Open sandboxFocus

Class TypeAspect

A base class for aspects that target type declarations (classes, structs, interfaces, delegates, and enums).

Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Interface|AttributeTargets.Delegate)]
public abstract class TypeAspect : Aspect, IAspect<INamedType>, IAspect, ICompileTimeSerializable, ITemplateProvider, IEligible<INamedType>
Remarks

This class provides a convenient base for creating type-level aspects by implementing IAspect<T> with T set to INamedType. Derived classes override BuildAspect(IAspectBuilder<INamedType>) to add advice (such as introducing members, implementing interfaces, or applying child aspects) to the target type.

Aspects can only be applied to run-time code, never to compile-time types (types marked with CompileTimeAttribute or RunTimeOrCompileTimeAttribute). This eligibility restriction is enforced by the BuildEligibility(IEligibilityBuilder<INamedType>) method.

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

Constructors

Name Description
TypeAspect()

Methods

Name Description
BuildAspect(IAspectBuilder<INamedType>)

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

BuildEligibility(IEligibilityBuilder<INamedType>)

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