Search code examples
c#warningssuppress-warnings

When do I suppress warnings to source vs. Project Suppression File


I'm working on resolving about 300 warnings and some of the warnings are unnecessary and can be suppressed. However, my question is do I suppress them in the Source - an attribute is added above the method - Or do I suppress them in the GlobalSuppressioins.cs? Is there any guidance for this, if so where?


Solution

  • The GlobalSuppression.cs file is for SuppressMessage attributes that cannot be placed in the source files. If a suppression can be placed in a source file it should.

    Issues that cannot be placed in the source file are things like "namespaces should have at least five classes". You can't place an attribute on a namespace so it goes in the global suppressions file.