既存の中規模プロジェクトで .NET 4 の CodeContracts の実験を始めたところですが、静的チェッカーが次のコードについてコンパイル時に警告を発していることに驚いています。
public class Foo
{
private readonly List<string> strs = new List<string>();
public void DoSomething()
{
// Compiler warning from the static checker:
// "requires unproven: source != null"
strs.Add("hello");
}
}
CodeContracts 静的チェッカーが strs.Add(...) 行について不平を言うのはなぜですか? strs が null になる方法はありませんよね?私は何か間違ったことをしていますか?