I've got this code:
public class CodeContractSample
{
private readonly List<object> _items = new List<object>();
public IEnumerable<object> Query()
{
Contract.Ensures(Contract.Result<IEnumerable<object>>() != null);
//if (_items == null) throw new Exception();
return _items;
}
}
CodeContracts gives this warning:
CodeContracts: ensures unproven: Contract.Result>() != null
If I uncomment the middle row it stops complaining. But why does it complain to start with? _items should never be null..?