Skip to main content

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+~.


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.


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