Skip to content

Commit

Permalink
Add one more suppression to class which marks RUC methods
Browse files Browse the repository at this point in the history
Recent changes modified the behavior of trimmer where it will now report warnings for all marked methods which have RUC. Previously it tried to avoid duplicate warnings by only doing this for base methods in virtual hierarchies. But that had bugs and the behavior was very complex and hard to predict. So now it warns always.

The DbConnectionStringBuilder class implement ICustomTypeDescriptor interface which has several methods marked with RUC - so the trimmer reported 2113 on all of these. But it didn't warn on the implementation. Now it warns on the implementation as well, with 2112.

The suppression has the same reason as previously, so no functional change.
  • Loading branch information
vitek-karas committed Jun 5, 2023
1 parent 48c3232 commit 472b161
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace System.Data.Common
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2113:ReflectionToRequiresUnreferencedCode",
Justification = "The use of GetType preserves ICustomTypeDescriptor members with RequiresUnreferencedCode, but the GetType callsites either "
+ "occur in RequiresUnreferencedCode scopes, or have individually justified suppressions.")]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode",

This comment has been minimized.

Copy link
@sbomer

sbomer Jun 5, 2023

Member

I may be wrong, but I thought that IL2112 would be reported on the member with RUC and would have to be suppressed there, not on the type.

This comment has been minimized.

Copy link
@vitek-karas

vitek-karas Jun 5, 2023

Author Member

The suppression has lexical scope - so suppressing on a type suppresses everything everywhere in that type
The warning IS reported on the member in question.

This comment has been minimized.

Copy link
@vitek-karas

vitek-karas Jun 5, 2023

Author Member

I mean I could change this to add like 15 separate suppressions, but it felt wrong

This comment has been minimized.

Copy link
@sbomer

sbomer Jun 5, 2023

Member

Makes sense, thanks! LGTM.

Justification = "The use of GetType preserves implementation of ICustomTypeDescriptor members with RequiresUnreferencedCode, but the GetType callsites either "
+ "occur in RequiresUnreferencedCode scopes, or have individually justified suppressions.")]
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
public class DbConnectionStringBuilder : IDictionary, ICustomTypeDescriptor
{
Expand Down

0 comments on commit 472b161

Please # to comment.