An interface that can be implemented by aspects that determine their inheritability dynamically based on aspect properties or the target declaration. When all the instances of the aspect class are unconditionally inheritable, use the InheritableAttribute instead.
Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
public interface IConditionallyInheritableAspect : IAspect, ICompileTimeSerializable, ITemplateProviderRemarks
Implementing this interface allows an aspect to decide at runtime whether it should be inherited by derived declarations. The IsInheritable(IDeclaration, IAspectInstance) method is called to determine whether a specific aspect instance should propagate to:
- Derived classes (from a base class)
- Derived interfaces (from a base interface)
- Implementing types (from an interface)
- Override members (from a virtual or abstract member)
- Interface implementations (from an interface member)
Cross-project inheritance: When the base declaration is in a referenced assembly, the IAspect object itself and its IAspectState (if set) are serialized into that assembly and deserialized when compiling the derived project. Ensure your aspect class and any custom state are compile-time serializable.
Note: When this interface is implemented, the IDE refactoring menu will always suggest adding the aspect to a declaration, even if the aspect is eligible for inheritance only on the target declaration.
Methods
| Name | Description |
|---|---|
| IsInheritable(IDeclaration, IAspectInstance) | Determines whether this aspect instance should be inherited by derived declarations. |