diff --git a/docs/core/compatibility/10.0.md b/docs/core/compatibility/10.0.md index 6406589933843..acea12efdbcb7 100644 --- a/docs/core/compatibility/10.0.md +++ b/docs/core/compatibility/10.0.md @@ -41,6 +41,7 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af | [Consistent shift behavior in generic math](core-libraries/10.0/generic-math.md) | Behavioral change | Preview 1 | | [Default trace context propagator updated to W3C standard](core-libraries/10.0/default-trace-context-propagator.md) | Behavioral change | Preview 4 | | [DriveInfo.DriveFormat returns Linux filesystem types](core-libraries/10.0/driveinfo-driveformat-linux.md) | Behavioral change | Preview 6 | +| [DynamicallyAccessedMembers annotation removed from DefaultValueAttribute ctor](core-libraries/10.0/defaultvalueattribute-dynamically-accessed-members.md) | Binary/source incompatible | Preview 7 | | [GnuTarEntry and PaxTarEntry no longer includes atime and ctime by default](core-libraries/10.0/tar-atime-ctime-default.md) | Behavioral change | Preview 5 | | [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 | diff --git a/docs/core/compatibility/core-libraries/10.0/defaultvalueattribute-dynamically-accessed-members.md b/docs/core/compatibility/core-libraries/10.0/defaultvalueattribute-dynamically-accessed-members.md new file mode 100644 index 0000000000000..08e7ae4048bf6 --- /dev/null +++ b/docs/core/compatibility/core-libraries/10.0/defaultvalueattribute-dynamically-accessed-members.md @@ -0,0 +1,38 @@ +--- +title: "Breaking change: 'DynamicallyAccessedMembers' annotation removed from 'DefaultValueAttribute' ctor" +description: "Learn about the breaking change in .NET 10 where a 'DefaultValueAttribute' constructor is no longer annotated with 'DynamicallyAccessedMembers'." +ms.date: 08/11/2025 +ai-usage: ai-assisted +--- + +# `DynamicallyAccessedMembers` annotation removed from `DefaultValueAttribute` ctor + +The constructor is no longer annotated with . This constructor is not supported with trimming and throws an exception if reached at run time in a trimmed app. + +## Version introduced + +.NET 10 Preview 7 + +## Previous behavior + +Previously, if the constructor was used in a trimmed app and the feature switch to disable exception throwing was used, publishing the app generated a trimming warning, and there was a chance the code worked at run time. + +## New behavior + +Starting in .NET 10, if the constructor is used in a trimmed app and the feature switch to disable exception throwing is used, publishing the app still generates a trimming warning. But there's a smaller chance the code will work at run time. + +## Type of breaking change + +This change can affect [binary compatibility](../../categories.md#binary-compatibility) and [source compatibility](../../categories.md#source-compatibility). + +## Reason for change + +This attribute should not be used in trimmed apps because it doesn't reliably work. Trimming should be free to remove type members mentioned in the attribute. + +## Recommended action + +Don't enable the feature switch that attempts to make (unreliably) work in trimmed apps. + +## Affected APIs + +- diff --git a/docs/core/compatibility/toc.yml b/docs/core/compatibility/toc.yml index 9f99fed62c5cb..dc1cf6fedf993 100644 --- a/docs/core/compatibility/toc.yml +++ b/docs/core/compatibility/toc.yml @@ -40,6 +40,8 @@ items: href: core-libraries/10.0/default-trace-context-propagator.md - name: DriveInfo.DriveFormat returns Linux filesystem types href: core-libraries/10.0/driveinfo-driveformat-linux.md + - name: DynamicallyAccessedMembers annotation removed from DefaultValueAttribute ctor + href: core-libraries/10.0/defaultvalueattribute-dynamically-accessed-members.md - name: GnuTarEntry and PaxTarEntry exclude atime and ctime by default href: core-libraries/10.0/tar-atime-ctime-default.md - name: LDAP DirectoryControl parsing is now more stringent