Is there anyway to suppress all error codes in one specific file?
Surprisingly I couldn't find this. This is pretty common scenario isn't it?
Documentation describes it seems:
- we have to disable it line by line or
- globally across all files.
CodePudding user response:
You can add this snippet at the very beginning of the file:
// <autogenerated />
This suppresses most warnings on that file.
CodePudding user response:
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 )
CodePudding user response:
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
