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, IMemberRefParent, INameProvider, IModuleProvider, IImportable, IHasCustomAttribute, IMetadataMember
- Inheritance
-
TypeSpecification
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
TypeSpecification(TypeSignature?)
Creates a new type specification.
public TypeSpecification(TypeSignature? signature)
Parameters
signatureTypeSignatureThe type signature to assign a metadata token.
TypeSpecification(MetadataToken)
Initializes an empty type specification.
protected TypeSpecification(MetadataToken token)
Parameters
tokenMetadataTokenThe token of the type specification.
Fields
CustomAttributesInternal
The internal custom attribute list.
protected IList<CustomAttribute>? CustomAttributesInternal
Field Value
Remarks
This value may not be initialized. Use CustomAttributes instead.
Properties
ContextModule
Gets the module that defines the member definition or reference.
public ModuleDefinition? ContextModule { 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.
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
HasCustomAttributes
Gets a value indicating whether the member is assigned custom attributes.
public virtual bool HasCustomAttributes { get; }
Property Value
IsValueType
public bool IsValueType { get; }
Property Value
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
importerReferenceImporterThe 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
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.
Resolve(RuntimeContext?, out TypeDefinition?)
Attempts to resolve the type reference to its definition, assuming the provided module as resolution context.
public ResolutionStatus Resolve(RuntimeContext? context, out TypeDefinition? definition)
Parameters
contextRuntimeContextThe context to assume when resolving the type.
definitionTypeDefinitionThe resolved type definition, or
nullif the type could not be resolved.
Returns
- ResolutionStatus
A value describing the success or failure status of the type resolution.
ToString()
public override string ToString()
Returns
ToTypeSignature()
Gets the underlying type signature.
public TypeSignature ToTypeSignature()
Returns
- TypeSignature
The type signature.
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
isValueTypebooltrueif the type is a value type,falseotherwise.
Returns
- TypeSignature
The constructed type signature instance.
Remarks
This function can be used to avoid type resolution on type references.
TryGetIsValueType(RuntimeContext?)
Determines whether the type is considered a value type or reference type by the runtime.
public bool? TryGetIsValueType(RuntimeContext? context)
Parameters
contextRuntimeContextThe runtime context that is assumed.
Returns
- bool?
truewhen the type is considered a value type,falsewhen it is a reference type,nullwhen unknown.