How to Ignore specific file from Visual Studio Warnings Analyzer?

Viewed 461
3 Answers

Make a section in the .editorconfig file for that given class; specify its file name [{YourClass.cs}] or path [{Folder/YourClass.cs}]in a section and set the severity for all rules to none.

See the All rules scope in the documentation.

[{YourClass.cs}]
dotnet_analyzer_diagnostic.severity = none

You can add this snippet at the very beginning of the file:

// <autogenerated />

This suppresses most warnings on that file.

Use #pragma warning ( push ), then #pragma warning ( disable ), then put your code, then use #pragma warning ( pop ) as described here:

Replace warningCode below with the real codes

 #pragma warning( push )
 #pragma warning( disable : WarningCode)
 //code with warning
 #pragma warning( pop )
Related