我正在使用 Resharper 5.x 进行编译时分析,它通常非常好,但它似乎没有将代码契约应用于其逻辑。我有类似以下的内容,但我在标记线上遇到了问题。
public void Method(int arg)
{
Contract.Requires(this.NullableValueType != null);
this.Method2(
arg,
this.NullableValueType.Value, // [1]
this.ReferenceType);
}
[1] 最终以“可能的'System.InvalidOperationException'”突出显示。有没有办法在不关闭检查的情况下摆脱这个错误?