I have the following code in my .Net 4 app:
static void Main(string[] args) {
Func();
}
static string S = "1";
static void Func() {
Contract.Ensures(S != Contract.OldValue(S));
S = S + "1";
}
This givens me an ensures unproven warning at compile time:
warning : CodeContracts: ensures unproven: S != Contract.OldValue(S)
What is going on? This works fine if S is an integer. It also works if I change the Ensure to S == Contract.OldValue(S + "1")
, but that's not what I want to do.