Ho il seguente codice nel mio .Net 4 app:Perché questo contratto basato su stringhe.Esure non è stato verificato?
static void Main(string[] args) {
Func();
}
static string S = "1";
static void Func() {
Contract.Ensures(S != Contract.OldValue(S));
S = S + "1";
}
Questo mi givens un avvertimento garantisce non provata in fase di compilazione:
warning : CodeContracts: ensures unproven: S != Contract.OldValue(S)
Che cosa sta succedendo? Funziona bene se S è un numero intero. Funziona anche se cambio l'Assicurare su S == Contract.OldValue(S + "1")
, ma non è quello che voglio fare.