void InitMethodSpec(DynamicMethod method) { var implFlags = method.GetMethodImplementationFlags(); this.methodSpec = "dynamic " + (method.IsStatic ? "static " : "instance ") + ((method.ReturnType != null && method.ReturnType != typeof(void)) ? method.ReturnType.ToString() + " " : "void ") + method.Name + " " + implFlags.ToString().ToLower(); }
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 + ")"); }
public override MethodImplAttributes GetMethodImplementationFlags() => m_owner.GetMethodImplementationFlags();
public override MethodImplAttributes GetMethodImplementationFlags() { return(_dynamicMethod.GetMethodImplementationFlags()); }