Skip to main content
All docs
V22.2
  • Suppress Analyzers

    Visual Studio UI

    Invoke the Code Actions Menu for a code issue to suppress analyzers.

    Place the caret in an issue in the code editor, and press Ctrl+. or Ctrl+~.

    CodeIssues_Suppress

    Source Code

    You can suppress violations in your source code as follows:

    As a directive
    Use the #pragma warning disable directive to suppress a single issue locally. Read more: Pragmas.
    As an attribute
    Add a SuppressMessageAttribute attribute in your code. Read more: In-source suppression and the SuppressMessageAttribute attribute.
    In a global suppression file
    Create or supplement the GlobalSuppressions.cs file with the SuppressMessageAttribute attribute. This type of suppression works only for members and broader scopes. Read more: Suppress violations using a global suppression file.

    The SuppressMessageAttribute or #pragma approaches are standard ways to silence warnings in Visual Studio. This info is valid for any code issue.

    Configure Analyzer Set

    You can configure an analyzer set for Visual Studio’s Error List window.

    In the Solution Explorer, expand <Your project> | References, right-click Analyzers, and choose the Open Active Rule Set item.

    CodeIssues_RuleSet

    Disable analyzers permanently or change their severity in the Microsoft rule set:

    CodeIssues_RuleSet

    See Also