Open sandboxFocus

Class PropertyAspect

A base class for aspects that target property declarations.

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

This class provides a convenient base for creating property-level aspects by implementing IAspect<T> with T set to IProperty. Derived classes override BuildAspect(IAspectBuilder<IProperty>) to add advice (such as overriding property accessors, adding contracts, or introducing attributes) to the target property.

For aspects that need to handle both fields and properties uniformly, consider deriving from FieldOrPropertyAspect instead. For aspects that specifically override property accessor implementations with templates, consider deriving from OverrideFieldOrPropertyAspect, which provides a simpler template-based API.

Aspects can only be applied to run-time code, never to compile-time types or their members. This eligibility restriction is enforced by the BuildEligibility(IEligibilityBuilder<IProperty>) method.

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

Constructors

Name Description
PropertyAspect()

Methods

Name Description
BuildAspect(IAspectBuilder<IProperty>)

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

BuildEligibility(IEligibilityBuilder<IProperty>)

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