1

Is it possible to tell Visual Studio to not analyze a specific file? In this case, GlobalSuppressions.cs. I can't find any setting for it in options.

I'm also trying to avoid messing up my code with suppress statements, so I want to keep GlobalSuppressions.cs, but not analyze it.

Syntax issues in GlobalSuppressions.cs: which I don't need

2 Answers 2

2

You can add the following to your root level .editorconfig file:

[yourfile.cs]
# Disable analyzers for a specific file
dotnet_diagnostic.CAxxxx.severity = none

CAxxxx should be replaced with a specific code analyzer rule you want to disable. In your case set it to none for disabling all analyzers on the file.

Hope this helps!


🤞🏼

Sign up to request clarification or add additional context in comments.

1 Comment

Yes that helped! Great solution
1

You can use preprocessor directives:

#pragma warning disable IDE0076
CSharpCodeProducingTheWarnings();
#pragma warning restore IDE0076

You can specify a comma delimited list of warnings if you want to suppress more than one warning.

You can also omit the #pragma warning restore to make the suppression active until the end of the file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.