Граф коммитов

15234 Коммитов

Автор SHA1 Сообщение Дата
Chris Sienkiewicz aa024eb33f
[FUSE] Provide intellisense for @inject directives (#10771)
* 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
2024-08-26 10:14:26 -07:00
Dustin Campbell 3423142c7d
Remove ItemCollection from CodeRenderingContext (#10764)
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`
(#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.
2024-08-22 13:53:35 -07:00
dotnet bot fc8332fdd7
Merge release/dev17.12 to main (#10774)
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
```
2024-08-21 02:32:14 -07:00
dotnet bot d7c7a32b2b
Merge release/dev17.11 to release/dev17.12 (#10767)
This is an automatically generated pull request from release/dev17.11
into release/dev17.12.


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/release/dev17.12

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-release/dev17.12
git reset --hard upstream/release/dev17.12
git merge upstream/release/dev17.11
# Fix merge conflicts
git commit
git push upstream merges/release/dev17.11-to-release/dev17.12 --force
```
2024-08-21 02:01:04 -07:00
David Wengier 2723187736
Cohost Document Symbols (#10728)
Fixes https://github.com/dotnet/razor/issues/10689
Roslyn side: https://github.com/dotnet/roslyn/pull/74730

Looks good, despite the Roslyn side having VS deps for images:

![image](https://github.com/user-attachments/assets/44d2ac8d-f7c1-46ec-9572-15bfd91bed28)
2024-08-21 13:34:46 +10:00
David Wengier 687a473d0d Fix after merge 2024-08-21 11:58:33 +10:00
David Wengier 55c3058eb7 Merge remote-tracking branch 'upstream/main' into CohostDocumentSymbol
# Conflicts:
#	eng/targets/Services.props
#	src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs
#	src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs
2024-08-21 11:55:14 +10:00
David Wengier ca93e0ea0e PR feedback 2024-08-21 11:54:07 +10:00
David Wengier 0bb4e6e55e Bump Roslyn version 2024-08-21 11:53:28 +10:00
Alex Gavrilov d38698fa24
Moving formatting service to common layer (#10761)
* 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
2024-08-21 01:49:14 +00:00
David Wengier acc84f69cf
Allow LSP and cohosting to provide specialized methods to get a syntax tree (#10765)
This PR is a classic self-nerd-snipe, and resolves this comment:
https://github.com/dotnet/razor/pull/10750#discussion_r1719087058

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.
2024-08-21 11:08:49 +10:00
David Wengier a3edec0c8a Move GetSyntaxTree to document snapshot 2024-08-21 10:17:06 +10:00
David Wengier 53fec86c28 Inject file path service into the document snapshot 2024-08-21 09:49:42 +10:00
David Wengier 7d5b2060c6 Remove code document parameter and just use document snapshot 2024-08-21 09:06:50 +10:00
Phil Allen 1d3c82c092
Update NOTICE.txt (#10768) 2024-08-20 13:19:01 -07:00
Fred Silberberg 68650a7d94
Allow @@ as a fallback (#10752)
* Added new tests for the specific regressed scenario.

* Allow `@@` sequences. Fixes https://github.com/dotnet/sdk/issues/42730 for now. When we move to the new lexer, these will once again be disallowed; attempting to use runtime compilation will necessitate using the native lexer.

* Fixup legacy test baselines
2024-08-20 10:50:58 -07:00
Dustin Campbell 934fea83a7 Add comments explaining the aggressive inlining behavior of EnumExtensions 2024-08-20 10:38:02 -07:00
Dustin Campbell b58f180910 Fix goofy whitespace 2024-08-20 10:24:06 -07:00
David Wengier 7470352912 Rework how we get generated documents
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)
2024-08-20 17:11:29 +10:00
David Wengier a8b425907f Directly test the component definition service in cohosting
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.
2024-08-20 17:10:49 +10:00
David Wengier ad16b168df Add missing test case 2024-08-20 17:09:56 +10:00
David Wengier 5ef490fbf3 Defer to C# for component attribute GTD in cohosting
This was a subtle future bug, that we would have hit when we removed the C# syntax tree bits in future. By checking for Razor GTD first we weren't deferring to Roslyn for plain attributes (ie, the case without `@bind-` in the tests) which means at best we do some extra unnecessary work, and at worst we could lose features for things Roslyn supports but we don't.

I did not intend to find this bug when I started. Sorry for missing it in the PR Dustin. The key is that `ignoreAttributes` should have been `true` when porting over the code, and changing that would have made the test fail in your branch.
2024-08-20 17:09:47 +10:00
David Wengier efceb90f2d Allow LSP and cohosting to provide specialized methods to get a syntax tree for a C# document 2024-08-20 17:06:26 +10:00
David Wengier e16582150b
Support component rename from an end tag (#10762)
Fixes https://github.com/dotnet/razor/issues/10717
2024-08-20 10:29:53 +10:00
Dustin Campbell 6593264ac6 Clean up and enable nullability for CodeRenderingContext and DefaultDocumentWriter 2024-08-19 17:16:07 -07:00
Dustin Campbell 7a9f32ea37 Pass RazorSourceDocument into CodeRenderingContext rather than RazorCodeDocument 2024-08-19 16:58:54 -07:00
Dustin Campbell 1eb601c417 Push NewLine setting into RazorCodeGenerationOptions
This change stops pushing the NewLine value into RazorCodeDocument.Items.
2024-08-19 16:58:54 -07:00
Dustin Campbell 28bfd61d38 Use SuppressUniqueIds exclusively from RazorCodeGenerationOptions
This change stops pushing the SuppressUniqueIds value into RazorCodeDocument.Items.
2024-08-19 16:58:54 -07:00
Dustin Campbell 96adc428f7 Collapse RazorCodeGenerationOptions boolean fields to a flags enum 2024-08-19 16:58:49 -07:00
Dustin Campbell 077764960f
Cohosting Support for Go to Definition (#10750)
Fixes #10631

Here's support for Go to Definition under co-hosting. Tests are still
incoming (and I'll add them before merging), but I wanted to get this
out for review to see if there's anything I missed or should implement
differently.
2024-08-19 16:53:32 -07:00
Dustin Campbell dd11c5e0db Clean up RazorCodeGenerationOptions a bit 2024-08-19 16:17:29 -07:00
Jared Parsons 0ff482d029
Dev Container (#10751) 2024-08-19 15:43:03 -07:00
Dustin Campbell 972691bc1e Merge RazorCodeGenerationOptions and DefaultRazorCodeGenerationOptions 2024-08-19 15:37:41 -07:00
Dustin Campbell 03e2d074c0 Merge RazorCodeGenerationOptionsBuilder and DefaultRazorCodeGenerationOptionsBuilder 2024-08-19 15:37:41 -07:00
Dustin Campbell 7ac711be8c Remove ItemCollection from CodeRenderingContext 2024-08-19 15:37:40 -07:00
Dustin Campbell 34507da443 Avoid extra allocations in IntermediateNodeExtensions.GetAllDiagnostics 2024-08-19 15:37:40 -07:00
Dustin Campbell 5072db43b5 Clean up pooled objects in CodeRenderingContext 2024-08-19 15:37:40 -07:00
Dustin Campbell 90f90ef875 Switch RazorCSharpDocument.Diagnostics to an ImmutableArray 2024-08-19 15:37:40 -07:00
Dustin Campbell ff63a4e603 Use pooled ImmutableArray builder for CodeRenderingContext diagnostics 2024-08-19 15:37:39 -07:00
Dustin Campbell c755804389 Swap RazorCSharpDocument.Create methods for constructors 2024-08-19 15:37:39 -07:00
Dustin Campbell 89204d4acf Clean up callers of RazorCSharpDocument.Create(...) 2024-08-19 15:37:39 -07:00
Dustin Campbell d00b1ffab8 Switch CodeRenderingContext.LinePragmas to an ImmutableArray 2024-08-19 15:37:39 -07:00
Dustin Campbell 25acc07be2 Merge RazorCSharpDocument and DefaultRazorCSharpDocument 2024-08-19 15:37:38 -07:00
Dustin Campbell 7ba41799a5 Pool ancestor stack in CodeRenderingContext 2024-08-19 15:37:38 -07:00
Dustin Campbell 635695fefb Pool line pragmas in CodeRenderingContext 2024-08-19 15:37:38 -07:00
Dustin Campbell 86e05ee42c Pool scope stack in CodeRenderingContext 2024-08-19 15:37:38 -07:00
Dustin Campbell 0e1774a4ee Clean up CodeRenderingContext a bit 2024-08-19 15:37:38 -07:00
Dustin Campbell 80d1ed36ee Merge CodeRenderingContext and DefaultCodeRenderingContext 2024-08-19 15:37:38 -07:00
David Wengier a8c3c3626a Use a proper Try pattern 2024-08-20 08:16:02 +10:00
Dustin Campbell 9325817b4e Add tests for co-hosted GTD 2024-08-19 12:57:46 -07:00