A base class for aspects that target both field and property declarations uniformly.
Inheritance
Implements
Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field)]
public abstract class FieldOrPropertyAspect : Aspect, IAspect<IFieldOrProperty>, IAspect, ICompileTimeSerializable, ITemplateProvider, IEligible<IFieldOrProperty>Remarks
This class provides a convenient base for creating aspects that apply to both fields and properties by implementing
IAspect<T> with T set to IFieldOrProperty. Derived classes override
BuildAspect(IAspectBuilder<IFieldOrProperty>) to add advice (such as overriding accessors, adding contracts, or introducing attributes)
to the target field or property.
For aspects that specifically override field or property accessors with templates, consider deriving from OverrideFieldOrPropertyAspect instead, which provides a simpler template-based API. For aspects that need to distinguish between fields and properties, use FieldAspect and PropertyAspect separately.
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<IFieldOrProperty>) method.
This is a convenience base class. The aspect framework primarily requires implementation of IAspect<T>.
Constructors
| Name | Description |
|---|---|
| FieldOrPropertyAspect() |
Methods
| Name | Description |
|---|---|
| BuildAspect(IAspectBuilder<IFieldOrProperty>) | Defines the aspect implementation by adding advice, child aspects, and validators to the target declaration. |
| BuildEligibility(IEligibilityBuilder<IFieldOrProperty>) | Configures the eligibility of the aspect or attribute by defining rules that determine which declarations the aspect can be applied to. |