Custom attribute that, when applied to an aspect class, causes all instances of this aspect to be inherited by derived declarations. The aspect's BuildAspect(IAspectBuilder<T>) method is invoked not only for the direct target declaration but also for all derived declarations.
Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[AttributeUsage(AttributeTargets.Class)]
[CompileTime]
public sealed class InheritableAttribute : AttributeRemarks
Aspects marked with this attribute are inherited in the following scenarios:
- From a base class to all derived classes
- From a base interface to all derived interfaces
- From an interface to all types implementing that interface
- From a
virtualorabstractmember to itsoverridemembers - From an interface member to its implementations
- From a parameter of a
virtualorabstractmethod to the corresponding parameter of alloverridemethods - From a parameter of an interface member to the corresponding parameter of all its implementations
Cross-project inheritance: Aspect inheritance works across project boundaries. 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. This is why aspect classes must be compile-time serializable (they derive from Attribute, which is automatically serializable).
Conditional inheritance: For aspects that need to decide inheritability based on properties or context, implement IConditionallyInheritableAspect instead of using this attribute.
Constructors
| Name | Description |
|---|---|
| InheritableAttribute() |