DevLabs > DevLabs Forums > Code Contracts > Adding ensures causes other contracts to fail
Ask a questionAsk a question
 

QuestionAdding ensures causes other contracts to fail

  • Sunday, November 08, 2009 4:35 AMPorges Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Ok, I have the following:

            [Pure]
            public override string NodeName
            {
                get
                {
                    return "#comment";
                }
            }
    
    All my contracts are proven by the static checker. However, when I change it to this:

            [Pure]
            public override string NodeName
            {
                get
                {
                    Contract.Ensures(Contract.Result<string>() == "#comment");
    
                    return "#comment";
                }
            }
    
    I get other (apparently unrelated) contracts failing. The point of failure is the 'return' line.

    The contracts in question are on the superclass of this, in an invariant:
            [ContractInvariantMethod]
            protected new void ObjectInvariant()
            {
                Contract.Invariant(dataField != null);
                Contract.Invariant(TextContent == dataField); // fails
                Contract.Invariant(NodeValue == dataField); // fails
                Contract.Invariant(Data == dataField);
            }
    
    Is this a bug in Contracts, or am I doing something wrong?

    I can supply full source if that will help.
    • Edited byPorges Sunday, November 08, 2009 4:37 AMadded some info
    •  

All Replies

  • Friday, November 13, 2009 4:34 PMMike BarnettMSFT, OwnerUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yes, if you can send us the full source that would help. I don't see anything immediate from the information you posted.
  • Monday, November 16, 2009 9:42 PMPorges Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Is there any specific email address I can use? It's a bit much code to post in a reply.
  • Wednesday, November 18, 2009 5:02 PMMike BarnettMSFT, OwnerUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yes! Please send it to codconfb _at_ microsoft _dot_ com. We can then take a look at it for you.