Open sandboxFocus

Interface IAspectInstance

Represents an instance of an aspect. The instance of the IAspect itself is in the Aspect property.

Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[InternalImplement]
[CompileTime]
public interface IAspectInstance : IAspectPredecessor
Remarks

Use Cases:

  • Accessing the current aspect instance: In the BuildAspect(IAspectBuilder<T>) method, access the current aspect instance via AspectInstance to retrieve aspect-specific information such as AspectClass, AspectState, SecondaryInstances, or Predecessors.
  • In templates: Access the current aspect instance via meta.AspectInstance to retrieve aspect-specific information during code generation.
  • Querying aspects on declarations: Retrieve aspect instances applied to any declaration using GetAspectInstances() to inspect which aspects have been applied and their state. This can only query aspects that have already been applied or are being applied (e.g., aspects ordered before the current one, or instances of the current aspect applied in a parent class).
  • In aspect predecessor chains: When examining Predecessors, predecessor instances can be cast to IAspectInstance when Kind indicates an aspect relationship.

Properties

Name Description
Aspect

Gets the aspect instance.

AspectClass

Gets the aspect type.

AspectState

Gets the optional opaque object defined by the aspect for the specific TargetDeclaration using the AspectState property of the IAspectBuilder interface.

IsInheritable

Gets a value indicating whether the current aspect instance can be inherited by derived declarations.

IsSkipped

Gets a value indicating whether the current aspect instance has been skipped. This value is true if the aspect evaluation resulted in an error or if the BuildAspect(IAspectBuilder<T>) method invoked SkipAspect(), if it has been excluded using ExcludeAspectAttribute, or when the target declaration was not eligible.

SecondaryInstances

Gets the other instances of the same AspectClass on the same TargetDeclaration. When several instances of the same AspectClass are found on the same TargetDeclaration, they are ordered by priority, and only the first one (the primary instance) gets executed. The other instances are exposed on this property.

Extension Methods

See Also