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

Initial cohost server implementation #9674

Merged
merged 26 commits into from
Jan 4, 2024

Conversation

davidwengier
Copy link
Contributor

@davidwengier davidwengier commented Dec 7, 2023

First part of #9519
Razor side of dotnet/roslyn#70819

This PR consumes the new Cohost server from Roslyn, and when enabled, moves DocumentColor requests from being handled by our existing Razor Language Server, to instead be handled by the new server. There is currently no sharing of project system data or anything like that yet. A few TODOs for follow ups, can't be merged, and indeed won't build, until a Roslyn package is available etc. but it's reviewable while we keep working, and more important its shippable in its "off" state.

Ignore the last commit, obviously won't be merged :)

@davidwengier davidwengier force-pushed the RoslynCohost branch 4 times, most recently from 153da8a to 16da9b8 Compare December 10, 2023 23:38
@davidwengier
Copy link
Contributor Author

Copy link
Contributor

@ryzngard ryzngard left a comment

Choose a reason for hiding this comment

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

:shipit:

Some minor musings and questions


namespace Microsoft.AspNetCore.Razor.LanguageServer.DocumentColor;

internal interface IDocumentColorService : ICapabilitiesProvider
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably for another time, but this feels a bit awkward. Should we just move to a central location for capabilities?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally prefer the "each endpoint does its own capabilities" model, but I agree the document service doing it is weird. Ideally the ApplyCapabilities impl would return back to the endpoint, once there is only one.


var serverCapabilities = new VSInternalServerCapabilities();

foreach (var provider in _cohostCapabilitiesProviders)
Copy link
Contributor

Choose a reason for hiding this comment

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

Our capabilities are not any difference right? This is just needed so we can run both cohosting and our current lsp server together?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the capabilities are different: We don't offer the same capability in cohosting and non. They sum together to the full set we support.

This is the place for capabilities to be set in cohosting, and some version of this code will stay. The way it works is that endpoints apply their own capabilities, so as we expose an endpoint to cohosting, via MEF, we remove it from the normal server, but not registering it in DI.

@@ -45,4 +45,6 @@ internal class TestLanguageServerFeatureOptions : LanguageServerFeatureOptions
public override bool IncludeProjectKeyInGeneratedFilePath => _includeProjectKeyInGeneratedFilePath;

public override bool MonitorWorkspaceFolderForConfigurationFiles => _monitorWorkspaceFolderForConfigurationFiles;

public override bool UseRazorCohostServer => throw new System.NotImplementedException();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just go ahead and add an optional constructor param for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So far I've only done it as needed. This was hardoded to return false in another PR to the feature branch

snapshot.DocumentFilePaths,
filePath => Assert.Equal("C:\\Path\\Index.cshtml", filePath),
filePath => Assert.Equal("C:\\Path\\About.cshtml", filePath));
snapshot.DocumentFilePaths.OrderBy(d => d),
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting that this hasn't broken before. I guess just changing the comparer did it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I guess so. Perhaps its stored in hashcode order, and we happened to get lucky with the previous hashcode calculation?

Copy link
Member

@maryamariyan maryamariyan left a comment

Choose a reason for hiding this comment

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

seems like there is a merge conflict on eng/Versions.props

@davidwengier davidwengier merged commit 13d3145 into dotnet:main Jan 4, 2024
12 checks passed
@davidwengier davidwengier deleted the RoslynCohost branch January 4, 2024 04:43
@ghost ghost added this to the Next milestone Jan 4, 2024
@Cosifne Cosifne modified the milestones: Next, 17.10 P1 Jan 30, 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
Development

Successfully merging this pull request may close these issues.

4 participants