diff --git a/docs/core/compatibility/10.0.md b/docs/core/compatibility/10.0.md index 545e946cadccf..9030cfe7aeba8 100644 --- a/docs/core/compatibility/10.0.md +++ b/docs/core/compatibility/10.0.md @@ -43,6 +43,7 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af | [LDAP DirectoryControl parsing is now more stringent](core-libraries/10.0/ldap-directorycontrol-parsing.md) | Behavioral change | Preview 1 | | [MacCatalyst version normalization](core-libraries/10.0/maccatalyst-version-normalization.md) | Behavioral change | Preview 1 | | [.NET runtime no longer provides default SIGTERM signal handler](core-libraries/10.0/sigterm-signal-handler.md) | Behavioral change | Preview 5 | +| [Specifying explicit struct Size is now disallowed with InlineArray](core-libraries/10.0/inlinearray-explicit-size-disallowed.md) | Binary incompatible | Preview 7 | | [System.Linq.AsyncEnumerable included in core libraries](core-libraries/10.0/asyncenumerable.md) | Source incompatible | Preview 1 | | [YMM embedded rounding removed from AVX10.2](core-libraries/10.0/ymm-embedded-rounding.md) | Behavioral change | Preview 5 | diff --git a/docs/core/compatibility/core-libraries/10.0/inlinearray-explicit-size-disallowed.md b/docs/core/compatibility/core-libraries/10.0/inlinearray-explicit-size-disallowed.md new file mode 100644 index 0000000000000..c60633e773183 --- /dev/null +++ b/docs/core/compatibility/core-libraries/10.0/inlinearray-explicit-size-disallowed.md @@ -0,0 +1,38 @@ +--- +title: "Breaking change: Specifying explicit struct Size is now disallowed with InlineArray" +description: "Learn about the breaking change in .NET 10 where specifying explicit Size to a struct decorated with InlineArrayAttribute now throws TypeLoadException." +ms.date: 08/08/2025 +ai-usage: ai-assisted +--- + +# Specifying explicit struct Size is now disallowed with InlineArray + +Applying explicit `Size` to a struct decorated with is ambiguous and now is not supported in the type loader. Previously, specifying explicit `Size` would result in implementation-specific behavior that might or might not match user expectations. + +## Version introduced + +.NET 10 Preview 7 + +## Previous behavior + +Previously, specifying explicit `Size` would result in implementation-specific behavior that might or might not match user expectations. + +## New behavior + +Starting in .NET 10 Preview 7, creating instances of such structs and other uses will result in a being thrown. + +## Type of breaking change + +This change is a [binary incompatible](../../categories.md#binary-compatibility) change. Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation. + +## Reason for change + +Specifying `Size` for an inline array struct is ambiguous and any interpretation would contradict the specification. + +## Recommended action + +In the unlikely case where you need to specify explicit size either for the array element or for the whole inline array, introduce a struct wrapping the element type or the whole array type. In the layout of the wrapper, the `Size` can be specified accordingly and unambiguously. + +## Affected APIs + +- Type loader (affects types that were not originally rejected) diff --git a/docs/core/compatibility/toc.yml b/docs/core/compatibility/toc.yml index 5d759fa5537af..6bfb72e19e75f 100644 --- a/docs/core/compatibility/toc.yml +++ b/docs/core/compatibility/toc.yml @@ -44,6 +44,8 @@ items: href: core-libraries/10.0/maccatalyst-version-normalization.md - name: No default SIGTERM signal handler href: core-libraries/10.0/sigterm-signal-handler.md + - name: Specifying explicit struct Size is now disallowed with InlineArray + href: core-libraries/10.0/inlinearray-explicit-size-disallowed.md - name: System.Linq.AsyncEnumerable included in core libraries href: core-libraries/10.0/asyncenumerable.md - name: YMM embedded rounding removed from AVX10.2