diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs index ef3cc90c16dbb0..2e7dc3253411b3 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs @@ -69,14 +69,23 @@ internal sealed partial class ReflectTypeDescriptionProvider : TypeDescriptionPr // These are attributes that, when we discover them on interfaces, we do // not merge them into the attribute set for a class. - private static readonly Type[] s_skipInterfaceAttributeList = new Type[] + private static readonly Type[] s_skipInterfaceAttributeList = InitializeSkipInterfaceAttributeList(); + + [UnconditionalSuppressMessage ("ReflectionAnalysis", "IL2045:AttributeRemoval", + Justification = "The ComVisibleAttribute is marked for removal and it's referenced here. Since this array" + + "contains only attributes which are going to be ignored, removing such attribute" + + "will not break the functionality in any way.")] + private static Type[] InitializeSkipInterfaceAttributeList() { + return new Type[] + { #if FEATURE_SKIP_INTERFACE - typeof(System.Runtime.InteropServices.GuidAttribute), - typeof(System.Runtime.InteropServices.InterfaceTypeAttribute) + typeof(System.Runtime.InteropServices.GuidAttribute), + typeof(System.Runtime.InteropServices.InterfaceTypeAttribute) #endif - typeof(System.Runtime.InteropServices.ComVisibleAttribute), - }; + typeof(System.Runtime.InteropServices.ComVisibleAttribute), + }; + } internal static Guid ExtenderProviderKey { get; } = Guid.NewGuid();