Add polyfills for .NET 10 attributes. #131
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note
Depends on #127.
API breakdown (for new features)
Polyfills for the following attributes were added:
[CompilerLoweringPreserve]DynamicallyAccessedMembersAttribute, matching upstream.[ExtensionMarker]DynamicDependencyAttrribute.Conditionproperty in the polyfill was obsoleted and hidden, matching upstream.Polyfills for the following runtime-supported attributes were added:
[UnsafeAccessorType]Additional context (optional)
The list of attributes was populated by searching for the regex
: .+Attributein files matchingrelease-notes/10.0/api-diff/Microsoft.NETCore.Appin the branch of dotnet/core#10147, and excluding the attributes in OOB packages..NET 10 added the following properties to existing attributes that we polyfill:
namespace System.Diagnostics.CodeAnalysis { public sealed class ExperimentalAttribute : System.Attribute { + public string? Message { get; set; } } public sealed class RequiresDynamicCodeAttribute : System.Attribute { + public bool ExcludeStatics { get; set; } } public sealed class RequiresUnreferencedCodeAttribute : System.Attribute { + public bool ExcludeStatics { get; set; } } }Because it would lead to an inconsistent experience, where the polyfills will be added when targeting say .NET Standard, but not a .NET version earlier than 10, these changes are not polyfilled at this moment.
Also, the following runtime-supported attributes were not polyfilled:
TypeMapAssemblyTargetAttribute<TTypeGroup>,TypeMapAssociationAttribute<TTypeGroup>, andTypeMapAttribute<TTypeGroup>, because they are generic and would cause issues on downlevel runtimes.MetadataUpdateDeletedAttribute, because it is emitted by Hot Reload, and applying it manually is not allowed.