Skip to content

Commit 90b8c70

Browse files
authored
Suppress trim warning caused by recent attribute removal changes (#62023)
This fixes a new warning generated by trimming some apps which was introduced in #54056. The `ComVisibleAttribute` in this case is referenced, but if it's removed it doesn't change functionality in any way.
1 parent 27a39e0 commit 90b8c70

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,23 @@ internal sealed partial class ReflectTypeDescriptionProvider : TypeDescriptionPr
6969

7070
// These are attributes that, when we discover them on interfaces, we do
7171
// not merge them into the attribute set for a class.
72-
private static readonly Type[] s_skipInterfaceAttributeList = new Type[]
72+
private static readonly Type[] s_skipInterfaceAttributeList = InitializeSkipInterfaceAttributeList();
73+
74+
[UnconditionalSuppressMessage ("ReflectionAnalysis", "IL2045:AttributeRemoval",
75+
Justification = "The ComVisibleAttribute is marked for removal and it's referenced here. Since this array" +
76+
"contains only attributes which are going to be ignored, removing such attribute" +
77+
"will not break the functionality in any way.")]
78+
private static Type[] InitializeSkipInterfaceAttributeList()
7379
{
80+
return new Type[]
81+
{
7482
#if FEATURE_SKIP_INTERFACE
75-
typeof(System.Runtime.InteropServices.GuidAttribute),
76-
typeof(System.Runtime.InteropServices.InterfaceTypeAttribute)
83+
typeof(System.Runtime.InteropServices.GuidAttribute),
84+
typeof(System.Runtime.InteropServices.InterfaceTypeAttribute)
7785
#endif
78-
typeof(System.Runtime.InteropServices.ComVisibleAttribute),
79-
};
86+
typeof(System.Runtime.InteropServices.ComVisibleAttribute),
87+
};
88+
}
8089

8190

8291
internal static Guid ExtenderProviderKey { get; } = Guid.NewGuid();

0 commit comments

Comments
 (0)