Is that true that Code Contracts static analysis cannot check the explicit return new ...
in a single branch methods (methods that don't have any conditionals and have only one return
) like:
static public Tuple<int> Foo()
{
return new Tuple<int>(42);
}
still warns me with
warning : CodeContracts: Possibly calling a method on a null reference. Do you expect that SomeClassName.Foo() returns non-null?
I indeed can help a static checker with
Contract.Ensures(Contract.Result<Tuple<int>>() != null);
explicitly but it looks like a huge overhead.
So my question is: am I missing something or that's my obligation to Ensure
even such a trivial cases?