<PackageReference Include="System.Reflection.Emit" Version="4.6.0-preview5.19224.8" />

MethodBuilder

public sealed class MethodBuilder : MethodInfo
Defines and represents a method (or constructor) on a dynamic class.
public bool InitLocals { get; set; }

Gets or sets a Boolean value that specifies whether the local variables in this method are zero initialized. The default value of this property is true.

Sets the number of generic type parameters for the current method, specifies their names, and returns an array of GenericTypeParameterBuilder objects that can be used to define their constraints.

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

Sets the parameter attributes and the name of a parameter of this method, or of the return value of this method. Returns a ParameterBuilder that can be used to apply custom attributes.

Returns an ILGenerator for this method with a default Microsoft intermediate language (MSIL) stream size of 64 bytes.

public ILGenerator GetILGenerator(int size)

Returns an ILGenerator for this method with the specified Microsoft intermediate language (MSIL) stream size.

public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)

Sets a custom attribute using a specified custom attribute blob.

public void SetCustomAttribute(CustomAttributeBuilder customBuilder)

Sets a custom attribute using a custom attribute builder.

Sets the implementation flags for this method.

public void SetParameters(Type[] parameterTypes)

Sets the number and types of parameters for a method.

public void SetReturnType(Type returnType)

Sets the return type of the method.

public void SetSignature(Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)

Sets the method signature, including the return type, the parameter types, and the required and optional custom modifiers of the return type and parameter types.