-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add DynamicallyAccessedMembersAttribute #33861
Comments
Looks good - I would add an overload with a message. Being able to customize the UX when this is reported as potential issue by the linker will be very valuable I think. |
/cc @eerhardt |
/cc @marek-safar |
namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(
AttributeTargets.Field |
AttributeTargets.ReturnValue |
AttributeTargets.GenericParameter |
AttributeTargets.Parameter |
AttributeTargets.Property)]
public sealed class DynamicallyAccessedMembersAttribute : Attribute
{
public DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberKinds memberKinds)
{
MemberKinds = memberKinds;
}
public DynamicallyAccessedMemberKinds MemberKinds { get; }
}
[Flags]
public enum DynamicallyAccessedMemberKinds
{
None = 0b00000000_00000000,
DefaultConstructor = 0b00000000_00000001,
PublicConstructors = 0b00000000_00000011,
NonPublicConstructors = 0b00000000_00000100,
PublicMethods = 0b00000000_00001000,
NonPublicMethods = 0b00000000_00010000,
PublicFields = 0b00000000_00100000,
NonPublicFields = 0b00000000_01000000,
PublicNestedTypes = 0b00000000_10000000,
NonPublicNestedTypes = 0b00000001_00000000,
PublicProperties = 0b00000010_00000000,
NonPublicProperties = 0b00000100_00000000,
PublicEvents = 0b00001000_00000000,
NonPublicEvents = 0b00010000_00000000,
}
} |
@terrajobst - I made some edits to your pasted API from the review.
|
One tiny naming question. We already have System.Reflection.MemberTypes. Would it make sense to name this enum @terrajobst @stephentoub @bartonjs @GrabYourPitchforks @MichalStrehovsky @vitek-karas ? |
Sounds fine to me. |
DynamicallyAccessedMembersAttribute DynamicDependencyAttribute UnconditionalSuppressMessageAttribute Fix dotnet#33861, dotnet#35339, dotnet#30902
This is in support of dotnet/linker#988 - see the spec there for motivation.
The text was updated successfully, but these errors were encountered: