I have class like bellow and I want to only let x be changed in Foo method and no other property. I can't use [Pure] like following example, because it locks all properties:
public class Test
{
private int x,y,z; //number of these properties is large
[Pure]
public void Foo()
{
//only x must be allowed to change
}
}
and I don't want to use something like this for all other properties than x:
Contract.Ensures(Contract.OldValue<int>(y) == y);
Contract.Ensures(Contract.OldValue<int>(z) == z);
...//and for other large number of properties
Is there any way to do this?
It seems there is no method implemented for this purpose in
Contractclass.