AdapterHelper.IsValidTypeSubstitution Method

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

Definition

Determines whether a target type is a valid substitution for a source type in the context of method overriding or interface implementation.
public static bool IsValidTypeSubstitution(
	IMember baseMember,
	IType sourceType,
	IMember derivedMember,
	IType targetType)

Parameters

baseMember IMember
The base declaration of the member.
sourceType IType
The type used by the base declaration that may be substituted.
derivedMember IMember
The derived or implementing declaration of the member.
targetType IType
The type used by the derived or implementing declaration that may substitute sourceType.

Returns

bool
true if targetType is a valid substitution for sourceType; otherwise, false.

Exceptions

ArgumentNullException
Thrown when any argument is null.

Remarks

When both members have declaring types, generic type parameters are matched against the actual type arguments in the derived member's declaring type, base types, and implemented interfaces. An unresolved parameter must remain the same parameter; satisfying its constraints alone does not establish a matching signature. When declaring type information is unavailable, the comparison uses IsSubstitutableBy(IType, IType).