Search code examples
c#visual-studiocode-analysis

How to configure Visual Studio not to analyse code in a specific file


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


Solution

  • 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!


    🤞🏼