How do I set the exception property for cleanliness?
I have a class like below and I only want to change x
in the method Foo
and no other property. I cannot use [Pure]
as in the following example because it blocks 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 except x
:
Contract.Ensures(Contract.OldValue<int>(y) == y);
Contract.Ensures(Contract.OldValue<int>(z) == z);
...//and for other large number of properties
Is there a way to do this?
+3
source to share
2 answers