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

Allow Razor to format a new document it wants to create #69878

Merged
merged 2 commits into from
Sep 14, 2023

Conversation

davidwengier
Copy link
Contributor

@davidwengier davidwengier commented Sep 11, 2023

Part of dotnet/razor#4330

Goes with dotnet/razor#9263 and dotnet/vscode-csharp#6329

Adds a custom endpoint so Razor can get access to the INewDocumentFormattingService, as well as remove and sort usings, and format the new document with the current C# format options.

@davidwengier
Copy link
Contributor Author

Ping @dotnet/razor-tooling @dotnet/roslyn-ide for reviews if you please
image

@davidwengier davidwengier merged commit 91f67f3 into dotnet:main Sep 14, 2023
22 of 24 checks passed
@ghost ghost added this to the Next milestone Sep 14, 2023
@davidwengier davidwengier deleted the RazorNewDocumentFormat branch September 14, 2023 07:45
davidwengier added a commit to dotnet/razor that referenced this pull request Sep 14, 2023
Fixes #4330
Fixes #8766
Includes #9262 so just review from
8a2b8af
onwards

Goes with dotnet/roslyn#69878 and
dotnet/vscode-csharp#6329

I logged #9264 to follow up with a
better test, though strictly speaking the one I've added id exhaustive
:)

Behaviour of Extract to Code Behind before this change. Note the many
using statements and block scoped namespace.

![ExtractToCodeBehindBefore](https://github.com/dotnet/razor/assets/754264/10ac5595-b3b2-44c2-a1a7-66664d3c8f1b)

Behaviour after this change. Note the file scoped namespace, and file
header.

![ExtractToCodeBehindAfter](https://github.com/dotnet/razor/assets/754264/65160715-bc98-4336-b19d-37f9b14adf94)

The squiggle on `NavigationManager` is due to an `.editorconfig` rule I
have on in that project, requiring `this.` qualification, so is
unrelated.
@Cosifne Cosifne modified the milestones: Next, 17.8 P3 Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants