Class TypeDescriptorExtensions
- Namespace
- AsmResolver.DotNet
- Assembly
- AsmResolver.DotNet.dll
Provides convenience extension methods to instances of ITypeDescriptor.
public static class TypeDescriptorExtensions
- Inheritance
-
TypeDescriptorExtensions
- Inherited Members
Methods
CreateMemberReference(IMemberRefParent, Utf8String?, MemberSignature?)
Constructs a reference to a member declared within the provided parent member.
public static MemberReference CreateMemberReference(this IMemberRefParent parent, Utf8String? memberName, MemberSignature? signature)
Parameters
parentIMemberRefParentThe declaring member.
memberNameUtf8StringThe name of the member to reference.
signatureMemberSignatureThe signature of the member to reference.
Returns
- MemberReference
The constructed reference.
CreateMemberReference(IMemberRefParent, string?, MemberSignature?)
Constructs a reference to a member declared within the provided parent member.
public static MemberReference CreateMemberReference(this IMemberRefParent parent, string? memberName, MemberSignature? signature)
Parameters
parentIMemberRefParentThe declaring member.
memberNamestringThe name of the member to reference.
signatureMemberSignatureThe signature of the member to reference.
Returns
- MemberReference
The constructed reference.
CreateTypeReference(IResolutionScope, Utf8String?, Utf8String)
Constructs a reference to a type within the provided resolution scope.
public static TypeReference CreateTypeReference(this IResolutionScope scope, Utf8String? ns, Utf8String name)
Parameters
scopeIResolutionScopeThe scope the type is defined in.
nsUtf8StringThe namespace of the type.
nameUtf8StringThe name of the type.
Returns
- TypeReference
The constructed reference.
CreateTypeReference(IResolutionScope, string?, string)
Constructs a reference to a type within the provided resolution scope.
public static TypeReference CreateTypeReference(this IResolutionScope scope, string? ns, string name)
Parameters
scopeIResolutionScopeThe scope the type is defined in.
nsstringThe namespace of the type.
namestringThe name of the type.
Returns
- TypeReference
The constructed reference.
CreateTypeReference(ITypeDefOrRef, Utf8String)
Constructs a reference to a nested type.
public static TypeReference CreateTypeReference(this ITypeDefOrRef declaringType, Utf8String nestedTypeName)
Parameters
declaringTypeITypeDefOrRefThe enclosing type.
nestedTypeNameUtf8StringThe name of the nested type.
Returns
- TypeReference
The constructed reference.
Exceptions
- ArgumentOutOfRangeException
Occurs when
declaringTypecannot be used as a declaring type of a type reference.
CreateTypeReference(ITypeDefOrRef, string)
Constructs a reference to a nested type.
public static TypeReference CreateTypeReference(this ITypeDefOrRef declaringType, string nestedTypeName)
Parameters
declaringTypeITypeDefOrRefThe enclosing type.
nestedTypeNamestringThe name of the nested type.
Returns
- TypeReference
The constructed reference.
Exceptions
- ArgumentOutOfRangeException
Occurs when
declaringTypecannot be used as a declaring type of a type reference.
IsTypeOf(ITypeDescriptor, string?, string?)
Determines whether a type matches a namespace and name pair.
public static bool IsTypeOf(this ITypeDescriptor type, string? ns, string? name)
Parameters
typeITypeDescriptorThe type.
nsstringThe namespace.
namestringThe name.
Returns
- bool
trueif the name and the namespace of the type matches the provided values,falseotherwise.
IsTypeOfUtf8(ExportedType, Utf8String?, Utf8String?)
Determines whether a type matches a namespace and name pair.
public static bool IsTypeOfUtf8(this ExportedType type, Utf8String? ns, Utf8String? name)
Parameters
typeExportedTypeThe type.
nsUtf8StringThe namespace.
nameUtf8StringThe name.
Returns
- bool
trueif the name and the namespace of the type matches the provided values,falseotherwise.
IsTypeOfUtf8(ITypeDefOrRef, Utf8String?, Utf8String?)
Determines whether a type matches a namespace and name pair.
public static bool IsTypeOfUtf8(this ITypeDefOrRef type, Utf8String? ns, Utf8String? name)
Parameters
typeITypeDefOrRefThe type.
nsUtf8StringThe namespace.
nameUtf8StringThe name.
Returns
- bool
trueif the name and the namespace of the type matches the provided values,falseotherwise.
MakeArrayType(ITypeDescriptor, params ArrayDimension[])
Constructs a new single-dimension, zero based array signature with the provided type descriptor as element type.
public static ArrayTypeSignature MakeArrayType(this ITypeDescriptor type, params ArrayDimension[] dimensions)
Parameters
typeITypeDescriptorThe element type.
dimensionsArrayDimension[]The dimensions of the array.
Returns
- ArrayTypeSignature
The constructed array type signature.
MakeArrayType(ITypeDescriptor, int)
Constructs a new single-dimension, zero based array signature with the provided type descriptor as element type.
public static ArrayTypeSignature MakeArrayType(this ITypeDescriptor type, int dimensionCount)
Parameters
typeITypeDescriptorThe element type.
dimensionCountintThe number of dimensions in the array.
Returns
- ArrayTypeSignature
The constructed array type signature.
MakeBoxedType(ITypeDescriptor)
Constructs a new boxed type signature with the provided type descriptor as element type. as element type.
public static BoxedTypeSignature MakeBoxedType(this ITypeDescriptor type)
Parameters
typeITypeDescriptorThe element type.
Returns
- BoxedTypeSignature
The constructed boxed type signature.
MakeByReferenceType(ITypeDescriptor)
Constructs a new by-reference type signature with the provided type descriptor as element type. as element type.
public static ByReferenceTypeSignature MakeByReferenceType(this ITypeDescriptor type)
Parameters
typeITypeDescriptorThe element type.
Returns
- ByReferenceTypeSignature
The constructed by-reference type signature.
MakeGenericInstanceType(ITypeDescriptor, params TypeSignature[])
Constructs a new pointer type signature with the provided type descriptor as element type. as element type.
public static GenericInstanceTypeSignature MakeGenericInstanceType(this ITypeDescriptor type, params TypeSignature[] typeArguments)
Parameters
typeITypeDescriptorThe element type.
typeArgumentsTypeSignature[]The arguments to instantiate the type with.
Returns
- GenericInstanceTypeSignature
The constructed by-reference type signature.
MakeGenericInstanceType(ITypeDescriptor, bool, params TypeSignature[])
Constructs a new pointer type signature with the provided type descriptor as element type. as element type.
public static GenericInstanceTypeSignature MakeGenericInstanceType(this ITypeDescriptor type, bool isValueType, params TypeSignature[] typeArguments)
Parameters
typeITypeDescriptorThe element type.
isValueTypebooltrueif the type is a value type,falseotherwise.typeArgumentsTypeSignature[]The arguments to instantiate the type with.
Returns
- GenericInstanceTypeSignature
The constructed by-reference type signature.
Remarks
This function can be used to avoid type resolution on type references.
MakeModifierType(ITypeDescriptor, ITypeDefOrRef, bool)
Constructs a new pointer type signature with the provided type descriptor as element type. as element type.
public static CustomModifierTypeSignature MakeModifierType(this ITypeDescriptor type, ITypeDefOrRef modifierType, bool isRequired)
Parameters
typeITypeDescriptorThe element type.
modifierTypeITypeDefOrRefThe modifier type to add.
isRequiredboolIndicates whether the modifier is required or optional.
Returns
- CustomModifierTypeSignature
The constructed by-reference type signature.
MakePinnedType(ITypeDescriptor)
Constructs a new pinned type signature with the provided type descriptor as element type. as element type.
public static PinnedTypeSignature MakePinnedType(this ITypeDescriptor type)
Parameters
typeITypeDescriptorThe element type.
Returns
- PinnedTypeSignature
The constructed by-reference type signature.
MakePointerType(ITypeDescriptor)
Constructs a new pointer type signature with the provided type descriptor as element type. as element type.
public static PointerTypeSignature MakePointerType(this ITypeDescriptor type)
Parameters
typeITypeDescriptorThe element type.
Returns
- PointerTypeSignature
The constructed by-reference type signature.
MakeSzArrayType(ITypeDescriptor)
Constructs a new single-dimension, zero based array signature with the provided type descriptor as element type.
public static SzArrayTypeSignature MakeSzArrayType(this ITypeDescriptor type)
Parameters
typeITypeDescriptorThe element type.
Returns
- SzArrayTypeSignature
The constructed array type signature.