<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />

System.Reflection.Emit.DynamicMethod

public sealed class DynamicMethod : MethodInfo
Defines and represents a dynamic method that can be compiled, executed, and discarded. Discarded methods are available for garbage collection.
public bool InitLocals { get; set; }

Gets or sets a value indicating whether the local variables in the method are zero-initialized.

public DynamicMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Module m, bool skipVisibility)

Creates a dynamic method that is global to a module, specifying the method name, attributes, calling convention, return type, parameter types, module, and whether just-in-time (JIT) visibility checks should be skipped for types and members accessed by the Microsoft intermediate language (MSIL) of the dynamic method.

public DynamicMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type owner, bool skipVisibility)

Creates a dynamic method, specifying the method name, attributes, calling convention, return type, parameter types, the type with which the dynamic method is logically associated, and whether just-in-time (JIT) visibility checks should be skipped for types and members accessed by the Microsoft intermediate language (MSIL) of the dynamic method.

public DynamicMethod(string name, Type returnType, Type[] parameterTypes)

Initializes an anonymously hosted dynamic method, specifying the method name, return type, and parameter types.

public DynamicMethod(string name, Type returnType, Type[] parameterTypes, bool restrictedSkipVisibility)

Initializes an anonymously hosted dynamic method, specifying the method name, return type, parameter types, and whether just-in-time (JIT) visibility checks should be skipped for types and members accessed by the Microsoft intermediate language (MSIL) of the dynamic method.

public DynamicMethod(string name, Type returnType, Type[] parameterTypes, Module m)

Creates a dynamic method that is global to a module, specifying the method name, return type, parameter types, and module.

public DynamicMethod(string name, Type returnType, Type[] parameterTypes, Module m, bool skipVisibility)

Creates a dynamic method that is global to a module, specifying the method name, return type, parameter types, module, and whether just-in-time (JIT) visibility checks should be skipped for types and members accessed by the Microsoft intermediate language (MSIL) of the dynamic method.

public DynamicMethod(string name, Type returnType, Type[] parameterTypes, Type owner)

Creates a dynamic method, specifying the method name, return type, parameter types, and the type with which the dynamic method is logically associated.

public DynamicMethod(string name, Type returnType, Type[] parameterTypes, Type owner, bool skipVisibility)

Creates a dynamic method, specifying the method name, return type, parameter types, the type with which the dynamic method is logically associated, and whether just-in-time (JIT) visibility checks should be skipped for types and members accessed by the Microsoft intermediate language (MSIL) of the dynamic method.

public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, string parameterName)

Defines a parameter of the dynamic method.

Returns a Microsoft intermediate language (MSIL) generator for the method with a default MSIL stream size of 64 bytes.

public ILGenerator GetILGenerator(int streamSize)

Returns a Microsoft intermediate language (MSIL) generator for the method with the specified MSIL stream size.