Making foreach on an IEnumerable allocation-free using reflection and dynamic methods

In this post I describe why foreach sometimes allocates, and show how you can use DynamicMethod and Reflection.Emit to go allocation-free