Visual studio 2013 VS codeanalysis CA1062即使在空检查后也会激发
我有一个使用visualstudio代码分析的Sitecore项目。我正在使用Sitecore方法“Assert.ArgumentNotNull”检查空参数,但是visualstudio代码分析引擎无法识别它并显示“CA1062验证公共方法的参数”消息 有没有一种更简单的方法来告诉分析引擎“Assert.ArgumentNotNull”执行空检查并且消息无效,而不是创建自定义规则Visual studio 2013 VS codeanalysis CA1062即使在空检查后也会激发,visual-studio-2013,sitecore,fxcop,Visual Studio 2013,Sitecore,Fxcop,我有一个使用visualstudio代码分析的Sitecore项目。我正在使用Sitecore方法“Assert.ArgumentNotNull”检查空参数,但是visualstudio代码分析引擎无法识别它并显示“CA1062验证公共方法的参数”消息 有没有一种更简单的方法来告诉分析引擎“Assert.ArgumentNotNull”执行空检查并且消息无效,而不是创建自定义规则 我不想禁止或禁用该消息。您不能以这种方式使用Sitecore的Assert类,这就是为什么: SitecoreAss
我不想禁止或禁用该消息。您不能以这种方式使用Sitecore的
Assert
类,这就是为什么:
SitecoreAssert
类以及NotNullAttribute
和CanBeNullAttribute
都是按照ReSharper在执行自己的分析时能够理解的方式制作的
Assert.ArgumentNotNull(对象,字符串)
方法的定义如下:
[AssertionMethod]
public static void ArgumentNotNull([CanBeNull] [AssertionCondition(AssertionConditionType.IS_NOT_NULL)] object argument, [CanBeNull] [InvokerParameterName] string argumentName)
所有这些属性都是在Sitecore中定义的,R#理解它们是因为命名约定
不幸的是,VS代码分析还有另一个命名约定ArgumentNotNull
对您来说应该是这样的:
public static void ArgumentNotNull([ValidatedNotNull] object argument, string argumentName)
由于不能修改断言
类,因此不能使用ValidatedNotNullAttribute
标记参数