diff --git a/src/libraries/System.Private.CoreLib/src/System/Attribute.cs b/src/libraries/System.Private.CoreLib/src/System/Attribute.cs index 2bc115b9f686dc..045edd8b1f6447 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Attribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Attribute.cs @@ -10,12 +10,11 @@ namespace System [AttributeUsage(AttributeTargets.All, Inherited = true, AllowMultiple = false)] [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicFields | DynamicallyAccessedMemberTypes.PublicFields)] public abstract partial class Attribute { protected Attribute() { } - [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2075:UnrecognizedReflectionPattern", - Justification = "Unused fields don't make a difference for equality")] public override bool Equals([NotNullWhen(true)] object? obj) { if (obj == null) @@ -48,8 +47,6 @@ public override bool Equals([NotNullWhen(true)] object? obj) return true; } - [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2075:UnrecognizedReflectionPattern", - Justification = "Unused fields don't make a difference for hashcode quality")] public override int GetHashCode() { Type type = GetType(); diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 680a79f0102a2d..15819f3413301e 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -498,6 +498,7 @@ public AssemblyLoadEventArgs(System.Reflection.Assembly loadedAssembly) { } public delegate void AssemblyLoadEventHandler(object? sender, System.AssemblyLoadEventArgs args); public delegate void AsyncCallback(System.IAsyncResult ar); [System.AttributeUsageAttribute(System.AttributeTargets.All, Inherited=true, AllowMultiple=false)] + [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] public abstract partial class Attribute { protected Attribute() { }