Open sandboxFocus

Class InterceptionAdviserExtensions

Provides extension methods that register interceptors from an aspect or a type fabric. The scope is the target of the adviser: a compilation, a namespace, a type or a member.

Inheritance
InterceptionAdviserExtensions
Namespace: Metalama.Extensions.Interceptors
Assembly: Metalama.Extensions.Interceptors.dll
Syntax
[CompileTime]
public static class InterceptionAdviserExtensions
Remarks

These methods can be called only during BuildAspect(IAspectBuilder<T>) or during the amend method of a fabric. They return nothing, because interception happens after all aspects have run. When the aspect ends with an error or is skipped, its interceptors are discarded.

The scope must be contained in the closest type of the aspect target. When the aspect target is a namespace, the scope must be contained in that namespace. When the aspect target is the compilation, any scope of the current project is accepted.

Only call sites written in the source code are intercepted. A call that the compiler, the runtime or a library makes on behalf of the code is not intercepted, because no call exists at the site. For instance, ToString cannot be intercepted reliably: an interpolated string, a string concatenation, Console.WriteLine( object ) and StringBuilder.Append( object ) call it inside the runtime.

Methods

Name Description
InterceptMethods(ITypeAmender, Func<IMethodInterceptionBuilder, IMethodInterception>)

Registers the interception of the uses of methods, described by a delegate. The scope declaration is the type of the fabric.

InterceptMethods<TScope>(IAdviser<TScope>, Func<IMethodInterceptionBuilder, IMethodInterception>)

Registers the interception of the uses of methods, described by a delegate.