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

Snap for 17.12 P2 #10793

Merged
merged 167 commits into from
Aug 27, 2024
Merged

Snap for 17.12 P2 #10793

merged 167 commits into from
Aug 27, 2024

Conversation

dibarbet
Copy link
Member

@dibarbet dibarbet commented Aug 26, 2024

merge main into release/dev17.12 to update for 17.12 P2. Main is 17.12 P3.

davidwengier and others added 30 commits July 25, 2024 17:38
This was done because originally with inlay hints I was changing global options in Roslyn, but ended up moving away from that. Still makes sense though.
Part of dotnet#9519
Needs dotnet/roslyn#74548 before it will compile
Needs
https://devdiv.visualstudio.com/DevDiv/_git/VSLanguageServerClient/pullrequest/567229
before it will work in VS

There were a few side quests on this one:
* Roslyn OOP, at least the way we access it, doesn't have any options
set, so took a few tries to get the Roslyn side of this right for our
needs
* I wrote this feature test-first so only discovered the lack of options
after I modified Roslyn and our test infra to allow us to set global
options, so ended up removing most of that code, Kept the bit about
isolated workspaces because it just makes sense.
* Had to re-write one of the `DocumentMappingService` methods to use
`TextChange` instead of `TextEdit` so I could use Roslyn LSP types
* The hacky, and fortunately temporary, way we were doing generated C#
content was causing cache misses in Roslyn in tests, so fixed that up
* When I finally got up to manual testing I found a bug in the platform
that meant inlay hints just don't work with dynamic registration, so
filed the above linked PR to fix that

If reviewing commit-at-a-time please note that the first commit was
written before the reworking of extension methods and LSP types, and the
fixes for that are in the last commit.
This is an automatically generated pull request from release/dev17.11
into main.


Once all conflicts are resolved and all the tests pass, you are free to
merge the pull request. 🐯

## Troubleshooting conflicts

### Identify authors of changes which introduced merge conflicts
Scroll to the bottom, then for each file containing conflicts copy its
path into the following searches:
- https://github.com/dotnet/razor/find/release/dev17.11
- https://github.com/dotnet/razor/find/main

Usually the most recent change to a file between the two branches is
considered to have introduced the conflicts, but sometimes it will be
necessary to look for the conflicting lines and check the blame in each
branch. Generally the author whose change introduced the conflicts
should pull down this PR, fix the conflicts locally, then push up a
commit resolving the conflicts.

### Resolve merge conflicts using your local repo
Sometimes merge conflicts may be present on GitHub but merging locally
will work without conflicts. This is due to differences between the
merge algorithm used in local git versus the one used by GitHub.
``` bash
git fetch --all
git checkout -t upstream/merges/release/dev17.11-to-main
git reset --hard upstream/main
git merge upstream/release/dev17.11
# Fix merge conflicts
git commit
git push upstream merges/release/dev17.11-to-main --force
```
…rojectCollectionResolver (dotnet#10706)

Started this for dotnet#10688 but saw
that Go To Def used the same service, so figured @DustinCampbell would
need to do the same thing, and thought it would be easier to put it up
separately.

(Unless of course you've already done this, or similar, Dustin in which
case I can just abandon this, nbd)
This change updates `DocumentContext` is several ways:

1. Fields used for caching are now assigned with `Interlocked.Initialize(...)` to ensure that the same value are used in race scenarios.
2. All public async methods now return `ValueTask` rather than `Task`. This has lower overhead since the async methods will return synchronously after the first call.
3. Members are no longer virtual. This appears to have been originally done to allow `DocumentContext` to be mocked for tests, which isn't the right way to handle testing. Instead, since `DocumentContext` delegates its implementation to its `IDocumentSnapshot`, the snapshot should be mocked to change the implementation.
4. The Identifier property has been converted to a method, since it creates a new object every time.
In order to remove `IDocumentContextFactory` from `AbstractRazorDocumentMappingService`, it's necessary to split `IRazorDocumentMappingService` into different services. The goal is to make `IRazorDocumentMappingService` provide APIs that only perform mapping using Roslyn primitives, such as `LinePosition`, `LinePositionSpan`, and `TextChange`. `IEditMappingService` contains an API moved from `IRazorDocumentMappingService` that remaps a `WorkspaceEdit`.
This allows `EditMappingService` and `AbstractRazorDocumentMappingService` to share a helper method.
This change removes `IDocumentContextFactory` from the `AbstracRazorDocumentMappingService` and replaces the single usage with a new protected abstract method.
davidwengier and others added 21 commits August 20, 2024 17:10
See comment in the file, but essentially this is the only way for the code that returns the generated documents syntax tree to be hit in cohosting.
In light of "should we get rid of document context" convo this morning, figured this made sense to do (and I needed _something_ on IDocumentSnapshot in order to actually make this whole idea work)
…x tree (dotnet#10765)

This PR is a classic self-nerd-snipe, and resolves this comment:
dotnet#10750 (comment)

Also inadvertently found a slight "bug" with the existing go to def code
in cohosting. Bug is in quotes because the actual user behaviour
probably was identical in 99% of cases.
* Moving RazorFormattingService to common layer

* Cleanup

* Switch Razor LSP server code to use RazorFormattingService from common layer

* Removing HTML formatting from common layer (for now)

It requires services not easily available and will require extra work. For now leaving it in LSP server layer. Current need for the formatting service in cohosting is for OnAutoInsert which doesn't need HTML formatting.

* Move AdhocServices, AdhoWorkspaceServices to common layer

* Cleanup moved resources

* Basic implementations for remote formatting classes

* Removing hardcoded option value

* Cleanup per CR suggestions

* Cleanup doc-comments
# Conflicts:
#	eng/targets/Services.props
#	src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs
#	src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs
This is an automatically generated pull request from release/dev17.12
into main.


Once all conflicts are resolved and all the tests pass, you are free to
merge the pull request. 🐯

## Troubleshooting conflicts

### Identify authors of changes which introduced merge conflicts
Scroll to the bottom, then for each file containing conflicts copy its
path into the following searches:
- https://github.com/dotnet/razor/find/release/dev17.12
- https://github.com/dotnet/razor/find/main

Usually the most recent change to a file between the two branches is
considered to have introduced the conflicts, but sometimes it will be
necessary to look for the conflicting lines and check the blame in each
branch. Generally the author whose change introduced the conflicts
should pull down this PR, fix the conflicts locally, then push up a
commit resolving the conflicts.

### Resolve merge conflicts using your local repo
Sometimes merge conflicts may be present on GitHub but merging locally
will work without conflicts. This is due to differences between the
merge algorithm used in local git versus the one used by GitHub.
``` bash
git fetch --all
git checkout -t upstream/merges/release/dev17.12-to-main
git reset --hard upstream/main
git merge upstream/release/dev17.12
# Fix merge conflicts
git commit
git push upstream merges/release/dev17.12-to-main --force
```
Because of a dare from @333fred, I'm currently on a crusade to remove
`ItemCollection` from the Razor Compiler completely. Previously, I
removed `ItemCollection` from `TagHelperDescriptorProviderContext`
(dotnet#10720). This time, I'm removing it from `CodeRenderingContext`.

It turns out that every `CodeRenderingContext` greedily creates an
`ItemCollection`, though there are only ever two things stored there:

1. A string to use for new lines in `CodeWriter`.
2. A string representing "suppress IDs", which is already specified in
`RazorCodeGenerationOptions`.

These two items were really present as a hook that compiler tests could
set. However, it's much easier and less wasteful to elevate both items
to `RazorCodeGenerationOptions` and make tests set the options directly.

I made a few other refactorings as part of this change:

- I merged several abstract base classes with their single default
concrete type:
  - `CodeRenderingContext` and `DefaultCodeRenderingContext`
  - `RazorCSharpDocument` and `DefaultRazorCSharpDocument`,
  - `RazorCodeGenerationOptions` and `DefaultRazorCodeGenerationOptions`
- `RazorCodeGenerationOptionsBuilder` and
`DefaultRazorCodeGenerationOptionsBuilder`.
- Reworked `RazorCodeGenerationOptions` and introduced
`RazorCodeGenerationOptionsFlags` to track its boolean fields.
- Cleaned up `RazorCSharpDocument` and unified its collections on
`ImmutableArray<>` rather than `IReadOnlyList<>`.
- Enabled nullability annotations for several types.
- Used more pooled collections in `CodeRenderingContext`.

Note: I was careful with my commit history, and it should be clean
enough to review commit-by-commit if that's your preference.
* When @Inject is missing the member name, generate a syntactically valid c# identifier so we get intellisense
* Emit an empty section when there is no typename
* Add tests and update baselines
Since the end of last week, these tests have been failing. Seems like
something changed on the platform side, perhaps a default value of a
setting. Have started a thread with the editor team to see if we need to
do more.
@dibarbet dibarbet requested review from a team as code owners August 26, 2024 23:01
@dibarbet dibarbet changed the title Snap for 17.12 P3 Snap for 17.12 P2 Aug 27, 2024
@dibarbet dibarbet merged commit fe31c90 into dotnet:release/dev17.12 Aug 27, 2024
12 of 15 checks passed
@dibarbet dibarbet deleted the snap_17_12_p3 branch August 27, 2024 01:55
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.