Back to Devexpress

Suppress Analyzers

coderushforroslyn-401560-static-code-analysis-analyzer-suppression.md

latest2.0 KB
Original Source

Suppress Analyzers

  • Mar 03, 2025

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

Source Code

You can suppress violations in your source code as follows:

As a directiveUse the #pragma warning disable directive to suppress a single issue locally. Read more: Pragmas.As an attributeAdd a SuppressMessageAttribute attribute in your code. Read more: In-source suppression and the SuppressMessageAttribute attribute.In a global suppression fileCreate 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.

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

See Also

Analyzers Library