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
attributesCallingConventionAttributesThe attributes.
returnTypeTypeSignatureThe return type of the method.
parameterTypesIEnumerable<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
HasSentinelParameterTypes
Gets a value indicating whether there are any sentinel parameters present in this signature.
public bool HasSentinelParameterTypes { get; }
Property Value
IncludeSentinel
Gets or sets a value indicating whether sentinel parameters should be included in the signature.
public bool IncludeSentinel { get; set; }
Property Value
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
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
returnTypeTypeSignatureThe 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
returnTypeTypeSignatureThe return type of the method.
parameterTypesIEnumerable<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
returnTypeTypeSignatureThe return type of the method.
genericParameterCountintThe number of generic parameters this method defines.
parameterTypesTypeSignature[]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
returnTypeTypeSignatureThe return type of the method.
genericParameterCountintThe number of generic parameters this method defines.
parameterTypesIEnumerable<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
returnTypeTypeSignatureThe 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
returnTypeTypeSignatureThe return type of the method.
parameterTypesIEnumerable<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
returnTypeTypeSignatureThe return type of the method.
genericParameterCountintThe number of generic parameters this method defines.
parameterTypesIEnumerable<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
contextBlobReaderContextThe blob reader context.
readerBinaryStreamReaderThe 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
importerReferenceImporterThe 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
importerReferenceImporterThe 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
contextGenericContextThe 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
moduleModuleDefinitionThe module that is supposed to import the member.
Returns
- bool
trueif the descriptor of the member is fully imported by the module,falseotherwise.
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
WriteContents(in BlobSerializationContext)
Serializes the blob (without extra data) to an output stream.
protected override void WriteContents(in BlobSerializationContext context)
Parameters
contextBlobSerializationContext