Skip to content

Commit 1a83452

Browse files
Copilotgewarren
andcommitted
Add breaking change documentation for DefaultValueAttribute DynamicallyAccessedMembers removal
Co-authored-by: gewarren <[email protected]>
1 parent 36d1db2 commit 1a83452

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

docs/core/compatibility/10.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af
3939
| [ActivitySource.CreateActivity and ActivitySource.StartActivity behavior change](core-libraries/10.0/activity-sampling.md) | Behavioral change | Preview 1 |
4040
| [C# 14 overload resolution with span parameters](core-libraries/10.0/csharp-overload-resolution.md) | Behavioral change | Preview 1 |
4141
| [Consistent shift behavior in generic math](core-libraries/10.0/generic-math.md) | Behavioral change | Preview 1 |
42+
| [DefaultValueAttribute(System.Type type, string? value) constructor no longer annotated with DynamicallyAccessedMembers](core-libraries/10.0/defaultvalueattribute-dynamically-accessed-members.md) | Binary incompatible/source incompatible | Preview 1 |
4243
| [Default trace context propagator updated to W3C standard](core-libraries/10.0/default-trace-context-propagator.md) | Behavioral change | Preview 4 |
4344
| [DriveInfo.DriveFormat returns Linux filesystem types](core-libraries/10.0/driveinfo-driveformat-linux.md) | Behavioral change | Preview 6 |
4445
| [GnuTarEntry and PaxTarEntry no longer includes atime and ctime by default](core-libraries/10.0/tar-atime-ctime-default.md) | Behavioral change | Preview 5 |
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "Breaking change: DefaultValueAttribute(System.Type type, string? value) constructor no longer annotated with DynamicallyAccessedMembers"
3+
description: "Learn about the breaking change in .NET 10 where DefaultValueAttribute(System.Type type, string? value) constructor is no longer annotated with DynamicallyAccessedMembers."
4+
ms.date: 01/30/2025
5+
ai-usage: ai-assisted
6+
---
7+
8+
# DefaultValueAttribute(System.Type type, string? value) constructor no longer annotated with DynamicallyAccessedMembers
9+
10+
The <xref:System.ComponentModel.DefaultValueAttribute.%23ctor(System.Type,System.String)?displayProperty=nameWithType> constructor is no longer annotated with <xref:System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute>. This constructor is not supported with trimming and will throw an exception if reached at runtime in a trimmed app.
11+
12+
## Version introduced
13+
14+
.NET 10
15+
16+
## Previous behavior
17+
18+
If the constructor was used in a trimmed app and the feature switch to disable exception throwing was used, publishing the app would generate a trimming warning and there was a chance the code would work at runtime.
19+
20+
## New behavior
21+
22+
If the constructor is used in a trimmed app and the feature switch to disable exception throwing is used, publishing the app will generate a trimming warning and there's a smaller chance the code will work at runtime.
23+
24+
## Type of breaking change
25+
26+
This change can affect [binary compatibility](../../categories.md#binary-compatibility) and [source compatibility](../../categories.md#source-compatibility).
27+
28+
## Reason for change
29+
30+
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.
31+
32+
## Recommended action
33+
34+
Do not enable the feature switch that attempts to make this attribute (unreliably) work in trimmed apps.
35+
36+
## Affected APIs
37+
38+
- <xref:System.ComponentModel.DefaultValueAttribute.%23ctor(System.Type,System.String)?displayProperty=fullName>

0 commit comments

Comments
 (0)