-
Notifications
You must be signed in to change notification settings - Fork 196
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
Cohosting OnAutoInsert endpoint #10776
Conversation
src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/AutoInsert/OnAutoInsertEndpoint.cs
Outdated
Show resolved
Hide resolved
...src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoClosingTagOnAutoInsertProvider.cs
Outdated
Show resolved
Hide resolved
...src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoClosingTagOnAutoInsertProvider.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoInsertService.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/InsertTextEdit.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RemoteAdhocWorkspaceFactory.cs
Show resolved
Hide resolved
...soft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnAutoInsertEndpoint.cs
Outdated
Show resolved
Hide resolved
...soft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnAutoInsertEndpoint.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm requesting a few changes:
- Please don't add extension methods for converting between Roslyn LSP types and VS LSP types directly. It is intentional that the
VsLspExtensions
andRoslynLspExtensions
methods never mix to make it easier to removeVsLspExtensions
later in Use Roslyn LSP library instead of Visual Studio #10682. See my comments below for guidance on what to do in each case. - I'm uncomfortable with the change to
IDocumentSnapshot
andDocumentSnapshot
. There is almost certainly a better abstraction then adding a method intended for formatting directly ontoIDocumentSnapshot
. - The
FrozenSet<T>
usage in this PR needs a second look.FrozenSet<T>
is not a designed to be the new workhorse class for sets. In fact, it is much more expensive to construct aFrozenSet<T>
because it performs up-front analysis to determine the best strategy. So, frozen sets should be reserved for use as static data. And, for arrays of 1 or 2 single character strings, aFrozenSet<string>
is completely contrived. It's a trivial task to write something faster by hand to perform aContains(...)
test. In addition, there's a lot of code using the frozen sets in this PR that cause unnecessary allocations by boxed their struct enumerators. I tried to add guidance throughout my feedback, but I'm happy to chat about this further offline. Or, we could make it a topic at the next Razor "code talk about" meeting.
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoInsertService.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoInsertService.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoInsertService.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IOnAutoInsertProvider.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IAutoInsertService.cs
Outdated
Show resolved
Hide resolved
.../Microsoft.AspNetCore.Razor.LanguageServer/Hosting/VSInternalServerCapabilitiesExtensions.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs
Outdated
Show resolved
Hide resolved
....LanguageServices.Razor/LanguageClient/Cohost/CohostOnAutoInsertTriggerCharacterProviders.cs
Outdated
Show resolved
Hide resolved
.../Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/OnAutoInsertEndpointTest.NetFx.cs
Show resolved
Hide resolved
...r/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/OnAutoInsertEndpointTest.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IOnAutoInsertProvider.cs
Outdated
Show resolved
Hide resolved
...crosoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/RazorOnAutoInsertProviderTestBase.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/AutoInsert/OnAutoInsertEndpoint.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a second review pass through the latest changes.
...src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoClosingTagOnAutoInsertProvider.cs
Outdated
Show resolved
Hide resolved
.../Microsoft.AspNetCore.Razor.LanguageServer/Hosting/VSInternalServerCapabilitiesExtensions.cs
Show resolved
Hide resolved
.../Microsoft.AspNetCore.Razor.LanguageServer/Hosting/VSInternalServerCapabilitiesExtensions.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/AutoInsert/OnAutoInsertEndpoint.cs
Show resolved
Hide resolved
...src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoClosingTagOnAutoInsertProvider.cs
Show resolved
Hide resolved
...soft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/CloseTextTagOnAutoInsertProviderTest.cs
Show resolved
Hide resolved
...ft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/AutoClosingTagOnAutoInsertProviderTest.cs
Outdated
Show resolved
Hide resolved
...r/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/OnAutoInsertEndpointTest.cs
Outdated
Show resolved
Hide resolved
...crosoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/RazorOnAutoInsertProviderTestBase.cs
Show resolved
Hide resolved
...crosoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/RazorOnAutoInsertProviderTestBase.cs
Outdated
Show resolved
Hide resolved
FYI that formatting tests are failing in CI for this PR. Not sure if you've taken a look at them yet. |
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ImportDocumentSnapshot.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ImportDocumentSnapshot.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like approving the PR with no tests for cohosting, but as there are tests for ensuring the existing bits don't break, I think it's okay to make an exception. Plus I'm waiting on this to merge so I can get my PR in and finish cohost formatting.
I expect I'll probably end up coming through and cleaning up a few things in this area anyway, since I won't be able to stop myself.
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoInsertService.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IAutoInsertService.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IOnAutoInsertProvider.cs
Outdated
Show resolved
Hide resolved
...zor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingCodeDocumentProvider.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingContext.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentSnapshot.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like approving the PR with no tests for cohosting, but as there are tests for ensuring the existing bits don't break, I think it's okay to make an exception. Plus I'm waiting on this to merge so I can get my PR in and finish cohost formatting.
I expect I'll probably end up coming through and cleaning up a few things in this area anyway, since I won't be able to stop myself.
src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Mapping/RazorLanguageQueryEndpoint.cs
Show resolved
Hide resolved
…rt/AutoClosingTagOnAutoInsertProvider.cs Co-authored-by: David Wengier <david.wengier@microsoft.com>
…rt/IAutoInsertService.cs Co-authored-by: David Wengier <david.wengier@microsoft.com>
…rt/InsertTextEdit.cs Co-authored-by: David Wengier <david.wengier@microsoft.com>
Creating IFormattingCodeDocumentProvider service with seprate LSP and Remote implementations to provide code document appropriate for formatting.
Extension methods can't be used for Mock setups, so since I made GetGeneratedOutputAsync() with no parameter an extension method, I had to switch unit tests to use GeGeneratedOutputAsync(It.Any<bool>())
9719aad
to
7715a4c
Compare
We still had non-parameter GetGeneratedOutputAsycnc in DocumentSnapshot (even though it wasn't in IDocumentSnapshot) which was getting called internally. That was both messy (since there is now no-parameter extension method on IDocumentSnapshot) and was causing issues in tests
Summary of the changes
Fixes:
Part of #9519
Notes:
All auto-insert scenarios should be addressed now (Razor, HTML, C#)
Tests will be added in a separate PR since this one has grown large and long enough as it is.