Open sandboxFocus

Class CompilationAspect

A base class for aspects that target the compilation level, applied using assembly-level custom attributes (e.g., [assembly: MyAspect]).

Inheritance
CompilationAspect
Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[AttributeUsage(AttributeTargets.Assembly)]
public abstract class CompilationAspect : Aspect, IAspect<ICompilation>, IAspect, ICompileTimeSerializable, ITemplateProvider, IEligible<ICompilation>
Remarks

This class provides a convenient base for creating compilation-level aspects by implementing IAspect<T> with T set to ICompilation. Derived classes override BuildAspect(IAspectBuilder<ICompilation>) to perform project-wide transformations, such as applying aspects to types meeting certain criteria, introducing project-level configuration, or validating project-wide conventions.

Note: In most scenarios, providing an IAmender<T> extension method that can be called from a fabric is preferred over using compilation aspects. Extension methods provide a programmatic API for project-wide transformations and offer better discoverability and composability, whereas compilation aspects require explicit declaration using [assembly: MyAspect] syntax.

For more localized transformations, consider using TypeAspect for type-level aspects or member-specific aspect base classes.

This is a convenience base class. The aspect framework primarily requires implementation of IAspect<T>.

Constructors

Name Description
CompilationAspect()

Methods

Name Description
BuildAspect(IAspectBuilder<ICompilation>)

Defines the aspect implementation by adding advice, child aspects, and validators to the target declaration.

BuildEligibility(IEligibilityBuilder<ICompilation>)

Configures the eligibility of the aspect or attribute by defining rules that determine which declarations the aspect can be applied to.

Extension Methods

See Also