Contract Ensures unproven for GUID

I m having a ensures unproven: !ReferenceEquals(Contract.Result<T>(), null) that contract is on an interface I have no control of

my implementation is something like this

    public Guid Blah()
    {
        var guid = Guid.NewGuid();

        if(ReferenceEquals(guid, null))
        {
            throw new ApplicationException("This shoul");
        }

        return guid;
    }

I tired with contract assumes instead of the if and some variations of the code above, but still getting the warning, any ideas? Cheers


Seems like this is an interaction with the generic types. If you fix the type to Guid it works fine... I think this is a bug in Code Contracts, so I've filed a question on the Code Contracts forum.

链接地址: http://www.djcxy.com/p/74406.html

上一篇: 代码合同警告关于可能失败的'假设'呼叫

下一篇: 合同确保未经验证的GUID