Skip to content

Document InlineArray explicit Size breaking change for .NET 10 #47906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/core/compatibility/10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
Original file line number Diff line number Diff line change
@@ -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 <xref:System.Runtime.CompilerServices.InlineArrayAttribute> 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 <xref:System.TypeLoadException> 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)
2 changes: 2 additions & 0 deletions docs/core/compatibility/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading