All docs
V20.2
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Analyzer Suppression

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

You can choose one of the following suppression types:

  • In Source - uses the #pragma warning disable directive to suppress a single issue locally.

  • In Suppression File - creates or supplements the GlobalSuppressions.cs file with the SuppressMessage attribute. This type of suppression works only for members and broader scopes. Refer to the In Source Suppression Overview article to learn more.

  • In Source (attribute) - adds a SuppressMessage attribute in your code.

You can configure 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

You can disable analyzers permanently or change their severity in the Microsoft rule set:

CodeIssues_RuleSet