Rediger

Del via


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 sealed
public ref class DynamicILInfo
public sealed class DynamicILInfo
[System.Runtime.InteropServices.ComVisible(true)]
public class DynamicILInfo
public class DynamicILInfo
type DynamicILInfo = class
[<System.Runtime.InteropServices.ComVisible(true)>]
type DynamicILInfo = class
Public NotInheritable Class DynamicILInfo
Public Class DynamicILInfo
Inheritance
DynamicILInfo
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". For more information, see ECMA 335 Common Language Infrastructure (CLI).

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

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

Methods

Equals(Object)

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

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetTokenFor(Byte[])

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

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, 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(RuntimeFieldHandle)

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

GetTokenFor(RuntimeMethodHandle, RuntimeTypeHandle)

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

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(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)

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

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SetCode(Byte[], Int32)

Sets the code body of the associated dynamic method.

SetCode(Byte*, Int32, Int32)

Sets the code body of the associated dynamic method.

SetExceptions(Byte[])

Sets the exception metadata for the associated dynamic method.

SetExceptions(Byte*, Int32)

Sets the exception metadata for the associated dynamic method.

SetLocalSignature(Byte[])

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

SetLocalSignature(Byte*, Int32)

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

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to