Open sandboxFocus

Class InheritableAttribute

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.

Inheritance
InheritableAttribute
Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[AttributeUsage(AttributeTargets.Class)]
[CompileTime]
public sealed class InheritableAttribute : Attribute
Remarks

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 virtual or abstract member to its override members
  • From an interface member to its implementations
  • From a parameter of a virtual or abstract method to the corresponding parameter of all override methods
  • 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()

Extension Methods

See Also