Skip to content

fix: preserve blank lines before csharpier-ignore comments#1868

Merged
belav merged 4 commits into
belav:mainfrom
nkgotcode:fix/oss-784-csharpier-ignore-blank-lines
Jun 5, 2026
Merged

fix: preserve blank lines before csharpier-ignore comments#1868
belav merged 4 commits into
belav:mainfrom
nkgotcode:fix/oss-784-csharpier-ignore-blank-lines

Conversation

@nkgotcode

Copy link
Copy Markdown
Contributor

Summary

Fixes #1867

Preserves leading blank-line trivia for ignored statement nodes when formatting files that use // csharpier-ignore comments, and adds regression tests.

Test plan

  • Updated CSharpierIgnore expected snapshots
  • Added LineEndingEdgeCase coverage
  • dotnet test on CSharpier.Tests

Closes #1867

Made with Cursor

Fixes belav#1867

Preserve leading blank-line trivia for ignored statement nodes and add
regression coverage for csharpier-ignore formatting edge cases.
@nkgotcode
nkgotcode force-pushed the fix/oss-784-csharpier-ignore-blank-lines branch from 7912fdc to d21f902 Compare June 4, 2026 22:57
return statements;
}

public static Doc PrintNodeWithoutFormatting(SyntaxNode syntaxNode, PrintingContext context)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three methods have almost the same name and I have no idea what the difference between them is and when to call which method.

}

[Test]
public async Task CSharpier_Ignore_Preserves_Preceding_Blank_Line()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests have no reason to be in this class if all they are doing is ensuring that a blank line is not removed. That is what the csharpierignore.test file is for.

@nkgotcode

Copy link
Copy Markdown
Contributor Author

Pushed e177a63: renamed the unformatted-print helpers to distinguish Doc wrapping from raw code normalization, and moved the blank-line regression cases into Src/CSharpier.Tests/FormattingTests/TestFiles/cs/CSharpierIgnore.test / .expected.test. I could not run dotnet test in this container because the repo pins SDK 10.0.201 and only 8.0.421 is installed here.

@belav
belav merged commit bc8987b into belav:main Jun 5, 2026
7 checks passed
@nkgotcode
nkgotcode deleted the fix/oss-784-csharpier-ignore-blank-lines branch June 5, 2026 14:49
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.

[Bug]: csharpier-ignore comment removes linespaces before block

2 participants