I'm trying to play with CodeContracts. I'm starting with a little function
public static string MyTrim(string text)
{
Contract.Requires(text != null);
Contract.Ensures(Contract.Result<string>().Length == 0 || Contract.Result<string>()[0] != ' ');
var sCurrent = text;
while (sCurrent.Length != 0 && sCurrent[0] == ' ')
{
sCurrent = sCurrent.Substring(1);
}
return sCurrent;
}
Code Contracts says to me that I didn't prove the Ensures. But After the while loop I know that the condition is false. So I know that
Scurrent.Length == 0 || Scurrent[0] != ' '
Which is exactly my ensure condition. What can i do to explain that to Code COntracts ?