Struct GenericContext
- Namespace
- AsmResolver.DotNet.Signatures
- Assembly
- AsmResolver.DotNet.dll
Provides a context within a generic instantiation, including the type arguments of the enclosing type and method.
public readonly struct GenericContext : IEquatable<GenericContext>
- Implements
- Inherited Members
Constructors
GenericContext(IGenericArgumentsProvider?, IGenericArgumentsProvider?)
Creates a new instance of the GenericContext class.
public GenericContext(IGenericArgumentsProvider? type, IGenericArgumentsProvider? method)
Parameters
type
IGenericArgumentsProviderThe type providing type arguments.
method
IGenericArgumentsProviderThe method providing type arguments.
Properties
IsEmpty
Returns true if both Type and Method providers are null
public bool IsEmpty { get; }
Property Value
Method
Gets the object responsible for providing type arguments defined by the current generic method instantiation.
public IGenericArgumentsProvider? Method { get; }
Property Value
Type
Gets the object responsible for providing type arguments defined by the current generic type instantiation.
public IGenericArgumentsProvider? Type { get; }
Property Value
Methods
Equals(GenericContext)
Determines whether two generic contexts have the same generic argument providers.
public bool Equals(GenericContext other)
Parameters
other
GenericContextThe other context.
Returns
- bool
true
if the contexts are considered equal,false
otherwise.
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
FromField(IFieldDescriptor)
Gets a type generic context from IFieldDescriptor.
public static GenericContext FromField(IFieldDescriptor field)
Parameters
field
IFieldDescriptorField to get the generic context from.
Returns
- GenericContext
Generic context.
FromMember(IMemberDescriptor)
Gets a type generic context from IMemberDescriptor.
public static GenericContext FromMember(IMemberDescriptor member)
Parameters
member
IMemberDescriptorMember to get the generic context from.
Returns
- GenericContext
Generic context.
FromMember(MemberReference)
Gets a type generic context from MemberReference.
public static GenericContext FromMember(MemberReference member)
Parameters
member
MemberReferenceMember reference to get the generic context from.
Returns
- GenericContext
Generic context.
FromMethod(IMethodDescriptor)
Gets a method and/or type generic context from IMethodDescriptor.
public static GenericContext FromMethod(IMethodDescriptor method)
Parameters
method
IMethodDescriptorMethod to get the generic context from.
Returns
- GenericContext
Generic context.
FromMethod(MethodSpecification)
Gets a method and/or type generic context from MethodSpecification.
public static GenericContext FromMethod(MethodSpecification method)
Parameters
method
MethodSpecificationMethod specification to get the generic context from.
Returns
- GenericContext
Generic context.
FromType(ITypeDescriptor)
Gets a type generic context from ITypeDescriptor.
public static GenericContext FromType(ITypeDescriptor type)
Parameters
type
ITypeDescriptorType to get the generic context from.
Returns
- GenericContext
Generic context.
FromType(GenericInstanceTypeSignature)
Gets a type generic context from GenericInstanceTypeSignature.
public static GenericContext FromType(GenericInstanceTypeSignature type)
Parameters
type
GenericInstanceTypeSignatureGeneric type signature to get the generic context from.
Returns
- GenericContext
Generic context.
FromType(TypeSpecification)
Gets a type generic context from TypeSpecification.
public static GenericContext FromType(TypeSpecification type)
Parameters
type
TypeSpecificationType specification to get the generic context from.
Returns
- GenericContext
Generic context.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
GetTypeArgument(GenericParameterSignature)
Resolves a type parameter to a type argument, based on the current generic context.
public TypeSignature GetTypeArgument(GenericParameterSignature parameter)
Parameters
parameter
GenericParameterSignatureThe parameter to get the argument value for.
Returns
- TypeSignature
The argument type.
Remarks
If a type parameter within the signature references a parameter that is not captured by the context (i.e. the corresponding generic argument provider is set to null), then this type parameter will not be substituted.
WithMethod(IGenericArgumentsProvider)
Enters a new generic context with a new method providing type arguments.
public GenericContext WithMethod(IGenericArgumentsProvider method)
Parameters
method
IGenericArgumentsProviderThe new method providing the type arguments.
Returns
- GenericContext
The new generic context.
WithType(IGenericArgumentsProvider)
Enters a new generic context with a new type providing type arguments.
public GenericContext WithType(IGenericArgumentsProvider type)
Parameters
type
IGenericArgumentsProviderThe new type providing the type arguments.
Returns
- GenericContext
The new generic context.