Open sandboxFocus

Interface IAspect<T>

The generic base interface for all aspects, where the type parameter specifies the kind of code declaration the aspect can be applied to.

Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[ForcedGenericRunTimeOrCompileTime]
public interface IAspect<in T> : IAspect, ICompileTimeSerializable, ITemplateProvider, IEligible<T> where T : class, IDeclaration
Type Parameters
Name Description
T

The type of declaration this aspect targets (e.g., IMethod, INamedType, IProperty).

Remarks

This is the primary interface that aspect classes implement. The type parameter T determines what kind of code elements (methods, types, properties, etc.) the aspect can be applied to.

The BuildAspect(IAspectBuilder<T>) method is called at compile time to configure how the aspect transforms the target code. This method receives an IAspectBuilder<TAspectTarget> which provides access to:

  • The target declaration being advised
  • Extension methods to add advice (transformations) via AdviserExtensions
  • Diagnostic reporting and suppression
  • Child aspect application and validation registration

Aspects can be applied to code in several ways: as custom attributes (by deriving from Aspect), programmatically via fabrics, through aspect inheritance, or as child aspects added by other aspects.

For complex aspects requiring multiple execution phases, annotate the aspect class with LayersAttribute to have BuildAspect(IAspectBuilder<T>) called multiple times in a defined order.

Methods

Name Description
BuildAspect(IAspectBuilder<T>)

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

Extension Methods

See Also