Skip to content

Commit 7b81acb

Browse files
authored
Add breaking change documentation for DynamicallyAccessedMembers annotation removal in .NET 10 (#47525)
1 parent 383efc6 commit 7b81acb

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

docs/core/compatibility/10.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af
4141
| Title | Type of change | Introduced version |
4242
|-------|---------------------|--------------------|
4343
| [ProviderAliasAttribute moved to Microsoft.Extensions.Logging.Abstractions assembly](extensions/10.0/provideraliasattribute-moved-assembly.md) | Source incompatible | Preview 4 |
44+
| [Removed DynamicallyAccessedMembers annotation from trim-unsafe Microsoft.Extensions.Configuration code](extensions/10.0/dynamically-accessed-members-configuration.md) | Binary incompatible | Preview 6 |
4445

4546
## Globalization
4647

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: "Breaking change: DynamicallyAccessedMembers annotation removed from trim-unsafe configuration APIs"
3+
description: "Learn about the breaking change in .NET 10 where DynamicallyAccessedMembers annotations were removed from trim-unsafe Microsoft.Extensions.Configuration APIs."
4+
ms.date: 07/22/2025
5+
ai-usage: ai-assisted
6+
ms.custom: https://github.com/dotnet/docs/issues/47433
7+
---
8+
9+
# DynamicallyAccessedMembers annotation removed from trim-unsafe configuration APIs
10+
11+
[Certain APIs](#affected-apis) related to <xref:Microsoft.Extensions.Configuration> that were marked as <xref:System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute> were also annotated to preserve at least some of the necessary members when trimming. This made the API partially work when trimming, while still generating trimming warnings. The annotations are now removed completely. Users are encouraged to migrate to the source generator that works reliably with trimming.
12+
13+
## Version introduced
14+
15+
.NET 10 Preview 6
16+
17+
## Previous behavior
18+
19+
Previously, the [affected APIs](#affected-apis) worked with some limited use cases while generating trimming warnings at publish time. These APIs were annotated to preserve at least some of the necessary members when trimming, making the API partially functional in trimmed scenarios.
20+
21+
## New behavior
22+
23+
Starting in .NET 10, the [affected APIs](#affected-apis) now work with even more limited use cases while still generating trimming warnings at publish time.
24+
25+
## Type of breaking change
26+
27+
This change can affect [binary compatibility](../../categories.md#binary-compatibility).
28+
29+
## Reason for change
30+
31+
The annotations were removed as part of an effort to remove uses of <xref:System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All?displayProperty=nameWithType> from the product.
32+
33+
## Recommended action
34+
35+
Use the binding configuration source generator, which works reliably with trimming and provides a trim-safe alternative to these APIs.
36+
37+
## Affected APIs
38+
39+
- <xref:Microsoft.Extensions.Configuration.ConfigurationBinder.Get(Microsoft.Extensions.Configuration.IConfiguration,System.Type,System.Action{Microsoft.Extensions.Configuration.BinderOptions})?displayProperty=fullName>
40+
- <xref:Microsoft.Extensions.Configuration.ConfigurationBinder.GetValue(Microsoft.Extensions.Configuration.IConfiguration,System.Type,System.String)?displayProperty=fullName>
41+
- <xref:Microsoft.Extensions.Configuration.ConfigurationBinder.GetValue(Microsoft.Extensions.Configuration.IConfiguration,System.Type,System.String,System.Object)?displayProperty=fullName>
42+
- <xref:Microsoft.Extensions.Configuration.ConfigurationBinder.GetValue``1(Microsoft.Extensions.Configuration.IConfiguration,System.String)?displayProperty=fullName>
43+
- <xref:Microsoft.Extensions.Configuration.ConfigurationBinder.GetValue``1(Microsoft.Extensions.Configuration.IConfiguration,System.String,``0)?displayProperty=fullName>
44+
- <xref:Microsoft.Extensions.Configuration.ConfigurationBinder.Get``1(Microsoft.Extensions.Configuration.IConfiguration)?displayProperty=fullName>
45+
- <xref:Microsoft.Extensions.Configuration.ConfigurationBinder.Get``1(Microsoft.Extensions.Configuration.IConfiguration,System.Action{Microsoft.Extensions.Configuration.BinderOptions})?displayProperty=fullName>
46+
- <xref:Microsoft.Extensions.Logging.Configuration.LoggerProviderOptions.RegisterProviderOptions``2(Microsoft.Extensions.DependencyInjection.IServiceCollection)?displayProperty=fullName>
47+
- <xref:Microsoft.Extensions.Logging.ConsoleLoggerExtensions.AddConsoleFormatter``2(Microsoft.Extensions.Logging.ILoggingBuilder)?displayProperty=fullName>
48+
- <xref:Microsoft.Extensions.Logging.ConsoleLoggerExtensions.AddConsoleFormatter``2(Microsoft.Extensions.Logging.ILoggingBuilder,System.Action{``1})?displayProperty=fullName>
49+
- <xref:Microsoft.Extensions.DependencyInjection.OptionsBuilderConfigurationExtensions.BindConfiguration``1(Microsoft.Extensions.Options.OptionsBuilder{``0},System.String,System.Action{Microsoft.Extensions.Configuration.BinderOptions})?displayProperty=fullName>
50+
- <xref:Microsoft.Extensions.DependencyInjection.OptionsBuilderConfigurationExtensions.Bind``1(Microsoft.Extensions.Options.OptionsBuilder{``0},Microsoft.Extensions.Configuration.IConfiguration)?displayProperty=fullName>
51+
- <xref:Microsoft.Extensions.DependencyInjection.OptionsBuilderConfigurationExtensions.Bind``1(Microsoft.Extensions.Options.OptionsBuilder{``0},Microsoft.Extensions.Configuration.IConfiguration,System.Action{Microsoft.Extensions.Configuration.BinderOptions})?displayProperty=fullName>
52+
- <xref:Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure*?displayProperty=fullName>
53+
- <xref:Microsoft.Extensions.Options.ConfigureFromConfigurationOptions`1?displayProperty=fullName>
54+
- <xref:Microsoft.Extensions.Options.NamedConfigureFromConfigurationOptions`1?displayProperty=fullName>

docs/core/compatibility/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ items:
5050
items:
5151
- name: "ProviderAliasAttribute moved to Microsoft.Extensions.Logging.Abstractions assembly"
5252
href: extensions/10.0/provideraliasattribute-moved-assembly.md
53+
- name: "Removed DynamicallyAccessedMembers annotation from trim-unsafe Microsoft.Extensions.Configuration code"
54+
href: extensions/10.0/dynamically-accessed-members-configuration.md
5355
- name: Globalization
5456
items:
5557
- name: Environment variable renamed to DOTNET_ICU_VERSION_OVERRIDE

0 commit comments

Comments
 (0)