Microsoft コード コントラクトに 3.5 ライブラリを使用しています
public object RetrieveById(int Id)
{
//stuff happens...
Contract.Ensures(newObject != null, "object must not be null");
return newProject;
//No error message if I move the Contract.Ensures to here
//But it isn't asserting/throwing a contract exception here either
}
次のコンパイラ メッセージが表示されます。
アップデート:
私はあなたの助けを借りてそれを理解しました:
- トップに移動
Contract.Result と照合する
Contract.Ensures(Contract.Result() != null, "オブジェクトを null にすることはできません");