Repository navigation
[Sonic] Move a few more Razor features to be sonic compatible #84069
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
Merged
+2,975
−1,644
Merged
Changes from 58 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
b7318df
Track declaration Razor C# documents
davidwengier e8b0e11
Unwrap Razor CodeLens resolve data
davidwengier 286c492
Use declaration document for Razor CodeLens
davidwengier a88a999
Add legacy Razor CodeLens tests
davidwengier aef113b
Simplify Razor semantic tokens
davidwengier 17a367c
Make Razor document symbols SONIC-aware
davidwengier f0a760c
Add Razor document symbol SONIC coverage
davidwengier 47254eb
Make Razor selection ranges SONIC-aware
davidwengier 8d16ffc
Add Razor selection range SONIC coverage
davidwengier 7c5c384
Fix CI issues
davidwengier 427e60e
Make Razor spell check SONIC-aware
davidwengier 9f61e1d
Add SONIC spell check tests
davidwengier b546c73
Make Razor inline completion SONIC-aware
davidwengier 3f2934d
Add SONIC inline completion tests
davidwengier e363e6a
Make Razor type hierarchy SONIC-aware
davidwengier e8c348a
Add SONIC type hierarchy tests
davidwengier 5413ad3
Make Razor go to implementation SONIC-aware
davidwengier 495fb29
Add SONIC go to implementation tests
davidwengier 8d540df
Make Razor find all references SONIC-aware
davidwengier bfc7b72
Add SONIC find all references tests
davidwengier b171b00
Move document and edit mapping code up to Remote.Razor
davidwengier 844035f
Move resource
davidwengier c9b000f
Delete unused file
davidwengier db79a4d
Move MEF exports to the real classes, and remove indirection
davidwengier 43d93eb
Rename file
davidwengier 1e8434a
Strongly type and simplify logic, now that there is no abstraction to…
davidwengier 9fa0075
Make edit service and mapping service handle multiple C# documents
davidwengier db803ac
Move document position info code
davidwengier b41ce6b
Remove unused Razor using directive
davidwengier 6b65bbb
Move formatting files up to Remote.Razor
davidwengier 3796b77
Move almost all of FormattingUtilities
davidwengier d60bd03
Move C# formatting options helper back a to shared location
davidwengier e4059b1
Move trigger characters to where they're actually used
davidwengier b63641b
Fix namespaces and usings
davidwengier 8f4a32d
Add IVT
davidwengier e46ed32
Move resources
davidwengier 51db216
Update tests
davidwengier 24d5d26
Move MEF attributes and remote unnecessary indirection
davidwengier 74d6760
Unskip tests
davidwengier 62c0956
Make formatting sonic compatible
davidwengier df11094
Update dependent services so they at least compile
davidwengier a4948b7
Fix "Show Formatting Document" feature
davidwengier 4ec51a3
Unskip tests (and add one)
davidwengier f1cbb12
Remove stale comment
davidwengier e384ef0
Fix benchmark
davidwengier cffd735
Make Razor inlay hints SONIC-aware
davidwengier e5affc8
Add SONIC inlay hint tests
davidwengier d758621
Make Razor folding ranges SONIC-aware
davidwengier 2057517
Add SONIC folding range tests
davidwengier 3eb3b12
Move files from Workspaces to Remote and unify namespaces
davidwengier c9d98ae
Move MEF export
davidwengier bff73ca
Rename file
davidwengier 577e795
Make Razor go to definition SONIC-aware
davidwengier 4c73cf3
Correctness
davidwengier 87ff5ca
[Sonic] Inlay hints, folding ranges, and go to definition (#84102)
davidwengier 11d5cb6
[Sonic] Support multiple C# documents in formatting (#84097)
davidwengier d00caf2
[Sonic] Move edit service up to Remote and make it sonic aware (#84086)
davidwengier f877407
[Sonic] Make even more Razor features to be sonic compatible (#84075)
davidwengier 6f75f9b
Fix grammatical error
davidwengier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
...or/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/RangeComparer.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...r/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/CSharpFormattingOptionsHelper.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Microsoft.CodeAnalysis.CSharp.Formatting; | ||
| using Microsoft.CodeAnalysis.Host; | ||
| using Microsoft.CodeAnalysis.Options; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.Razor.Formatting; | ||
|
|
||
| internal static class CSharpFormattingOptionsHelper | ||
| { | ||
| internal static CSharpSyntaxFormattingOptions GetCSharpSyntaxFormattingOptions( | ||
| SolutionServices services, | ||
| CSharpSyntaxFormattingOptions? csharpSyntaxFormattingOptions) | ||
| { | ||
| csharpSyntaxFormattingOptions | ||
| ??= (CSharpSyntaxFormattingOptions)(services.GetService<ILegacyGlobalOptionsWorkspaceService>()?.GetSyntaxFormattingOptions(services.GetLanguageServices(LanguageNames.CSharp)) | ||
| ?? CSharpSyntaxFormattingOptions.Default); | ||
|
|
||
| return csharpSyntaxFormattingOptions; | ||
| } | ||
|
|
||
| internal static CSharpSyntaxFormattingOptions GetResolvedCSharpSyntaxFormattingOptions( | ||
| SolutionServices services, | ||
| RazorFormattingOptions options, | ||
| CSharpSyntaxFormattingOptions? csharpSyntaxFormattingOptions = null) | ||
| { | ||
| csharpSyntaxFormattingOptions = GetCSharpSyntaxFormattingOptions( | ||
| services, | ||
| csharpSyntaxFormattingOptions ?? options.CSharpSyntaxFormattingOptions); | ||
|
|
||
| return csharpSyntaxFormattingOptions with | ||
| { | ||
| LineFormatting = csharpSyntaxFormattingOptions.LineFormatting with | ||
| { | ||
| UseTabs = !options.InsertSpaces, | ||
| TabSize = options.TabSize, | ||
| IndentationSize = options.TabSize, | ||
| NewLine = CSharpSyntaxFormattingOptions.Default.NewLine | ||
| } | ||
| }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 assume we don't see there being any additional differences needed between decl/impl docs? If there were to be, it might be worth considering whether this could be an abstract base class, having impl and decl derivations.
Uh oh!
There was an error while loading. Please reload this page.
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 think if anything, we could probably simplify this a lot more. The SourceText property used to be the only way to get the C# text, but with cohosting we can get it from the Roslyn solution snapshot. The diagnostics property is weird in sonic, since currently both documents duplicate all diagnostics, so I could see those moving up to RazorCodeDocument. I'm pretty sure linePragmas is only used for tests. Which means a RazorCSharpDocument could become a simple record that just stores source mappings and whether its a declaration document. In fact, I could see an argument for source mappings to store isDeclarationDocument, and have them just be a property on RazorCodeDocument and make this unnecessary altogether. Though I've no idea what impact that would have on the compiler, I'm not as familiar with that codebase.
I definitely still want to improve the architecture here, along with the DocumentContext and DocumentSnapshot stuff, but the longer the sonic feature branch lives, the more stressed I become about conflicts.