Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Proposal: Allow creating custom Workspace classes #76433

Open
grokys opened this issue Dec 14, 2024 · 2 comments
Open

API Proposal: Allow creating custom Workspace classes #76433

grokys opened this issue Dec 14, 2024 · 2 comments
Labels
Area-IDE Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@grokys
Copy link

grokys commented Dec 14, 2024

Background and Motivation

The Workspace API is currently essentially closed to extension. The AdhocWorkspace and MSBuildWorkspace classes are sealed and while one can derive from Workspace itself, trying to implement a basic Workspace by copying the code for AdhocWorkspace won't work because said class uses internal APIs.

Given that there are a number of Workspace implementations in the Roslyn codebase itself, I'm sure that you can appreciate that being able to implement/extend Workspace is valuable. Looking though old issues, it looks like Workspace was originally intended to be extensible.

Proposed API

Either remove sealed from AdhocWorkspace (and maybe MSBuildWorkspace?) or provide a new abstract AbstractCustomWorkspace class which implements the parts which require internal APIs.

Alternative Designs

It's entirely possible that I'm missing something here and that this is already possible. An alternative solution would be to document/provide a sample of how to implement a custom workspace on top of Workspace with existing APIs.

Risks

More API surface for the Roslyn team to maintain ;)

@grokys grokys added Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request labels Dec 14, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 14, 2024
@CyrusNajmabadi
Copy link
Member

Extending Workspace itself should be possible. If that doesn't work, let us know what API is blocking you.

@grokys
Copy link
Author

grokys commented Dec 19, 2024

let us know what API is blocking you.

I did link to one internal API in the original description, but these are the internal APIs used in AdhocWorkspace:

  • TextDocument.GetTextSynchronously
  • TextDocument.GetTextVersionSynchronously

These seem to be needed in order to get the SourceText in OpenDocument, in order to create a SourceTextContainer to pass to OnDocumentOpened: GetTextAsync can't be used as OpenDocument is not async.

Unless there's an alternative API I should be using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

2 participants