如何忽略以下内容中的特定VS代码分析规则(例如CA1305:Microsoft.Globalization):


方法?
类?
命名空间?


(假设所有这些选项都是可能的。)

最佳答案

您可以像这样使用SupressMessage属性:

[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
}


在方法,属性,类型等上

关于visual-studio - 忽略Visual Studio中的代码分析规则,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1445415/

10-10 21:16