Search code examples
.netcode-contracts

Ensure interface readonly property does not change


Consider the following interface:

interface IToto
{
    string Name {get;}
}

Using Code Contracts, how can I make sure that the Name property value never changes?

I tried using Contract.OldValue within a ContractInvariantMethod-marked method but appearantly it isn't supported. Anything else I can do?


Solution

  • Found my answer here. Appearantly it isn't yet supported by Code Contracts.