Open sandboxFocus

Class 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.

Inheritance
Workspace
Namespace: Metalama.Framework.Workspaces
Assembly: Metalama.Framework.Workspaces.dll
Syntax
public sealed class Workspace : IDisposable, IProjectSet, ICompilationSetResult, IIntrospectionCompilationDetails, IWorkspaceLoadInfo
Remarks

A workspace can be created by calling Load(params string[]) or LoadAsync(params string[]), which load projects or solutions into the default WorkspaceCollection. Workspaces with the same parameters are cached and reused within the same collection.

The workspace provides access to project information through the Projects property, and exposes introspection capabilities for analyzing aspect instances, transformations, and diagnostics across all loaded projects. Use ApplyFilter(Predicate<Project>) to filter projects and focus introspection queries on specific subsets.

Properties

Name Description
Advice

Gets the list of advice in the compilation.

AspectClasses

Gets the list of aspect classes in the compilation.

AspectInstances

Gets the list of aspect instances in the compilation.

AspectLayers

Gets the ordered list of aspect layers in the compilation. Note that when the current object represents several projects, the execution order of the aspect layers is not relevant.

Diagnostics

Gets the list of diagnostics reported by Metalama and by aspects.

HasMetalamaSucceeded

Gets a value indicating whether the processing of the compilation by Metalama was successful for all projects in the current set. This property returns true if the Metalama compilation process completed successfully, even if it resulted the compilation processes reported errors. These errors would be visible in the Diagnostics collection.

IntrospectionOptions

Gets or sets the IntrospectionOptions for the current workspace.

IsMetalamaEnabled

Gets a value indicating whether Metalama is enabled on this project.

LoadedPaths

Gets the paths of the projects or solutions that were loaded into the workspace.

MetalamaVersion

Gets the version number of Metalama. This is determined by the LinqPad packages for Metalama, not by the Metalama packages in the projects loaded in the workspace.

Projects

Gets the projects in the current project set.

Properties

Gets the MSBuild properties that were used when loading the workspace.

SourceCode

Gets the source code compilations for all projects in this set, before Metalama transformations are applied.

Transformations

Gets the list of transformations applied to source code.

TransformedCode

Gets the transformed code produced by Metalama for the compilations in this set.

WorkspaceDiagnostics

Gets the diagnostics produced while loading the workspace, such as MSBuild errors or warnings.

Methods

Name Description
ApplyFilter(Predicate<Project>)
ClearFilters()

Clears all filters applied by ApplyFilter(Predicate<Project>), restoring the Projects collection to include all loaded projects.

Dispose()
GetDeclaration(string, string, string, bool)
GetProject(string, string?)
GetSubset(Predicate<Project>)
Load(params string[])
LoadAsync(params string[])
Reload(bool, CancellationToken)
ReloadAsync(bool, CancellationToken)
WithIgnoreErrors()

Modifies the IntrospectionOptions of the current workspace by setting the IgnoreErrors property to true, and returns the current workspace.

WithIntrospectionOptions(IntrospectionOptions)

Modifies the IntrospectionOptions of the current workspace, and returns the current workspace.

Events

Name Description
Disposed

Extension Methods

See Also