DynamicILInfo DynamicILInfo DynamicILInfo DynamicILInfo Class

Definition

Provides support for alternative ways to generate the Microsoft intermediate language (MSIL) and metadata for a dynamic method, including methods for creating tokens and for inserting the code, exception handling, and local variable signature blobs.

public ref class DynamicILInfo
[System.Runtime.InteropServices.ComVisible(true)]
public class DynamicILInfo
type DynamicILInfo = class
Public Class DynamicILInfo
Inheritance
DynamicILInfoDynamicILInfoDynamicILInfoDynamicILInfo
Attributes

Remarks

The DynamicILInfo class allows developers to write their own MSIL generators instead of using ILGenerator.

To create instances of other types, call methods, and so on, the MSIL you generate must include tokens for those entities. The DynamicILInfo class provides several overloads of the GetTokenFor method, which return tokens valid in the scope of the current DynamicILInfo. For example, if you need to call an overload of the Console.WriteLine method, you can obtain a RuntimeMethodHandle for that overload and pass it to the GetTokenFor method to obtain a token to embed in your MSIL.

Once you have created Byte arrays for your local variable signature, exceptions, and code body, you can use the SetCode, SetExceptions, and SetLocalSignature methods to insert them into the DynamicMethod associated with your DynamicILInfo object.

Generating your own metadata and MSIL requires familiarity with the Common Language Infrastructure (CLI) documentation, especially "Partition II: Metadata Definition and Semantics" and "Partition III: CIL Instruction Set". The documentation is available online; see ECMA C# and Common Language Infrastructure Standards on MSDN and Standard ECMA-335 - Common Language Infrastructure (CLI) on the Ecma International Web site.

Note

Do not use DynamicILInfo to generate code that creates a delegate to another dynamic method by calling the delegate constructor directly. Instead, use the CreateDelegate method to create the delegate. A delegate that is created with the delegate constructor does not have a reference to the target dynamic method. The dynamic method might be reclaimed by garbage collection while the delegate is still in use.

Properties

DynamicMethod DynamicMethod DynamicMethod DynamicMethod

Gets the dynamic method whose body is generated by the current instance.

Methods

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetTokenFor(Byte[]) GetTokenFor(Byte[]) GetTokenFor(Byte[]) GetTokenFor(Byte[])

Gets a token, valid in the scope of the current DynamicILInfo, representing the signature for the associated dynamic method.

GetTokenFor(DynamicMethod) GetTokenFor(DynamicMethod) GetTokenFor(DynamicMethod) GetTokenFor(DynamicMethod)

Gets a token, valid in the scope of the current DynamicILInfo, representing a dynamic method to be called from the associated method.

GetTokenFor(RuntimeFieldHandle) GetTokenFor(RuntimeFieldHandle) GetTokenFor(RuntimeFieldHandle) GetTokenFor(RuntimeFieldHandle)

Gets a token, valid in the scope of the current DynamicILInfo, representing a field to be accessed from the associated dynamic method.

GetTokenFor(RuntimeFieldHandle, RuntimeTypeHandle) GetTokenFor(RuntimeFieldHandle, RuntimeTypeHandle) GetTokenFor(RuntimeFieldHandle, RuntimeTypeHandle) GetTokenFor(RuntimeFieldHandle, RuntimeTypeHandle)

Gets a token, valid in the scope of the current DynamicILInfo, representing a field to be accessed from the associated dynamic method; the field is on the specified generic type.

GetTokenFor(RuntimeMethodHandle) GetTokenFor(RuntimeMethodHandle) GetTokenFor(RuntimeMethodHandle) GetTokenFor(RuntimeMethodHandle)

Gets a token, valid in the scope of the current DynamicILInfo, representing a method to be accessed from the associated dynamic method.

GetTokenFor(RuntimeMethodHandle, RuntimeTypeHandle) GetTokenFor(RuntimeMethodHandle, RuntimeTypeHandle) GetTokenFor(RuntimeMethodHandle, RuntimeTypeHandle) GetTokenFor(RuntimeMethodHandle, RuntimeTypeHandle)

Gets a token, valid in the scope of the current DynamicILInfo, representing a method on a generic type.

GetTokenFor(RuntimeTypeHandle) GetTokenFor(RuntimeTypeHandle) GetTokenFor(RuntimeTypeHandle) GetTokenFor(RuntimeTypeHandle)

Gets a token, valid in the scope of the current DynamicILInfo, representing a type to be used in the associated dynamic method.

GetTokenFor(String) GetTokenFor(String) GetTokenFor(String) GetTokenFor(String)

Gets a token, valid in the scope of the current DynamicILInfo, representing a string literal to be used in the associated dynamic method.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SetCode(Byte*, Int32, Int32) SetCode(Byte*, Int32, Int32) SetCode(Byte*, Int32, Int32) SetCode(Byte*, Int32, Int32)

Sets the code body of the associated dynamic method.

SetCode(Byte[], Int32) SetCode(Byte[], Int32) SetCode(Byte[], Int32) SetCode(Byte[], Int32)

Sets the code body of the associated dynamic method.

SetExceptions(Byte*, Int32) SetExceptions(Byte*, Int32) SetExceptions(Byte*, Int32) SetExceptions(Byte*, Int32)

Sets the exception metadata for the associated dynamic method.

SetExceptions(Byte[]) SetExceptions(Byte[]) SetExceptions(Byte[]) SetExceptions(Byte[])

Sets the exception metadata for the associated dynamic method.

SetLocalSignature(Byte*, Int32) SetLocalSignature(Byte*, Int32) SetLocalSignature(Byte*, Int32) SetLocalSignature(Byte*, Int32)

Sets the local variable signature that describes the layout of local variables for the associated dynamic method.

SetLocalSignature(Byte[]) SetLocalSignature(Byte[]) SetLocalSignature(Byte[]) SetLocalSignature(Byte[])

Sets the local variable signature that describes the layout of local variables for the associated dynamic method.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to