When I learned about Code Contracts, I assumed I could do the following:
public void ContractTest(string input)
{
Contract.Requires(input != null);
}
public void ContractTestCaller(string input)
{
this.ContractTest(input);
}
And get a warning since it is not possible to prove input != null
in ContractTestCaller
. However I don't get a warning.
Then I thought I might at least get a warning when I do this:
public void ContractTestCallerCaller()
{
this.ContractTestCaller(null);
}
But again, nothing.
I see three different possibilites:
Which one is it?
Here are my settings:
Turns out the issue is the "Infer Requires" option being checked. I do not completely understand why but it works when I turn it off.
I also found this link refering to the same problem:
https://github.com/Microsoft/CodeContracts/issues/439