Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress warning if UnconditionalSuppressMessageAttribute is used #1892

Closed
wants to merge 2 commits into from

Conversation

agocke
Copy link
Member

@agocke agocke commented Mar 15, 2021

If/when Roslyn ships a universal suppress behavior here we can remove this code.

@agocke agocke requested a review from marek-safar as a code owner March 15, 2021 11:10
@agocke agocke requested review from mateoatr and tlakollo March 15, 2021 11:11

internal static bool IsDiagnosticSuppressed(OperationAnalysisContext operationContext, string diagnosticId)
{
var attributes = operationContext.ContainingSymbol.GetAttributes();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work when the suppression is up in the tree?
e.g.

[UnconditionalSuppressMessage ("", "IL1234:MyWarning")]
class Foo {
   void Bar () {
     // Triggers warning IL1234
  }
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this only handles local suppression. Global suppression support will have to be added in another PR.

Copy link
Contributor

@mateoatr mateoatr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about unconditional suppressions that use the target property?

@agocke
Copy link
Member Author

agocke commented Mar 16, 2021

As far as I can tell, the Target property is only relevant on attributes higher than the member level.

@agocke
Copy link
Member Author

agocke commented Mar 18, 2021

I'm gonna close this for now, since it looks like the Roslyn change is gonna go through.

@tlakollo
Copy link
Contributor

Closing in favor of dotnet/roslyn#51792

@tlakollo tlakollo closed this Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants