-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API Proposal]: Enhance RequiresDynamicCode Attribute to apply to class #67368
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
I added the api-ready-for-review I don't think we will discuss anything interesting in this PR. I think is only worth discussing this in the API review meeting. |
Tagging subscribers to this area: @tommcdon Issue DetailsBackground and motivationThere are scenarios where it makes sense to apply this attribute to a class as discussed in this PR. In the particular case, the internal class is around runtime code generation and applying at the class level results in a better user experience as opposed to annotating at member level. The trimmer equivalent attribute, RequiresUnreferencedCode, already allows the attribute to be applied at class level. API Proposal namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(
AttributeTargets.Method |
AttributeTargets.Constructor |
+ AttributeTargets.Class,
Inherited = false)]
public partial class RequiresDynamicCodeAttribute: Attribute
{
}
} API Usage[RequiresDynamicCode("The native code for Regex compilation might not be available at runtime.")]
internal abstract class RegexCompiler Alternative DesignsNone and leave the RequiresDynamicCodeAttribute class as is, which would require working around the issue RisksRequires Analyzers build for this attribute and NativeAot compiler to adjust to the enhanced scope.
|
Looks good as proposed namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(
AttributeTargets.Method |
AttributeTargets.Constructor |
+ AttributeTargets.Class,
Inherited = false)]
public partial class RequiresDynamicCodeAttribute: Attribute
{
}
} |
Background and motivation
There are scenarios where it makes sense to apply this attribute to a class as discussed in this PR. In the particular case, the internal class is around runtime code generation and applying at the class level results in a better user experience as opposed to annotating at member level.
The trimmer equivalent attribute, RequiresUnreferencedCode, already allows the attribute to be applied at class level.
API Proposal
namespace System.Diagnostics.CodeAnalysis { [AttributeUsage( AttributeTargets.Method | AttributeTargets.Constructor | + AttributeTargets.Class, Inherited = false)] public partial class RequiresDynamicCodeAttribute: Attribute { } }
API Usage
Alternative Designs
None and leave the RequiresDynamicCodeAttribute class as is, which would require working around the issue
Risks
Requires Analyzers build for this attribute and NativeAot compiler to adjust to the enhanced scope.
The text was updated successfully, but these errors were encountered: