Breyta

Deila með


DynamicallyAccessedMembers annotation removed from DefaultValueAttribute ctor

The DefaultValueAttribute.DefaultValueAttribute(Type, String) constructor is no longer annotated with DynamicallyAccessedMembersAttribute. This constructor is not supported with trimming and throws an exception if reached at runtime in a trimmed app.

Version introduced

.NET 10

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 runtime.

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 runtime.

Type of breaking change

This change can affect binary compatibility and 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.

Don't enable the feature switch that attempts to make DynamicallyAccessedMembersAttribute (unreliably) work in trimmed apps.

Affected APIs