How do I ignore a specific VS code analysis rule (say CA1305 : Microsoft.Globalization) within a:
(Assuming these options are all possible.)
To open this page, right-click the project node in Solution Explorer and select Properties. Select the Code Analysis tab. To disable source analysis at build time, uncheck the Run on build option. To disable live source analysis, uncheck the Run on live analysis option.
Use a #pragma warning (C#) or Disable (Visual Basic) directive to suppress the warning for only a specific line of code.
You can use the SupressMessage attribute like this:-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2233:OperationsShouldNotOverflow", MessageId = "newValue+1", Justification = "The reason I think its acceptable in this case")]
void SomeMethod()
{
// Some code that would normal cause this Code Analysis message
}
On a method, property, type etc.
Use #pragma warning(suppress: Cxxxx)
You can put the pragma at the appropriate scope in the source file (i.e. class, method)
See http://msdn.microsoft.com/en-us/library/2c8f766e(VS.80).aspx
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