Skip to content

Commit

Permalink
Suppress trim warning caused by recent attribute removal changes (#62023
Browse files Browse the repository at this point in the history
)

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.
  • Loading branch information
vitek-karas authored Nov 26, 2021
1 parent 27a39e0 commit 90b8c70
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 90b8c70

Please sign in to comment.