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

Rework how IProjectSnapshotManager is composed into Visual Studio and the Razor Language Server #10063

Merged
merged 15 commits into from
Mar 13, 2024

Conversation

DustinCampbell
Copy link
Member

@DustinCampbell DustinCampbell commented Mar 12, 2024

Fixes #9950
Fixes #9515
Fixes #9514

I recommend reviewing commit by commit.

The primary goal of this pull request is to change how IProjectSnapshotManger is created and how listeners subscribe to it. Primarily, IProjectSnapshotChangeTrigger and IProjectSnapshotManagerAccessor have been removed. To make sure that services previously exported as IProjectSnapshotChangeTriggers are still loaded, I've introduced the notion of an IRazorStartupService. This is a service that is guaranteed to be loaded when Razor tooling is bootstrapped in both the VS and Language Server. Often, these startup services are responsible for keeping the project snapshot manager up-to-date and need to be loaded before any project updates have occurred.

In order to remove IProjectSnapshotManagerAccessor, I needed to re-work several tests to use real Razor tooling objects, rather than mocks. In particular RenameEndpointTest received a lot of attention, though there's still more work that can be done there.

Copy link
Member

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you wanted reviews or not, but...

@DustinCampbell DustinCampbell force-pushed the razor-bootstrap2 branch 4 times, most recently from ba2ed93 to 2bea5b0 Compare March 12, 2024 20:25
@DustinCampbell DustinCampbell marked this pull request as ready for review March 12, 2024 22:49
@DustinCampbell DustinCampbell requested a review from a team as a code owner March 12, 2024 22:49
@DustinCampbell DustinCampbell changed the title [DRAFT] Rework how IProjectSnapshotManager is composed into Visual Studio and the Razor Language Server Rework how IProjectSnapshotManager is composed into Visual Studio and the Razor Language Server Mar 12, 2024
@DustinCampbell
Copy link
Member Author

Gonna do one last rebase on main...

This change removes the implementation and usages of IProjectSnapshotManagerAccessor from the language server. Instead, services can just import an IProjectSnapshotManager. This requires updating more tests to just use tooling components directly, rather than mocking them out. In particular, updating RenameEndpointTest required extra work because the mocks were inconsistent with reality.
This updates DefaultProjectSnapshotManager to stop importing IProjectSnapshotManagerTrigger instances.
This change removes IProjectSnapshotChangeTrigger implementations in the language server and introduces the concept of an IRazorStartupService. Start up services will be created when Razor tooling is started up.
…ger completely

Fixes dotnet#9950

This is a pretty significant change that requires refactoring of how the project snapshot manager is exported within Visual Studio. The IProjectSnapshotManagerAccessor implementations and usages have been completely removed, and IProjectSnapshotChangeTrigger has also been deleted. Now, if a service wants to subscribe to project change events, they can import an IProjectSnapshotManager. And, if that service wants to be loaded when the Razor tooling is boot-strapped, they can export themselves as an IRazorStartupService.
This change updates the VS Razor start up service initialization to include the three entry points that bootstrap Razor tooling:

1. LegacyTextViewConnectionListener: If the legacy editor is enabled and a project is loaded with an editor already opened, Razor tooling bootstraps when a subject buffer is connected.
2. RazorLSPTextViewConnectionListener: If the LSP editor is enabled and a project is loaded with an editor already opened, Razor tooling bootstraps when a subject buffer is connected.
3. WindowsRazorProjectHostBase: If a project is loaded and there aren't any open editors, Razor tooling bootstraps at the first update to the project manager.
These methods just call into IErrorReporter.ReportError(...). Without them, ProjectSnapshotManager no longer needs to take an IErrorReporter in its constructor.
@DustinCampbell
Copy link
Member Author

Gonna do one last rebase on main...

All good now.

Copy link
Member

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@DustinCampbell DustinCampbell merged commit fb04aec into dotnet:main Mar 13, 2024
12 checks passed
@DustinCampbell DustinCampbell deleted the razor-bootstrap2 branch March 13, 2024 22:40
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants