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