Base interface for objects that can cause aspects to be added to a compilation, such as aspect instances and fabric instances. This interface tracks the chain of causality that led to an aspect being applied, accessible through the Predecessors property.
Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
[InternalImplement]
public interface IAspectPredecessorRemarks
This interface is implemented by IAspectInstance, IFabricInstance, and IAttribute, establishing a unified model for tracking what caused aspects to be added to declarations.
The primary use case for predecessors when building aspects is to access the state of parent aspects through IAspectState. When a parent aspect creates child aspects, the child aspects can query their Predecessors to find the parent aspect instance and access its state, enabling communication and data sharing between parent and child aspects in the aspect composition hierarchy.
Predecessors also serve secondary purposes for debugging, introspection, and understanding aspect composition and provenance.
For example:
- When a fabric adds an aspect to a type, that fabric instance becomes a predecessor of the aspect instance.
- When an aspect creates child aspects, the parent aspect instance becomes a predecessor of the child aspect instances, allowing children to access parent state.
- When a custom attribute that is also an aspect (e.g., a class implementing IAspect) is applied to a declaration, the attribute becomes a predecessor.
Properties
| Name | Description |
|---|---|
| PredecessorDegree | Gets the depth in the predecessor chain, indicating how many levels of indirection exist between
the root cause and this predecessor. A value of |
| Predecessors | Gets the list of objects that have caused the current aspect instance (but not any instance in the SecondaryInstances list) to be created. The ordering of this list is undetermined and should not be relied upon. |
| TargetDeclaration | Gets the declaration to which the aspect or fabric is applied. |