Open sandboxFocus

Method GetTargetInterface

GetTargetInterface(ICompilation, Type?, IGenericContext?, bool)

Gets the target of the reference for a given compilation, with control over the interface type and error handling. Prefer the extension methods GetTarget<T>(IRef<T>, ICompilation, IGenericContext?) or GetTargetOrNull<T>(IRef<T>, ICompilation, IGenericContext?) for typical usage.

Declaration
ICompilationElement? GetTargetInterface(ICompilation compilation, Type? interfaceType, IGenericContext? genericContext = null, bool throwIfMissing = false)
Parameters
Type Name Description
ICompilation compilation

The compilation in which to resolve the reference.

Type interfaceType

The optional interface type to use for the target, or null to use the default.

IGenericContext genericContext

The optional generic context for resolving generic instances.

bool throwIfMissing

If true, throws an exception when the reference cannot be resolved; if false, returns null.

Returns
Type Description
ICompilationElement

The resolved compilation element, or null if the reference cannot be resolved and throwIfMissing is false.