Table of Contents

Class MethodSignature

Namespace
AsmResolver.DotNet.Signatures
Assembly
AsmResolver.DotNet.dll

Represents the signature of a method defined or referenced by a .NET executable file.

public class MethodSignature : MethodSignatureBase, IImportable
Inheritance
MethodSignature
Implements
Inherited Members

Constructors

MethodSignature(CallingConventionAttributes, TypeSignature, IEnumerable<TypeSignature>?)

Creates a new method signature with the provided return and parameter types.

public MethodSignature(CallingConventionAttributes attributes, TypeSignature returnType, IEnumerable<TypeSignature>? parameterTypes)

Parameters

attributes CallingConventionAttributes

The attributes.

returnType TypeSignature

The return type of the method.

parameterTypes IEnumerable<TypeSignature>

The types of the parameter the method defines.

Properties

GenericParameterCount

Gets or sets the number of generic parameters this method defines.

public int GenericParameterCount { get; set; }

Property Value

int

HasSentinelParameterTypes

Gets a value indicating whether there are any sentinel parameters present in this signature.

public bool HasSentinelParameterTypes { get; }

Property Value

bool

IncludeSentinel

Gets or sets a value indicating whether sentinel parameters should be included in the signature.

public bool IncludeSentinel { get; set; }

Property Value

bool

SentinelParameterTypes

Gets an ordered list of types indicating the types of the sentinel parameters that this member defines.

public IList<TypeSignature> SentinelParameterTypes { get; }

Property Value

IList<TypeSignature>

Remarks

For any of the sentinel parameter types to be emitted to the output module, the IncludeSentinel must be set to true.

Methods

CreateInstance(TypeSignature)

Creates a new parameter-less method signature for an instance method.

public static MethodSignature CreateInstance(TypeSignature returnType)

Parameters

returnType TypeSignature

The return type of the method.

Returns

MethodSignature

The signature.

CreateInstance(TypeSignature, IEnumerable<TypeSignature>)

Creates a method signature for an instance method that has a number of parameters.

public static MethodSignature CreateInstance(TypeSignature returnType, IEnumerable<TypeSignature> parameterTypes)

Parameters

returnType TypeSignature

The return type of the method.

parameterTypes IEnumerable<TypeSignature>

The parameter types.

Returns

MethodSignature

The signature.

CreateInstance(TypeSignature, int, TypeSignature[])

Creates a generic method signature for an instance method that has a number of parameters.

public static MethodSignature CreateInstance(TypeSignature returnType, int genericParameterCount, TypeSignature[] parameterTypes)

Parameters

returnType TypeSignature

The return type of the method.

genericParameterCount int

The number of generic parameters this method defines.

parameterTypes TypeSignature[]

The parameter types.

Returns

MethodSignature

The signature.

CreateInstance(TypeSignature, int, IEnumerable<TypeSignature>)

Creates a generic method signature for an instance method that has a number of parameters.

public static MethodSignature CreateInstance(TypeSignature returnType, int genericParameterCount, IEnumerable<TypeSignature> parameterTypes)

Parameters

returnType TypeSignature

The return type of the method.

genericParameterCount int

The number of generic parameters this method defines.

parameterTypes IEnumerable<TypeSignature>

The parameter types.

Returns

MethodSignature

The signature.

CreateStatic(TypeSignature)

Creates a new parameter-less method signature for a static method.

public static MethodSignature CreateStatic(TypeSignature returnType)

Parameters

returnType TypeSignature

The return type of the method.

Returns

MethodSignature

The signature.

CreateStatic(TypeSignature, IEnumerable<TypeSignature>)

Creates a method signature for a static method that has a number of parameters.

public static MethodSignature CreateStatic(TypeSignature returnType, IEnumerable<TypeSignature> parameterTypes)

Parameters

returnType TypeSignature

The return type of the method.

parameterTypes IEnumerable<TypeSignature>

The parameter types.

Returns

MethodSignature

The signature.

CreateStatic(TypeSignature, int, IEnumerable<TypeSignature>)

Creates a generic method signature for a static method that has a number of parameters.

public static MethodSignature CreateStatic(TypeSignature returnType, int genericParameterCount, IEnumerable<TypeSignature> parameterTypes)

Parameters

returnType TypeSignature

The return type of the method.

genericParameterCount int

The number of generic parameters this method defines.

parameterTypes IEnumerable<TypeSignature>

The parameter types.

Returns

MethodSignature

The signature.

FromReader(ref BlobReaderContext, ref BinaryStreamReader)

Reads a single method signature from an input stream.

public static MethodSignature FromReader(ref BlobReaderContext context, ref BinaryStreamReader reader)

Parameters

context BlobReaderContext

The blob reader context.

reader BinaryStreamReader

The blob input stream.

Returns

MethodSignature

The method signature.

GetTotalParameterCount()

Determines the total number of parameters that this method requires to be invoked.

public override int GetTotalParameterCount()

Returns

int

The number of parameters

Remarks

This number includes the this parameter, as well as any potential sentinel parameters.

ImportWith(ReferenceImporter)

Imports the method signature using the provided reference importer object.

public MethodSignature ImportWith(ReferenceImporter importer)

Parameters

importer ReferenceImporter

The reference importer to us.

Returns

MethodSignature

The imported signature.

ImportWithInternal(ReferenceImporter)

Imports the signature using the provided reference importer object.

protected override CallingConventionSignature ImportWithInternal(ReferenceImporter importer)

Parameters

importer ReferenceImporter

The reference importer to us.

Returns

CallingConventionSignature

The imported signature.

InstantiateGenericTypes(GenericContext)

Substitutes any generic type parameter in the method signature with the parameters provided by the generic context.

public MethodSignature InstantiateGenericTypes(GenericContext context)

Parameters

context GenericContext

The generic context.

Returns

MethodSignature

The instantiated method signature.

Remarks

When the type signature does not contain any generic parameter, this method might return the current instance of the method signature.

IsImportedInModule(ModuleDefinition)

Determines whether the descriptor of the member is fully imported in the provided module.

public override bool IsImportedInModule(ModuleDefinition module)

Parameters

module ModuleDefinition

The module that is supposed to import the member.

Returns

bool

true if the descriptor of the member is fully imported by the module, false otherwise.

Remarks

This method verifies all references in the descriptor of the member only. It does not verify any additional data or contents (such as a method body) associated to the member.

MakeFunctionPointerType()

Constructs a new function pointer type signature based on this method signature.

public FunctionPointerTypeSignature MakeFunctionPointerType()

Returns

FunctionPointerTypeSignature

The new type signature.

ToString()

public override string ToString()

Returns

string

WriteContents(in BlobSerializationContext)

Serializes the blob (without extra data) to an output stream.

protected override void WriteContents(in BlobSerializationContext context)

Parameters

context BlobSerializationContext