Search code examples
c#.netcode-contracts

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


Solution

  • 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.