Consider the following code :
public class RandomClass
{
private readonly string randomString;
public RandomClass(string randomParameter)
{
Contract.Requires(randomParameter != null);
Contract.Ensures(this.randomString != null);
this.randomString = randomParameter;
}
public string RandomMethod()
{
return // CodeContracts: requires unproven: replacement != null
Regex.Replace(string.Empty, string.Empty, this.randomString);
}
}
This ensures that randomString
will not be null when RandomMethod
gets executed. Why does code contracts analysis ignores this fact and throws a CodeContracts: requires unproven: replacement != null
warning?