MethodBodyStreamEncoder.AddMethodBody Method

Definition

Overloads

AddMethodBody(InstructionEncoder, Int32, StandaloneSignatureHandle, MethodBodyAttributes)

Encodes a method body and adds it to the method body stream.

AddMethodBody(InstructionEncoder, Int32, StandaloneSignatureHandle, MethodBodyAttributes, Boolean)

Encodes a method body and adds it to the method body stream, using the provided instruction encoder, maximum stack size, local variables' signature handle, method body attributes, and allowing to indicate whether the method should allocate from the dynamic local memory pool or not.

AddMethodBody(Int32, Int32, Int32, Boolean, StandaloneSignatureHandle, MethodBodyAttributes)

Encodes a method body and adds it to the method body stream, using the provided code size, maximum stack size, number of exception regions, local variables' signature handle, method body attributes and allowing to indicate whether the exception regions should be encoded in small format or not.

AddMethodBody(Int32, Int32, Int32, Boolean, StandaloneSignatureHandle, MethodBodyAttributes, Boolean)

Encodes a method body and adds it to the method body stream, using the provided code size, maximum stack size, number of exception regions, local variables' signature handle, method body attributes, allowing to indicate whether the exception regions should be encoded in small format or not, and allowing to indicate whether the method should allocate from the dynamic local memory pool or not.

AddMethodBody(InstructionEncoder, Int32, StandaloneSignatureHandle, MethodBodyAttributes)

Source:
MethodBodyStreamEncoder.cs
Source:
MethodBodyStreamEncoder.cs
Source:
MethodBodyStreamEncoder.cs
Source:
MethodBodyStreamEncoder.cs

Encodes a method body and adds it to the method body stream.

C#
public int AddMethodBody(System.Reflection.Metadata.Ecma335.InstructionEncoder instructionEncoder, int maxStack, System.Reflection.Metadata.StandaloneSignatureHandle localVariablesSignature, System.Reflection.Metadata.Ecma335.MethodBodyAttributes attributes);
C#
public int AddMethodBody(System.Reflection.Metadata.Ecma335.InstructionEncoder instructionEncoder, int maxStack = 8, System.Reflection.Metadata.StandaloneSignatureHandle localVariablesSignature = default, System.Reflection.Metadata.Ecma335.MethodBodyAttributes attributes = System.Reflection.Metadata.Ecma335.MethodBodyAttributes.InitLocals);

Parameters

instructionEncoder
InstructionEncoder

The instruction encoder.

maxStack
Int32

The maximum stack size.

localVariablesSignature
StandaloneSignatureHandle

The local variables' signature handle.

attributes
MethodBodyAttributes

The method body attributes.

Returns

The offset of the encoded body within the method body stream.

Exceptions

instructionEncoder has default value.

maxStack is out of range [0, UInt16.MaxValue].

A label targeted by a branch in the instruction stream has not been marked, or the distance between a branch instruction and the target label doesn't fit the size of the instruction operand.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

AddMethodBody(InstructionEncoder, Int32, StandaloneSignatureHandle, MethodBodyAttributes, Boolean)

Source:
MethodBodyStreamEncoder.cs
Source:
MethodBodyStreamEncoder.cs
Source:
MethodBodyStreamEncoder.cs
Source:
MethodBodyStreamEncoder.cs

Encodes a method body and adds it to the method body stream, using the provided instruction encoder, maximum stack size, local variables' signature handle, method body attributes, and allowing to indicate whether the method should allocate from the dynamic local memory pool or not.

C#
public int AddMethodBody(System.Reflection.Metadata.Ecma335.InstructionEncoder instructionEncoder, int maxStack = 8, System.Reflection.Metadata.StandaloneSignatureHandle localVariablesSignature = default, System.Reflection.Metadata.Ecma335.MethodBodyAttributes attributes = System.Reflection.Metadata.Ecma335.MethodBodyAttributes.InitLocals, bool hasDynamicStackAllocation = false);

Parameters

instructionEncoder
InstructionEncoder

The instruction encoder.

maxStack
Int32

The maximum stack size.

localVariablesSignature
StandaloneSignatureHandle

The local variables' signature handle.

attributes
MethodBodyAttributes

The method body attributes.

hasDynamicStackAllocation
Boolean

true if the method allocates from the dynamic local memory pool (the IL contains the localloc instruction); false otherwise.

Returns

The offset of the encoded body within the method body stream.

Exceptions

instructionEncoder has default value.

maxStack is out of range [0, UInt16.MaxValue].

A label targeted by a branch in the instruction stream has not been marked, or the distance between a branch instruction and the target label doesn't fit the size of the instruction operand.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

AddMethodBody(Int32, Int32, Int32, Boolean, StandaloneSignatureHandle, MethodBodyAttributes)

Source:
MethodBodyStreamEncoder.cs
Source:
MethodBodyStreamEncoder.cs
Source:
MethodBodyStreamEncoder.cs
Source:
MethodBodyStreamEncoder.cs

Encodes a method body and adds it to the method body stream, using the provided code size, maximum stack size, number of exception regions, local variables' signature handle, method body attributes and allowing to indicate whether the exception regions should be encoded in small format or not.

C#
public System.Reflection.Metadata.Ecma335.MethodBodyStreamEncoder.MethodBody AddMethodBody(int codeSize, int maxStack, int exceptionRegionCount, bool hasSmallExceptionRegions, System.Reflection.Metadata.StandaloneSignatureHandle localVariablesSignature, System.Reflection.Metadata.Ecma335.MethodBodyAttributes attributes);
C#
public System.Reflection.Metadata.Ecma335.MethodBodyStreamEncoder.MethodBody AddMethodBody(int codeSize, int maxStack = 8, int exceptionRegionCount = 0, bool hasSmallExceptionRegions = true, System.Reflection.Metadata.StandaloneSignatureHandle localVariablesSignature = default, System.Reflection.Metadata.Ecma335.MethodBodyAttributes attributes = System.Reflection.Metadata.Ecma335.MethodBodyAttributes.InitLocals);

Parameters

codeSize
Int32

The number of bytes to be reserved for instructions.

maxStack
Int32

The maximum stack size.

exceptionRegionCount
Int32

The number of exception regions.

hasSmallExceptionRegions
Boolean

true if the exception regions should be encoded in small format; false otherwise.

localVariablesSignature
StandaloneSignatureHandle

The local variables' signature handle.

attributes
MethodBodyAttributes

The method body attributes.

Returns

The offset of the encoded body within the method body stream.

Exceptions

codeSize, exceptionRegionCount, or maxStack is out of the allowed range.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

AddMethodBody(Int32, Int32, Int32, Boolean, StandaloneSignatureHandle, MethodBodyAttributes, Boolean)

Source:
MethodBodyStreamEncoder.cs
Source:
MethodBodyStreamEncoder.cs
Source:
MethodBodyStreamEncoder.cs
Source:
MethodBodyStreamEncoder.cs

Encodes a method body and adds it to the method body stream, using the provided code size, maximum stack size, number of exception regions, local variables' signature handle, method body attributes, allowing to indicate whether the exception regions should be encoded in small format or not, and allowing to indicate whether the method should allocate from the dynamic local memory pool or not.

C#
public System.Reflection.Metadata.Ecma335.MethodBodyStreamEncoder.MethodBody AddMethodBody(int codeSize, int maxStack = 8, int exceptionRegionCount = 0, bool hasSmallExceptionRegions = true, System.Reflection.Metadata.StandaloneSignatureHandle localVariablesSignature = default, System.Reflection.Metadata.Ecma335.MethodBodyAttributes attributes = System.Reflection.Metadata.Ecma335.MethodBodyAttributes.InitLocals, bool hasDynamicStackAllocation = false);

Parameters

codeSize
Int32

The number of bytes to be reserved for instructions.

maxStack
Int32

The maximum stack size.

exceptionRegionCount
Int32

The number of exception regions.

hasSmallExceptionRegions
Boolean

true if the exception regions should be encoded in small format; false otherwise.

localVariablesSignature
StandaloneSignatureHandle

The local variables' signature handle.

attributes
MethodBodyAttributes

The method body attributes.

hasDynamicStackAllocation
Boolean

true if the method allocates from the dynamic local memory pool (the localloc instruction); false otherwise.

Returns

The offset of the encoded body within the method body stream.

Exceptions

codeSize, exceptionRegionCount, or maxStack is out of the allowed range.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)