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?
If you migrate a project to Visual Studio 2019, you might suddenly be faced with a large number of code analysis warnings. If you aren't ready to fix the warnings, you can suppress all of them by selecting Analyze > Build and Suppress Active Issues.
If we don't want to fix the warning, then we can suppress it with the @SuppressWarnings annotation. This annotation allows us to say which kinds of warnings to ignore. While warning types can vary by compiler vendor, the two most common are deprecation and unchecked.
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.
Some additional information from MSDN:
MSDN - In Source Suppression
"The global suppression file maintains suppressions that are either global-level suppressions or suppressions that do not specify a target. For example, suppressions for assembly level violations are stored in this file. "
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With