Open sandboxFocus

Interface IInterceptionContext

The base interface of the contexts of a call site. It describes one site. IMethodInterceptionSite and Context implement or expose it.

Namespace: Metalama.Extensions.Interceptors
Assembly: Metalama.Extensions.Interceptors.dll
Syntax
[CompileTime]
[InternalImplement]
public interface IInterceptionContext
Remarks

Declarations exposed by this interface belong to the source compilation, before any aspect transformation. The aspect repository of the compilation is the final one, so Enhancements().HasAspect reports the aspects of the whole pipeline. Declarations introduced by aspects are not visible.

All information in this interface is specific to one site. It is not available to templates, because a generated interceptor method can be shared by several sites. To pass site information to a template, pass it as a template argument.

This object must not be stored after the delegate that received it returns.

Source expressions exposed by the derived interfaces, such as the receiver and the arguments, are available for inspection only. They cannot be emitted in generated code, because the site already evaluates them.

The sub-objects of the context, such as Caller, have the lifetime of the context.

Properties

Name Description
AspectState

Gets the state of the aspect instance that registered the interceptor, as it is when BuildAspect(IAspectBuilder<T>) exits, or null when a fabric registered the interceptor.

Caller

Gets the code that contains the site: the member, the kind of code and the function.

CanPlaceInCallingType

Gets a value indicating whether a method synthesized with PlaceInCallingType() can intercept the site.

CancellationToken

Gets a cancellation token that the provider should pass to long operations.

Diagnostics

Gets a sink that reports diagnostics, by default, on the name of the invoked or referenced method, and suppresses diagnostics in the Member of Caller. Diagnostics are attributed to the aspect or fabric that registered the interceptor.

NonInterceptableReason

Gets the reason why the site cannot be intercepted, or None when it can be intercepted. When this property is not None, any result other than Skip() produces a warning and the site is left unchanged.

ScopeDeclaration

Gets the declaration selected at registration whose scope contains the site.

ScopeTag

Gets the tag of ScopeDeclaration when the registration was made through a tagged query, or null otherwise.

Source

Gets the source of the site: the invocation expression or the method group.

Methods

Name Description
CanPlaceInType(INamedType)

Determines whether a method synthesized with PlaceInType(INamedType) in a given type can intercept the site.

Extension Methods