static void DumpMethod(DynamicMethod method) { Console.Clear(); Console.WriteLine(method.ToString() + " " + method.GetMethodImplementationFlags().ToString()); // ILGenerator ILGen = method.GetILGenerator(); int maxStackSize = (int)ILGen.@ƒ("m_maxStackSize"); byte[] ilBytes, localSignature; var resolver = method.@ƒ("m_resolver"); if (resolver != null) { Type DynamicResolverType = Type.GetType("System.Reflection.Emit.DynamicResolver"); ilBytes = (byte[])resolver.@ƒ(DynamicResolverType, "m_code"); localSignature = (byte[])resolver.@ƒ(DynamicResolverType, "m_localSignature"); } else { ilBytes = new byte[ILGen.ILOffset]; Array.Copy((byte[])ILGen.@ƒ("m_ILStream"), ilBytes, ilBytes.Length); localSignature = ((SignatureHelper)ILGen.@ƒ("m_localSignature")).GetSignature(); } Console.WriteLine(string.Format("// Code size {0} (0x{0:X2}) ", ilBytes.Length)); Console.WriteLine(".maxstack " + maxStackSize.ToString()); if (localSignature != null && localSignature.Length > 0) { Console.WriteLine("// LocalSignature"); DumpBytes(localSignature, 2, ConsoleColor.Yellow); Console.WriteLine(); } // Console.WriteLine(".body ("); DumpBytes(ilBytes); Console.WriteLine(Environment.NewLine + ")"); }