I assume (pun intended) that this bug is related to #34.
Consider following code:
static bool Check()
{
Console.WriteLine("Check!");
return true;
}
private static IEnumerable<string> FooAsync1(string str)
{
Contract.Assert(Check() && str != null );
yield return str;
}
Rewriting this code with level < 4 (i.e. not in a Full mode) should remove Assert method call from the iterator block.
But in reality, ccrewriter removes anly method call itself, but leaves precondition check in the final IL code.
Running this code with Preconditions only, will print "Check" message on the screen.
The same behavior would be for async methods as well.
UPDATE: minor correction.
To reproduce this issue complexity of the expression matters but not where it was called (iterator block/async method/regular method):
private static void Foo(string str)
{
// Check method would be called
Contract.Assert(Check() && str != null);
Console.WriteLine("Boo");
}
private static void Foo2(string str)
{
// Call to Check method would be erased
Contract.Assert(Check());
Console.WriteLine("Boo");
}
With Preconditions only in Foo method Checkmethod would be called but inFoo2` method - not.