dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.04k stars 4.03k forks source link

Rethink Workspace kinds #45728

Open tmat opened 4 years ago

tmat commented 4 years ago

This proposal is an attempt to rethink our approach to workspace customization, which is currently quite ad-hoc.

The core idea is that we should distinguish between two orthogonal customizations: 1) WorkspaceKind and 2) subtyping a Workspace.

WorkspaceKind should be an indicator of the set of services that apply to the workspace. It should determine the MEF composition of services that are available in a specific workspace.

The Workspace subtype on the other hand only customizes how solution is being updated and how changes to the solution are reported via events.

It should be possible to choose these independently.

As a consequence I propose that we remove RemoteWorkspace and TestWorkspace kinds, while keeping RemoteWorkspace and TestWorkspace subtypes.

Removing WorkspaceKind.RemoteWorkspace

The OOP host will create an instance of RemoteWorkspace that subclasses Workspace but with a kind equal to the kind of in-proc workspace that the RemoteWorkspace instance mirrors.

Removing WorkspaceKind.Test

I propose that each test must use a composition of product assemblies that correspond to the layer the test is testing as a baseline. For example, if an editor layer feature is being tested the test should use a composition that consists of compiler, workspace, features and editor features Roslyn assemblies as well as any other product assemblies these depend on in real product (such as Editor assemblies). Tests that need to mock some services would add mock service types into the composition exported with ServiceLayer.Test attribute value, which would override any other service layer/workspace kind.

ServiceHub specific services

ServiceHub would publish OOP-specific services that override in-proc defaults with ServiceLayer.Host. These OOP-overridable services shall not be exported with specific WorkspaceKind since that currently overrides ServiceLayer.Host. Instead these services would be published with ServiceLayer.Editor or ServiceLayer.Default.

tmat commented 4 years ago

@jasonmalinowski @dotnet/roslyn-ide RFC

vatsalyaagrawal commented 4 years ago

@tmat please add milestone as appropriate.

CyrusNajmabadi commented 4 years ago

I'm strongly in support of this. i very much like the idea that we have standardized compositions, and standard workspaces, and test work just by making the right workspace with the right composition.