Class Signature
Encapsulates function's return type, calling convention and parameter types
Inheritance
Inherited Members
Namespace: CilTools.BytecodeAnalysis
Assembly: CilTools.BytecodeAnalysis.dll
Syntax
public class Signature
Constructors
Signature(Byte[], ITokenResolver)
Initializes a new signature object, resolving metadata tokens using the specified resolver
Declaration
public Signature(byte[] data, ITokenResolver resolver)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | data | The byte array containing the signature data |
| ITokenResolver | resolver | The object used to resolve metadata tokens |
Remarks
The signature could be the method signature or the standalone signature (ECMA-335 II.23.2.3: StandAloneMethodSig)
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Source array is null |
| System.ArgumentException | Source array is empty |
| System.IO.EndOfStreamException | Unexpected end of input data |
| CilParserException | Input data is invalid |
| System.NotSupportedException | Signature contains unsupported elements |
Signature(Byte[], ITokenResolver, MemberInfo)
Initializes a new signature object, resolving metadata tokens using the specified resolver in the specified generic context
Declaration
public Signature(byte[] data, ITokenResolver resolver, MemberInfo member)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | data | The byte array containing the signature data |
| ITokenResolver | resolver | The object used to resolve metadata tokens |
| System.Reflection.MemberInfo | member | Method that identifies generic context for generic method params, or null if this signature does not belong to a generic method |
Remarks
The signature could be the method signature or the standalone signature (ECMA-335 II.23.2.3: StandAloneMethodSig)
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Source array is null |
| System.ArgumentException | Source array is empty |
| System.IO.EndOfStreamException | Unexpected end of input data |
| CilParserException | Input data is invalid |
| System.NotSupportedException | Signature contains unsupported elements |
Signature(Byte[], Module)
Initializes a new Signature object representing a stand-alone method signature
Declaration
public Signature(byte[] data, Module module)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | data | The byte array containing StandAloneMethodSig data (ECMA-335 II.23.2.3) |
| System.Reflection.Module | module | Module containing the passed signature |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Source array is null |
| System.ArgumentException | Source array is empty |
| System.IO.EndOfStreamException | Unexpected end of input data |
| CilParserException | Input data is invalid |
| System.NotSupportedException | Signature contains unsupported elements |
Signature(Stream, ITokenResolver, MemberInfo)
Initializes a new signature object from the stream, resolving metadata tokens using the specified resolver in the specified generic context
Declaration
public Signature(Stream src, ITokenResolver resolver, MemberInfo member)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | src | The stream to read signature data from |
| ITokenResolver | resolver | The object used to resolve metadata tokens |
| System.Reflection.MemberInfo | member | Method that identifies generic context for generic method params, or null if this signature does not belong to a generic method |
Remarks
The signature could be the method signature or the standalone signature (ECMA-335 II.23.2.3: StandAloneMethodSig)
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Source stream is null |
| System.IO.EndOfStreamException | Unexpected end of input data |
| CilParserException | Input data is invalid |
| System.NotSupportedException | Signature contains unsupported elements |
Properties
CallingConvention
Returns calling convention of the function described by this signature
Declaration
public CallingConvention CallingConvention { get; }
Property Value
| Type | Description |
|---|---|
| CallingConvention |
ExplicitThis
Gets the value indicating whether the instance pointer is included explicitly in this signature
Declaration
public bool ExplicitThis { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
GenericArgsCount
Gets the generic arguments or parameters count for the generic method, or zero if this signature does not represent the generic method.
Declaration
public int GenericArgsCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
GenericInst
Gets the value indicating whether this signature represents the generic method instantiation
Declaration
public bool GenericInst { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
HasThis
Gets the value indicating whether the function described by this signature uses an instance pointer
Declaration
public bool HasThis { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
ParamsCount
Gets the amount of fixed parameters that the function described by this signature takes
Declaration
public int ParamsCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
ParamTypes
Enumerates types of fixed parameters that the function described by this signature takes
Declaration
public IEnumerable<TypeSpec> ParamTypes { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<TypeSpec> |
ReturnType
Gets the return type of the function described by this signature
Declaration
public TypeSpec ReturnType { get; }
Property Value
| Type | Description |
|---|---|
| TypeSpec |
Methods
GetParamType(Int32)
Gets the type of parameter with the specified index
Declaration
public TypeSpec GetParamType(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | Index of the requested parameter |
Returns
| Type | Description |
|---|---|
| TypeSpec | The type of requested parameter |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Index is negative or outside the bounds of collection |
GetParamTypes()
Gets the array of fixed parameter types that the function described by this signature takes
Declaration
public TypeSpec[] GetParamTypes()
Returns
| Type | Description |
|---|---|
| TypeSpec[] |
ReadFieldSignature(Byte[], ITokenResolver, MemberInfo)
Reads the field signature from the specified byte array
Declaration
public static TypeSpec ReadFieldSignature(byte[] data, ITokenResolver resolver, MemberInfo member)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | data | The byte array containing the field signature data |
| ITokenResolver | resolver | The object used to resolve metadata tokens |
| System.Reflection.MemberInfo | member | Method that identifies generic context for generic method params, or null if this signature does not belong to a generic method |
Returns
| Type | Description |
|---|---|
| TypeSpec | The |
Remarks
The field signature in .NET assembly consists of only the single TypeSpec that represents the field type. The signature data passed to this method should not contain data for signature types other then the field signature (such as the method signature), or an exception will be thrown.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Source array is null |
| System.ArgumentException | Source array is empty |
| System.IO.InvalidDataException | The signature data does not represent the field signature |
ReadFromArray(Byte[], SignatureContext)
Reads a signature from the specified byte array using the specified signature context
Declaration
public static Signature ReadFromArray(byte[] data, SignatureContext ctx)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | data | Byte array to read data from |
| SignatureContext | ctx | The signature context |
Returns
| Type | Description |
|---|---|
| Signature |
Remarks
The signature could be the method signature or the standalone signature (ECMA-335 II.23.2.3: StandAloneMethodSig)
A signature context encapsulates a token resolver and a generic context. Generic context is only used when the signature contains generic parameters.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Source array or signature context is null |
| System.ArgumentException | Source array is empty |
ToString()
Gets the textual representation of this signature as CIL code
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String |