Skip to content

Commit 9c429f5

Browse files
Copilotgewarren
andcommitted
Add breaking change documentation for DynamicallyAccessedMembers annotation removal
Co-authored-by: gewarren <[email protected]>
1 parent cd3d7b4 commit 9c429f5

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: "Breaking change: Removed DynamicallyAccessedMembers annotation from trim-unsafe Microsoft.Extensions.Configuration code"
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: 12/21/2024
5+
ai-usage: ai-assisted
6+
ms.custom: https://github.com/dotnet/docs/issues/47433
7+
---
8+
9+
# Removed DynamicallyAccessedMembers annotation from trim-unsafe Microsoft.Extensions.Configuration code
10+
11+
Certain Microsoft.Extensions.Configuration APIs that were marked as `RequiresUnreferencedCode` and had `DynamicallyAccessedMembers` annotations to preserve some necessary members during trimming have had those annotations removed completely. This change affects the trimming behavior of these APIs in .NET 10.
12+
13+
## Version introduced
14+
15+
.NET 10 Preview 6
16+
17+
## Previous behavior
18+
19+
Previously, certain Microsoft.Extensions.Configuration 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 same Microsoft.Extensions.Configuration APIs now work with even more limited use cases while still generating trimming warnings at publish time. The `DynamicallyAccessedMembers` annotations have been completely removed, reducing the amount of code preserved during trimming.
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 `DynamicallyAccessedMemberTypes.All` from the product. This change encourages users to migrate to more trim-safe alternatives.
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+
Overloads that generate trimming warnings.

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)