Skip to content

xunit/xunit#3336: Fix xUnit2023 fixer trivia and indentation#212

Open
LindqvistMartin wants to merge 1 commit into
xunit:mainfrom
LindqvistMartin:fix-xunit2023-fixer-formatting
Open

xunit/xunit#3336: Fix xUnit2023 fixer trivia and indentation#212
LindqvistMartin wants to merge 1 commit into
xunit:mainfrom
LindqvistMartin:fix-xunit2023-fixer-formatting

Conversation

@LindqvistMartin

Copy link
Copy Markdown

Fixes xunit/xunit#3336.

The fixer reused the original invocation and lambda nodes without clearing their trivia, so a // comment on the Assert.Collection got copied onto the generated var line (with its indentation reset to column zero), and a multi-line inspector body kept its old indentation instead of lining up under the new statement.

Stripping the trivia off the reused invocation fixes the comment; normalizing the inspector body fixes the indentation. Added a regression test for a leading comment, a multi-line collection, and a multi-line inspector.

The fixer reused the original invocation and lambda nodes without clearing
their trivia, so a leading comment on the Assert.Collection statement was
copied onto the generated var declaration (and its indentation reset), and a
multi-line inspector body kept its original indentation instead of re-indenting
under the new statement.

Strip the trivia from the reused invocation and normalize the inspector body
before reinserting them.
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.

Issues with the fixer for xUnit2023

1 participant