-
Notifications
You must be signed in to change notification settings - Fork 196
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
Keep whitespace in extract to code behind #9262
Merged
davidwengier
merged 10 commits into
dotnet:main
from
davidwengier:BetterExtractToCodeBehind
Sep 12, 2023
Merged
Keep whitespace in extract to code behind #9262
davidwengier
merged 10 commits into
dotnet:main
from
davidwengier:BetterExtractToCodeBehind
Sep 12, 2023
Conversation
This file contains 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
Calling NormalizeWhitespace is the lazy way to not have to worry about trivia when using SyntaxFactory, but it also destroys any formatting the user might have done. Better to use the actual formatter to fix indentation and things, and just generate the code as a string. Using syntax factory wasn't really helping too much.
Just to make sure the formatter is doing the right thing
The invalid C# code annoyed me :P
Turns out this test was invalid, and this behaviour is not possible to do on our side. The good news is the old code was just as wrong, and I have a better solution in the works :)
DustinCampbell
approved these changes
Sep 11, 2023
Comment on lines
187
to
188
.GetDocumentIntermediateNode() | ||
.FindDescendantNodes<UsingDirectiveIntermediateNode>(); |
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.
nit: indentation
ghost
added this to the Next milestone
Sep 12, 2023
davidwengier
added a commit
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #8750
The main fix here is to not use NormalizeWhitespace, but the formatter instead, as the former clobbers too much of the users code. Commit-at-a-time is probably the way to go, to see how the test output changes (or doesn't 😛)