Table of Contents

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 IGenericArgumentsProvider

The type providing type arguments.

method IGenericArgumentsProvider

The method providing type arguments.

Properties

IsEmpty

Returns true if both Type and Method providers are null

public bool IsEmpty { get; }

Property Value

bool

Method

Gets the object responsible for providing type arguments defined by the current generic method instantiation.

public IGenericArgumentsProvider? Method { get; }

Property Value

IGenericArgumentsProvider

Type

Gets the object responsible for providing type arguments defined by the current generic type instantiation.

public IGenericArgumentsProvider? Type { get; }

Property Value

IGenericArgumentsProvider

Methods

Equals(GenericContext)

Determines whether two generic contexts have the same generic argument providers.

public bool Equals(GenericContext other)

Parameters

other GenericContext

The 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 object

The 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 IFieldDescriptor

Field 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 IMemberDescriptor

Member 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 MemberReference

Member 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 IMethodDescriptor

Method 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 MethodSpecification

Method 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 ITypeDescriptor

Type 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 GenericInstanceTypeSignature

Generic 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 TypeSpecification

Type 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 GenericParameterSignature

The 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 IGenericArgumentsProvider

The 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 IGenericArgumentsProvider

The new type providing the type arguments.

Returns

GenericContext

The new generic context.