Compiler generates a different IAsyncStateMachine for await foreach to handle iteration on async enumerables. It contains a MoveNextAsync method beside MoveNext. So we can find this pattern by checking if this method exists and based on that transform the statements to await foreach.