Open sandboxFocusImprove this doc

Namespace Metalama.Framework.Workspaces

Overview

This namespace enables the loading of a C# project and solution into the Metalama.Framework.Code code model from any application, such as LinqPad.

The entry point of this namespace is the WorkspaceCollection class.

Class Diagram

classDiagram
    class ICompilationSet {
        Compilations
        Types
        Methods
        Fields
        Properties
        FieldsAndProperties
        Constructors
        Events
        TargetFrameworks
    }

    class IIntrospectionCompilationDetails {
        Diagnostics
        AspectClasses
        AspectLayers
        AspectInstances
        Advice
        Transformations
        IsMetalamaEnabled
        HasMetalamaSucceeded
    }

    class IProjectSet {
        Projects
        GetSubset()
        GetDeclaration()
    }

    IProjectSet --> ICompilationSet  : SourceCode
    ICompilationSetResult --|> IIntrospectionCompilationDetails
    ICompilationSetResult --> ICompilationSet  : TransformedCode

    IProjectSet --|>  ICompilationSet
    IProjectSet --|> ICompilationSetResult
    Project --|> IProjectSet
    Workspace  --|> IProjectSet
    WorkspaceCollection --* Workspace

    IProjectSet --* Project : Projects

Classes

DeclarationExtensions

Extension methods for IDeclaration that provide introspection capabilities within a workspace.

DiagnosticExtensions

Extension methods for IIntrospectionDiagnostic.

DiagnosticReporter

A utility class that makes it easy to report diagnostics from code queries in different environments. The default implementation writes messages to the console using the ReportToConsole(IReadOnlyList<IIntrospectionDiagnostic>) method. The action can be changed by setting the ReportAction property.

MSBuildInitializationException

An exception thrown when MSBuild initialization fails.

Project

Represents a C# project for a specific compilation. When a project targets multiple frameworks, each target framework is represented by a separate Project instance.

ServiceBuilder

A builder for registering custom project services that will be available to all workspaces in a WorkspaceCollection.

Workspace

Represents a set of projects. Workspaces can be created using the WorkspaceCollection class. When projects target several frameworks, they are represented by several instances of the Project class in the workspace.

WorkspaceCollection

Represents a set of workspaces. Two attempts to load a workspace with the same parameters, in the same WorkspaceCollection, will return the exact same instance, unless the Reset() method is called.

WorkspaceLoadException

An exception thrown when errors occur while loading a workspace.

Interfaces

ICompilationSet

Represents a set of compilations and exposes lists of declarations that merge the declarations from all the compilations in the set.

ICompilationSetResult

Represents the result of compiling a set of compilations, providing access to both introspection details and the transformed code produced by Metalama.

IProjectSet

Represents a set of projects. An IProjectSet can include several instances of the Project for the same file if they target multiple frameworks, one Project instance per framework. You can create a subset with the GetSubset(Predicate<Project>) method.

IWorkspaceLoadInfo

Exposes the information needed to reconstruct a Workspace.