Class TypeSpecification
- Namespace
- AsmResolver.DotNet
- Assembly
- AsmResolver.DotNet.dll
Represents a type that allows for assigning metadata tokens to type signatures stored in the blob stream.
public class TypeSpecification : MetadataMember, ITypeDefOrRef, ITypeDescriptor, IMemberDescriptor, IFullNameProvider, IImportable, IMemberRefParent, INameProvider, IModuleProvider, IHasCustomAttribute, IMetadataMember
- Inheritance
-
TypeSpecification
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
TypeSpecification(TypeSignature?)
Creates a new type specification.
public TypeSpecification(TypeSignature? signature)
Parameters
signature
TypeSignatureThe type signature to assign a metadata token.
TypeSpecification(MetadataToken)
Initializes an empty type specification.
protected TypeSpecification(MetadataToken token)
Parameters
token
MetadataTokenThe token of the type specification.
Properties
CustomAttributes
Gets a collection of custom attributes assigned to this member.
public IList<CustomAttribute> CustomAttributes { get; }
Property Value
DeclaringType
When this type is nested, gets the enclosing type.
public ITypeDefOrRef? DeclaringType { get; }
Property Value
FullName
Gets the full name of the object.
public string FullName { get; }
Property Value
IsValueType
Gets a value indicating whether instances of this type are passed on by value or by reference.
public bool IsValueType { get; }
Property Value
Module
Gets the module that defines the member definition or reference.
public ModuleDefinition? Module { get; }
Property Value
Remarks
For member references, this does not obtain the module definition that the member is defined in. Rather, it obtains the module definition that references this reference.
Name
Gets or sets the name of the referenced type.
public Utf8String Name { get; }
Property Value
Namespace
Gets or sets the namespace the type is residing in.
public Utf8String? Namespace { get; }
Property Value
Scope
Gets the resolution scope that defines the type.
public IResolutionScope? Scope { get; }
Property Value
Signature
Gets or sets the type signature that this type specification is referencing.
public TypeSignature? Signature { get; set; }
Property Value
Methods
GetCustomAttributes()
Obtains the list of custom attributes assigned to the member.
protected virtual IList<CustomAttribute> GetCustomAttributes()
Returns
- IList<CustomAttribute>
The attributes
Remarks
This method is called upon initialization of the CustomAttributes property.
GetSignature()
Obtains the signature the type specification is referencing.
protected virtual TypeSignature? GetSignature()
Returns
- TypeSignature
The signature.
Remarks
This method is called upon initialization of the Signature property.
ImportWith(ReferenceImporter)
Imports the type specification using the provided reference importer object.
public ITypeDefOrRef ImportWith(ReferenceImporter importer)
Parameters
importer
ReferenceImporterThe reference importer to use.
Returns
- ITypeDefOrRef
The imported type.
IsImportedInModule(ModuleDefinition)
Determines whether the descriptor of the member is fully imported in the provided module.
public bool IsImportedInModule(ModuleDefinition module)
Parameters
module
ModuleDefinitionThe 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.
Resolve()
Resolves the reference to a type definition.
public TypeDefinition? Resolve()
Returns
- TypeDefinition
The resolved type definition, or
null
if the type could not be resolved.
Remarks
This method can only be invoked if the reference was added to a module.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
ToTypeSignature()
Transforms the type descriptor to an instance of a TypeSignature, which can be used in blob signatures.
public TypeSignature ToTypeSignature()
Returns
- TypeSignature
The constructed type signature instance.
ToTypeSignature(bool)
Transforms the type descriptor to an instance of a TypeSignature, which can be used in blob signatures.
public TypeSignature ToTypeSignature(bool isValueType)
Parameters
isValueType
booltrue
if the type is a value type,false
otherwise.
Returns
- TypeSignature
The constructed type signature instance.
Remarks
This function can be used to avoid type resolution on type references.