开发者

Contract Ensures unproven for GUID

开发者 https://www.devze.com 2023-02-04 00:51 出处:网络
I m having a ensures unproven: !ReferenceEquals(Contract.Result<T>(), null) that contract is on an interface I have no control of

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消