Open sandboxFocus

Interface IAspectBuilder

An object used by the BuildAspect(IAspectBuilder<T>) method of the aspect to provide advice, child aspects and validators, or report diagnostics. This is the weakly-typed variant of the IAspectBuilder<TAspectTarget> interface.

Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public interface IAspectBuilder

Properties

Name Description
Advice

Gets an object that allows to create advice, e.g. overriding members, introducing members, or implementing new interfaces.

AspectInstance

Gets the current IAspectInstance, which gives access to the Predecessors and the SecondaryInstances of the current aspect.

AspectState

Gets or sets an arbitrary object that is then exposed on the AspectState property of the IAspectInstance interface. While a single instance of an aspect class can be used for several target declarations, the AspectState is specific to the target declaration. If the aspect is inherited, the AspectState must be compile-time-serializable (ICompileTimeSerializable or default serializable classes).

CancellationToken

Gets the cancellation token for the current operation.

Diagnostics

Gets a service that allows to report or suppress diagnostics.

IsAspectSkipped

Gets a value indicating whether the SkipAspect() method was called.

Layer

Gets the name of the layer being built, or null if this is the default (initial) layer. When an aspect has several layers, the BuildAspect(IAspectBuilder<T>) method is called several times. To register aspect layers, add the LayersAttribute custom attribute to the aspect class.

Project

Gets the current IProject, which represents the csproj file and allows to share project-local data.

Tags

Gets or sets the tags passed to all advice added by the current BuildAspect(IAspectBuilder<T>) method. These tags can be consumed from the meta.Tags property.

Target

Gets the declaration to which the aspect was added.

Methods

Name Description
SkipAspect()

Skips the application of the aspect to the code. Any provided advice and child aspects are ignored, but provided diagnostics are preserved. In multi-layer aspects, the next layers of the aspect are skipped.

WithTarget<T>(T)
With<T>(T)

Returns a copy of the current IAspectBuilder, for use in the current execution context, but for a different Target declaration.