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

Cohosting OnAutoInsert endpoint #10776

Merged
merged 64 commits into from
Aug 29, 2024
Merged

Conversation

alexgav
Copy link
Contributor

@alexgav alexgav commented Aug 22, 2024

Summary of the changes

  • Cohosting endpoint for auto-insert endpoint.

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.

@alexgav alexgav requested a review from a team as a code owner August 22, 2024 02:35
Copy link
Member

@DustinCampbell DustinCampbell left a 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:

  1. Please don't add extension methods for converting between Roslyn LSP types and VS LSP types directly. It is intentional that the VsLspExtensions and RoslynLspExtensions methods never mix to make it easier to remove VsLspExtensions later in Use Roslyn LSP library instead of Visual Studio #10682. See my comments below for guidance on what to do in each case.
  2. I'm uncomfortable with the change to IDocumentSnapshot and DocumentSnapshot. There is almost certainly a better abstraction then adding a method intended for formatting directly onto IDocumentSnapshot.
  3. 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 a FrozenSet<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, a FrozenSet<string> is completely contrived. It's a trivial task to write something faster by hand to perform a Contains(...) 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.

Copy link
Member

@DustinCampbell DustinCampbell left a 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.

@DustinCampbell
Copy link
Member

FYI that formatting tests are failing in CI for this PR. Not sure if you've taken a look at them yet.

Copy link
Contributor

@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 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.

Copy link
Contributor

@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 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.

alexgav and others added 19 commits August 29, 2024 09:49
…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>())
@alexgav alexgav force-pushed the dev/alexgav/CohostingOnAutoInsertEndpoint branch from 9719aad to 7715a4c Compare August 29, 2024 16:50
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
@alexgav alexgav merged commit 12f5194 into main Aug 29, 2024
12 checks passed
@alexgav alexgav deleted the dev/alexgav/CohostingOnAutoInsertEndpoint branch August 29, 2024 18:27
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Aug 29, 2024
@phil-allen-msft phil-allen-msft modified the milestones: Next, 17.12 P3 Oct 31, 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