MemberAdapterRepository.ResolveCanonicalType Method

Namespace
Kampute.DocToolkit.Metadata.Adapters
Assembly
  • Kampute.DocToolkit.dll

Definition

Resolves the canonical form of a type.
public virtual Type ResolveCanonicalType(Type type)

Parameters

type Type
The type to resolve.

Returns

Type
A Type instance that is reference-equal to the canonical type definition if applicable; otherwise, the original type.

Remarks

When a nested generic type definition is collected indirectly (such as Type.BaseType or Type.GetInterfaces()), the returned Type instance may be incorrectly flagged as a constructed generic type despite having only generic parameters as type arguments. This leads to discrepancies in equality comparisons, especially when such types are used as keys in collections that rely on reference equality.

This method ensures that when such types are encountered, they are converted back to their generic type definitions and thus reference-equal to instances obtained directly via typeof expressions.