Udostępnij za pośrednictwem


AdhocWorkspace Class

Definition

A workspace that allows full manipulation of projects and documents, but does not persist changes.

public ref class AdhocWorkspace sealed : Microsoft::CodeAnalysis::Workspace
public sealed class AdhocWorkspace : Microsoft.CodeAnalysis.Workspace
type AdhocWorkspace = class
    inherit Workspace
Public NotInheritable Class AdhocWorkspace
Inherits Workspace
Inheritance
AdhocWorkspace

Constructors

AdhocWorkspace()
AdhocWorkspace(HostServices, String)

A workspace that allows full manipulation of projects and documents, but does not persist changes.

Properties

CanOpenDocuments

Returns true, signifiying that you can call the open and close document APIs to add the document into the open document list.

CurrentSolution

The current solution.

The solution is an immutable model of the current set of projects and source documents. It provides access to source text, syntax trees and semantics.

This property may change as the workspace reacts to changes in the environment or after TryApplyChanges(Solution) is called.

(Inherited from Workspace)
Kind

The kind of the workspace. This is generally Host if originating from the host environment, but may be any other name used for a specific kind of workspace.

(Inherited from Workspace)
Options
Obsolete.

Gets or sets the set of all global options and Options. Setter also force updates the CurrentSolution to have the updated Options.

(Inherited from Workspace)
PartialSemanticsEnabled

Override this property if the workspace supports partial semantics for documents.

(Inherited from Workspace)
Services

Services provider by the host for implementing workspace features.

(Inherited from Workspace)

Methods

AddDocument(DocumentInfo)

Adds a document to the workspace.

AddDocument(ProjectId, String, SourceText)

Adds a document to the workspace.

AddProject(ProjectInfo)

Adds a project to the workspace. All previous projects remain intact.

AddProject(String, String)

Adds a project to the workspace. All previous projects remain intact.

AddProjects(IEnumerable<ProjectInfo>)

Adds multiple projects to the workspace at once. All existing projects remain intact.

AddSolution(SolutionInfo)

Adds an entire solution to the workspace, replacing any existing solution.

AdjustReloadedProject(Project, Project) (Inherited from Workspace)
AdjustReloadedSolution(Solution, Solution)

This method is called during OnSolutionReload. Override this method if you want to manipulate the reloaded solution.

(Inherited from Workspace)
ApplyAdditionalDocumentAdded(DocumentInfo, SourceText)

This method is called during TryApplyChanges(Solution) to add a new additional document to a project.

Override this method to implement the capability of adding additional documents.

(Inherited from Workspace)
ApplyAdditionalDocumentRemoved(DocumentId)

This method is called during TryApplyChanges(Solution) to remove an additional document from a project.

Override this method to implement the capability of removing additional documents.

(Inherited from Workspace)
ApplyAdditionalDocumentTextChanged(DocumentId, SourceText)

This method is called to change the text of an additional document.

Override this method to implement the capability of changing additional document text.

(Inherited from Workspace)
ApplyAnalyzerConfigDocumentAdded(DocumentInfo, SourceText)

This method is called during TryApplyChanges(Solution) to add a new analyzer config document to a project.

Override this method to implement the capability of adding analyzer config documents.

(Inherited from Workspace)
ApplyAnalyzerConfigDocumentRemoved(DocumentId)

This method is called during TryApplyChanges(Solution) to remove an analyzer config document from a project.

Override this method to implement the capability of removing analyzer config documents.

(Inherited from Workspace)
ApplyAnalyzerConfigDocumentTextChanged(DocumentId, SourceText)

This method is called to change the text of an analyzer config document.

Override this method to implement the capability of changing analyzer config document text.

(Inherited from Workspace)
ApplyAnalyzerReferenceAdded(ProjectId, AnalyzerReference)

This method is called during TryApplyChanges(Solution) to add an analyzer reference to a project.

Override this method to implement the capability of adding analyzer references.

(Inherited from Workspace)
ApplyAnalyzerReferenceRemoved(ProjectId, AnalyzerReference)

This method is called during TryApplyChanges(Solution) to remove an analyzer reference from a project.

Override this method to implement the capability of removing analyzer references.

(Inherited from Workspace)
ApplyCompilationOptionsChanged(ProjectId, CompilationOptions)

This method is called during TryApplyChanges(Solution) to change the compilation options.

Override this method to implement the capability of changing compilation options.

(Inherited from Workspace)
ApplyDocumentAdded(DocumentInfo, SourceText)

This method is called during TryApplyChanges(Solution) to add a new document to a project.

Override this method to implement the capability of adding documents.

(Inherited from Workspace)
ApplyDocumentInfoChanged(DocumentId, DocumentInfo)

This method is called to change the info of a document.

Override this method to implement the capability of changing a document's info.

(Inherited from Workspace)
ApplyDocumentRemoved(DocumentId)

This method is called during TryApplyChanges(Solution) to remove a document from a project.

Override this method to implement the capability of removing documents.

(Inherited from Workspace)
ApplyDocumentTextChanged(DocumentId, SourceText)

This method is called to change the text of a document.

Override this method to implement the capability of changing document text.

(Inherited from Workspace)
ApplyMetadataReferenceAdded(ProjectId, MetadataReference)

This method is called during TryApplyChanges(Solution) to add a metadata reference to a project.

Override this method to implement the capability of adding metadata references.

(Inherited from Workspace)
ApplyMetadataReferenceRemoved(ProjectId, MetadataReference)

This method is called during TryApplyChanges(Solution) to remove a metadata reference from a project.

Override this method to implement the capability of removing metadata references.

(Inherited from Workspace)
ApplyParseOptionsChanged(ProjectId, ParseOptions)

This method is called during TryApplyChanges(Solution) to change the parse options.

Override this method to implement the capability of changing parse options.

(Inherited from Workspace)
ApplyProjectAdded(ProjectInfo)

This method is called during TryApplyChanges(Solution) to add a project to the current solution.

Override this method to implement the capability of adding projects.

(Inherited from Workspace)
ApplyProjectChanges(ProjectChanges)

This method is called during TryApplyChanges(Solution) for each project that has been added, removed or changed.

Override this method if you want to modify how project changes are applied.

(Inherited from Workspace)
ApplyProjectReferenceAdded(ProjectId, ProjectReference)

This method is called during TryApplyChanges(Solution) to add a project reference to a project.

Override this method to implement the capability of adding project references.

(Inherited from Workspace)
ApplyProjectReferenceRemoved(ProjectId, ProjectReference)

This method is called during TryApplyChanges(Solution) to remove a project reference from a project.

Override this method to implement the capability of removing project references.

(Inherited from Workspace)
ApplyProjectRemoved(ProjectId)

This method is called during TryApplyChanges(Solution) to remove a project from the current solution.

Override this method to implement the capability of removing projects.

(Inherited from Workspace)
CanApplyChange(ApplyChangesKind)
CanApplyCompilationOptionChange(CompilationOptions, CompilationOptions, Project)

Called during a call to TryApplyChanges(Solution) to determine if a specific change to CompilationOptions is allowed.

(Inherited from Workspace)
CanApplyParseOptionChange(ParseOptions, ParseOptions, Project)

Called during a call to TryApplyChanges(Solution) to determine if a specific change to ParseOptions is allowed.

(Inherited from Workspace)
CheckAdditionalDocumentIsInCurrentSolution(DocumentId)

Throws an exception if an additional document is not part of the current solution.

(Inherited from Workspace)
CheckAdditionalDocumentIsNotInCurrentSolution(DocumentId)

Throws an exception if an additional document is already part of the current solution.

(Inherited from Workspace)
CheckAnalyzerConfigDocumentIsInCurrentSolution(DocumentId)

Throws an exception if an analyzer config is not part of the current solution.

(Inherited from Workspace)
CheckAnalyzerConfigDocumentIsNotInCurrentSolution(DocumentId)

Throws an exception if the analyzer config document is already part of the current solution.

(Inherited from Workspace)
CheckCanOpenDocuments() (Inherited from Workspace)
CheckDocumentCanBeRemoved(DocumentId) (Inherited from Workspace)
CheckDocumentIsClosed(DocumentId) (Inherited from Workspace)
CheckDocumentIsInCurrentSolution(DocumentId)

Throws an exception if a document is not part of the current solution.

(Inherited from Workspace)
CheckDocumentIsNotInCurrentSolution(DocumentId)

Throws an exception if a document is already part of the current solution.

(Inherited from Workspace)
CheckDocumentIsOpen(DocumentId) (Inherited from Workspace)
CheckProjectCanBeRemoved(ProjectId)

Currently projects can always be removed, but this method still exists because it's protected and we don't want to break people who may have derived from Workspace and either called it, or overridden it.

(Inherited from Workspace)
CheckProjectDoesNotContainOpenDocuments(ProjectId) (Inherited from Workspace)
CheckProjectDoesNotHaveAnalyzerReference(ProjectId, AnalyzerReference)

Throws an exception if a project already has a specific analyzer reference.

(Inherited from Workspace)
CheckProjectDoesNotHaveMetadataReference(ProjectId, MetadataReference)

Throws an exception if a project already has a specific metadata reference.

(Inherited from Workspace)
CheckProjectDoesNotHaveProjectReference(ProjectId, ProjectReference)

Throws an exception if a project already has a specific project reference.

(Inherited from Workspace)
CheckProjectDoesNotHaveTransitiveProjectReference(ProjectId, ProjectId)

Throws an exception if project has a transitive reference to another project.

(Inherited from Workspace)
CheckProjectHasAnalyzerReference(ProjectId, AnalyzerReference)

Throws an exception if a project does not have a specific analyzer reference.

(Inherited from Workspace)
CheckProjectHasMetadataReference(ProjectId, MetadataReference)

Throws an exception if a project does not have a specific metadata reference.

(Inherited from Workspace)
CheckProjectHasProjectReference(ProjectId, ProjectReference)

Throws an exception if a project does not have a specific project reference.

(Inherited from Workspace)
CheckProjectIsInCurrentSolution(ProjectId)

Throws an exception if the project is not part of the current solution.

(Inherited from Workspace)
CheckProjectIsNotInCurrentSolution(ProjectId)

Throws an exception is the project is part of the current solution.

(Inherited from Workspace)
CheckSolutionIsEmpty()

Throws an exception is the solution is not empty.

(Inherited from Workspace)
ClearDocumentData(DocumentId)

This method is called to clear an individual document is removed.

Override this method if you want to do additional work when a document is removed. Call the base method at the end of your method.

(Inherited from Workspace)
ClearOpenDocument(DocumentId, Boolean)
Obsolete.
(Inherited from Workspace)
ClearOpenDocument(DocumentId) (Inherited from Workspace)
ClearProjectData(ProjectId)

This method is called when an individual project is removed.

Override this method if you want to do additional work when a project is removed. Call the base method at the end of your method.

(Inherited from Workspace)
ClearSolution()

Clears all projects and documents from the workspace.

ClearSolutionData()

This method is called when a solution is cleared.

Override this method if you want to do additional work when a solution is cleared. Call the base method at the end of your method.

This method is called while a lock is held. Be very careful when overriding as innapropriate work can cause deadlocks.

(Inherited from Workspace)
CloseAdditionalDocument(DocumentId)

Puts the specified additional document into the closed state

CloseAnalyzerConfigDocument(DocumentId)

Puts the specified analyzer config document into the closed state

CloseAnalyzerConfigDocument(DocumentId)

Close the specified analyzer config document in the host environment.

(Inherited from Workspace)
CloseDocument(DocumentId)

Puts the specified document into the closed state.

CreateSolution(SolutionId)

Create a new empty solution instance associated with this workspace.

(Inherited from Workspace)
CreateSolution(SolutionInfo)

Create a new empty solution instance associated with this workspace.

(Inherited from Workspace)
Dispose()

Disposes this workspace. The workspace can longer be used after it is disposed.

(Inherited from Workspace)
Dispose(Boolean)

Call this method when the workspace is disposed.

Override this method to do additional work when the workspace is disposed. Call this method at the end of your method.

(Inherited from Workspace)
GetAdditionalDocumentName(DocumentId)

Gets the name to use for an additional document in an error message.

(Inherited from Workspace)
GetAnalyzerConfigDocumentName(DocumentId)

Gets the name to use for an analyzer document in an error message.

(Inherited from Workspace)
GetDocumentIdInCurrentContext(SourceTextContainer)

Gets the id for the document associated with the given text container in its current context. Documents are normally associated with a text container when the documents are opened.

(Inherited from Workspace)
GetDocumentName(DocumentId)

Gets the name to use for a document in an error message.

(Inherited from Workspace)
GetOpenDocumentIds(ProjectId)

Gets a list of the currently opened documents.

(Inherited from Workspace)
GetProjectName(ProjectId)

Gets the name to use for a project in an error message.

(Inherited from Workspace)
GetRelatedDocumentIds(SourceTextContainer)

Gets the ids for documents in the CurrentSolution snapshot associated with the given container. Documents are normally associated with a text container when the documents are opened.

(Inherited from Workspace)
IsDocumentOpen(DocumentId)

Determines if the document is currently open in the host environment.

(Inherited from Workspace)
OnAdditionalDocumentAdded(DocumentInfo)

Call this method when an additional document is added to a project in the host environment.

(Inherited from Workspace)
OnAdditionalDocumentClosed(DocumentId, TextLoader) (Inherited from Workspace)
OnAdditionalDocumentOpened(DocumentId, SourceTextContainer, Boolean) (Inherited from Workspace)
OnAdditionalDocumentRemoved(DocumentId)

Call this method when an additional document is removed from a project in the host environment.

(Inherited from Workspace)
OnAdditionalDocumentTextChanged(DocumentId, SourceText, PreservationMode)

Call this method when the text of an additional document is updated in the host environment.

(Inherited from Workspace)
OnAdditionalDocumentTextLoaderChanged(DocumentId, TextLoader)

Call this method when the text of a additional document is changed on disk.

(Inherited from Workspace)
OnAnalyzerConfigDocumentAdded(DocumentInfo)

Call this method when an analyzer config document is added to a project in the host environment.

(Inherited from Workspace)
OnAnalyzerConfigDocumentClosed(DocumentId, TextLoader) (Inherited from Workspace)
OnAnalyzerConfigDocumentOpened(DocumentId, SourceTextContainer, Boolean) (Inherited from Workspace)
OnAnalyzerConfigDocumentRemoved(DocumentId)

Call this method when an analyzer config document is removed from a project in the host environment.

(Inherited from Workspace)
OnAnalyzerConfigDocumentTextChanged(DocumentId, SourceText, PreservationMode)

Call this method when the text of an analyzer config document is updated in the host environment.

(Inherited from Workspace)
OnAnalyzerConfigDocumentTextLoaderChanged(DocumentId, TextLoader)

Call this method when the text of a analyzer config document is changed on disk.

(Inherited from Workspace)
OnAnalyzerReferenceAdded(ProjectId, AnalyzerReference)

Call this method when an analyzer reference is added to a project in the host environment.

(Inherited from Workspace)
OnAnalyzerReferenceRemoved(ProjectId, AnalyzerReference)

Call this method when an analyzer reference is removed from a project in the host environment.

(Inherited from Workspace)
OnAssemblyNameChanged(ProjectId, String)

Call this method when a project's assembly name is changed in the host environment.

(Inherited from Workspace)
OnCompilationOptionsChanged(ProjectId, CompilationOptions)

Call this method when a project's compilation options are changed in the host environment.

(Inherited from Workspace)
OnDocumentAdded(DocumentInfo)

Call this method when a document is added to a project in the host environment.

(Inherited from Workspace)
OnDocumentClosed(DocumentId, TextLoader, Boolean) (Inherited from Workspace)
OnDocumentClosing(DocumentId)

Override this method to act immediately when a document is closing, as opposed to waiting for the corresponding workspace changed event to fire asynchronously.

(Inherited from Workspace)
OnDocumentContextUpdated(DocumentId)

Call this method when a document has been made the active context in the host environment.

(Inherited from Workspace)
OnDocumentInfoChanged(DocumentId, DocumentInfo)

Call this method when the document info changes, such as the name, folders or file path.

(Inherited from Workspace)
OnDocumentOpened(DocumentId, SourceTextContainer, Boolean) (Inherited from Workspace)
OnDocumentReloaded(DocumentInfo)

Call this method when a document is reloaded in the host environment.

(Inherited from Workspace)
OnDocumentRemoved(DocumentId)

Call this method when a document is removed from a project in the host environment.

(Inherited from Workspace)
OnDocumentsAdded(ImmutableArray<DocumentInfo>)

Call this method when multiple document are added to one or more projects in the host environment.

(Inherited from Workspace)
OnDocumentSourceCodeKindChanged(DocumentId, SourceCodeKind)

Call this method when the SourceCodeKind of a document changes in the host environment.

(Inherited from Workspace)
OnDocumentTextChanged(Document)

Override this method to act immediately when the text of a document has changed, as opposed to waiting for the corresponding workspace changed event to fire asynchronously.

(Inherited from Workspace)
OnDocumentTextChanged(DocumentId, SourceText, PreservationMode)

Call this method when the text of a document is updated in the host environment.

(Inherited from Workspace)
OnDocumentTextLoaderChanged(DocumentId, TextLoader)

Call this method when the text of a document is changed on disk.

(Inherited from Workspace)
OnMetadataReferenceAdded(ProjectId, MetadataReference)

Call this method when a metadata reference is added to a project in the host environment.

(Inherited from Workspace)
OnMetadataReferenceRemoved(ProjectId, MetadataReference)

Call this method when a metadata reference is removed from a project in the host environment.

(Inherited from Workspace)
OnOutputFilePathChanged(ProjectId, String)

Call this method when a project's output file path is changed in the host environment.

(Inherited from Workspace)
OnOutputRefFilePathChanged(ProjectId, String)

Call this method when a project's output ref file path is changed in the host environment.

(Inherited from Workspace)
OnParseOptionsChanged(ProjectId, ParseOptions)

Call this method when a project's parse options are changed in the host environment.

(Inherited from Workspace)
OnProjectAdded(ProjectInfo)

Call this method to respond to a project being added/opened in the host environment.

(Inherited from Workspace)
OnProjectNameChanged(ProjectId, String, String)

Call this method when a project's name is changed in the host environment.

(Inherited from Workspace)
OnProjectReferenceAdded(ProjectId, ProjectReference)

Call this method when a project reference is added to a project in the host environment.

(Inherited from Workspace)
OnProjectReferenceRemoved(ProjectId, ProjectReference)

Call this method when a project reference is removed from a project in the host environment.

(Inherited from Workspace)
OnProjectReloaded(ProjectInfo)

Call this method to respond to a project being reloaded in the host environment.

(Inherited from Workspace)
OnProjectRemoved(ProjectId)

Call this method to respond to a project being removed from the host environment.

(Inherited from Workspace)
OnSolutionAdded(SolutionInfo)

Call this method to respond to a solution being opened in the host environment.

(Inherited from Workspace)
OnSolutionReloaded(SolutionInfo)

Call this method to respond to a solution being reloaded in the host environment.

(Inherited from Workspace)
OnSolutionRemoved()

This method is called when the solution is removed from the workspace.

Override this method if you want to do additional work when the solution is removed. Call the base method at the end of your method. Call this method to respond to a solution being removed/cleared/closed in the host environment.

(Inherited from Workspace)
OnWorkspaceFailed(WorkspaceDiagnostic) (Inherited from Workspace)
OpenAdditionalDocument(DocumentId, Boolean)

Puts the specified additional document into the open state.

OpenAnalyzerConfigDocument(DocumentId, Boolean)

Puts the specified analyzer config document into the open state.

OpenAnalyzerConfigDocument(DocumentId, Boolean)

Open the specified analyzer config document in the host environment.

(Inherited from Workspace)
OpenDocument(DocumentId, Boolean)

Puts the specified document into the open state.

RaiseDocumentActiveContextChangedEventAsync(Document)
Obsolete.
(Inherited from Workspace)
RaiseDocumentActiveContextChangedEventAsync(SourceTextContainer, DocumentId, DocumentId) (Inherited from Workspace)
RaiseDocumentClosedEventAsync(Document) (Inherited from Workspace)
RaiseDocumentOpenedEventAsync(Document) (Inherited from Workspace)
RaiseTextDocumentClosedEventAsync(TextDocument) (Inherited from Workspace)
RaiseTextDocumentOpenedEventAsync(TextDocument) (Inherited from Workspace)
RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind, Solution, Solution, ProjectId, DocumentId) (Inherited from Workspace)
RegisterText(SourceTextContainer)

Register a correspondence between a text container and a workspace.

(Inherited from Workspace)
ScheduleTask(Action, String)

Executes an action as a background task, as part of a sequential queue of tasks.

(Inherited from Workspace)
ScheduleTask<T>(Func<T>, String)

Execute a function as a background task, as part of a sequential queue of tasks.

(Inherited from Workspace)
SetCurrentSolution(Solution)

Sets the CurrentSolution of this workspace. This method does not raise a WorkspaceChanged event.

(Inherited from Workspace)
TryApplyChanges(Solution)

Apply changes made to a solution back to the workspace.

The specified solution must be one that originated from this workspace. If it is not, or the workspace has been updated since the solution was obtained from the workspace, then this method returns false. This method will still throw if the solution contains changes that are not supported according to the CanApplyChange(ApplyChangesKind) method.

(Inherited from Workspace)
UnregisterText(SourceTextContainer)

Unregister a correspondence between a text container and a workspace.

(Inherited from Workspace)
UpdateReferencesAfterAdd()

Updates all projects to properly reference other projects as project references instead of metadata references.

(Inherited from Workspace)

Events

DocumentActiveContextChanged

An event that is fired when the active context document associated with a buffer changes.

(Inherited from Workspace)
DocumentClosed

An event that is fired when a Document is closed in the editor.

(Inherited from Workspace)
DocumentOpened

An event that is fired when a Document is opened in the editor.

(Inherited from Workspace)
TextDocumentClosed

An event that is fired when any TextDocument is closed in the editor.

(Inherited from Workspace)
TextDocumentOpened

An event that is fired when any TextDocument is opened in the editor.

(Inherited from Workspace)
WorkspaceChanged

An event raised whenever the current solution is changed.

(Inherited from Workspace)
WorkspaceFailed

An event raised whenever the workspace or part of its solution model fails to access a file or other external resource.

(Inherited from Workspace)

Applies to