代码合同。 “始终评估为常量值”警告的错误号

时间:2015-05-20 08:26:25

标签: c# code-contracts

该代码中的错误警告:

return (Patient as IHrsHolder) ?? (Course as IHrsHolder) ?? Appointment;

我想抑制警告,所以我需要错误号码。但错误列表或输出中没有任何数字,只有:

CodeContracts: warning: The Boolean condition this.Patient == null always evaluates to a constant value. If it (or its negation) appear in the source code, you may have some dead code or redundant check

如何抑制(不重写代码)?

1 个答案:

答案 0 :(得分:0)

在这种情况下,“ErrorNumber”实际上是一个字符串:

[SuppressMessage("Microsoft.Contracts", "TestAlwaysEvaluatingToAConstant")]