Open sandboxFocusImprove this doc

Namespace Metalama.Framework.Introspection

Overview

This namespace reveals intermediate details of the compilation process, such as the list of aspect classes, aspect instances, advice, transformations, and diagnostics.

This namespace proves useful when troubleshooting an aspect, a fabric, or a set of aspects. It provides details that are not readily apparent from the compilation output.

To begin with this namespace, load your C# project or solution using the Metalama.Framework.Workspaces namespace or with the LINQPad driver. Refer to Using LINQPad for more information.

The entry point of this namespace is the IIntrospectionCompilationDetails interface. This interface is implemented by the Workspace and Project classes.

For example, the following query returns all aspect instances in a project:

workspace.GetProject("Metalama.Samples.Log4", "net9.0").AspectInstances

Class diagram

classDiagram


    IIntrospectionCompilationDetails --* "0..*" IIntrospectionDiagnostic
    IIntrospectionCompilationDetails --* "0..*" IIntrospectionAspectClass
    IIntrospectionCompilationDetails --* "0..*" IIntrospectionAspectLayer
    IIntrospectionCompilationDetails --* "0..*" IIntrospectionAspectInstance
    IIntrospectionCompilationDetails --* "0..*" IIntrospectionAdvice
    IIntrospectionCompilationDetails --* "0..*" IIntrospectionTransformation


    IIntrospectionAspectClass "1" --* "0..*" IIntrospectionAspectInstance
    IIntrospectionAspectClass "1" --o "1..*" IIntrospectionAspectLayer

    IIntrospectionAspectInstance  --* "0..*" IIntrospectionDiagnostic
    IIntrospectionAspectInstance --o "0..*" IIntrospectionAdvice
    IIntrospectionAspectInstance --* "0..*" IIntrospectionAspectInstance : SecondaryInstances
    IIntrospectionAspectInstance --|> IIntrospectionAspectPredecessor
    IIntrospectionFabric --|> IIntrospectionAspectPredecessor

    IIntrospectionAttributeAsPredecessor --|> IIntrospectionAspectPredecessor

    class IIntrospectionAspectInstance {
        Aspect: IAspect
        AspectState: IAspectState
    }

    class IIntrospectionAspectLayer {
        Id
        LayerName
        Order
        ExplicitOrder
        IsDefaultLayer
    }

    class IIntrospectionAspectPredecessor {
     PredecessorDegree
     TargetDeclaration : IDeclaration

    }

    class IIntrospectionAdvice {
        AdviceKind
        TargetDeclaration
        AspectLayerId
    }

    class IIntrospectionTransformation {
        TransformationKind
        TargetDeclaration
        Description
        IntroducedDeclaration
        Order
    }

    IIntrospectionAdvice "1" --* "0..*" IIntrospectionTransformation : Transformation

    IIntrospectionAspectPredecessor "0..*" --* "0..*" IIntrospectionAspectPredecessor : Predecessors
    IIntrospectionAspectPredecessor "0..*" --* "0..*" IIntrospectionAspectPredecessor : Successors

Classes

CompilationFailedException

Exception thrown when the compilation failed.

IntrospectionAspectRelationship

Represents the relationship that an object (attribute, fabric, aspect) has created or required another aspect or validator. These relationships are exposed on Predecessors and Successors.

IntrospectionOptions

Options for introspection operations.

Structs

IntrospectionReferenceDetail

Provides detailed information about a specific occurrence of a reference between declarations, including the exact source location and the kind of reference.

Interfaces

IIntrospectionAdvice

Represents a piece of advice provided by an aspect.

IIntrospectionAspectClass

Represents an aspect class (i.e. a type of aspect) and exposes all its instances in the current scope.

IIntrospectionAspectInstance

Represents an instance of an aspect, as well as the results of the aspect instance.

IIntrospectionAspectLayer

Represents an aspect layer in the compilation.

IIntrospectionAspectPredecessor

Base interface for objects that can cause aspects to be added to a compilation. Predecessors are exposed on the Predecessors property.

IIntrospectionAttributeAsPredecessor

Wraps an IAttribute (which represents a custom attribute) into a IIntrospectionAspectPredecessor.

IIntrospectionCompilationDetails

Exposes the compilation results but not the transformed source code.

IIntrospectionCompilationResult

Represents the result of the processing of a compilation by Metalama.

IIntrospectionDiagnostic

Represents a diagnostic (error, warning, information, hidden message).

IIntrospectionFabric

Represents a fabric.

IIntrospectionReference

Represents a reference from one declaration to another.

IIntrospectionReferenceGraph

Provides methods for querying references between declarations in a compilation. This interface enables static code analysis by exposing both inbound references (declarations that reference a target) and outbound references (declarations that a source declaration references).

IIntrospectionTransformation

Represents a code transformation.

IProjectIntrospectionService

Provides introspection services for a project, including access to the reference graph for analyzing code relationships between declarations.

Enums

IntrospectionChildKinds

Specifies which kinds of child declarations to include when querying references.

IntrospectionDiagnosticSource

Enumerates the possible sources (or originators) of an IIntrospectionDiagnostic.

IntrospectionTransformationKind

Enumerates the kinds of code transformations.