Skip to content

format and check disagree on blank lines after #endif preprocessor directive #1836

@mmisiek137

Description

@mmisiek137

Description

dotnet csharpier format . leaves a double blank line after #endif, but dotnet csharpier check . flags it as unformatted -- expecting a single blank line. This makes CI checks fail on code the formatter itself produced.

Reproduction

Given this file:

using Newtonsoft.Json;
#if NET472
using System.Windows.Markup;
#endif


namespace TestLib
{
  1. Run dotnet csharpier format . -- file is unchanged (double blank line stays)
  2. Run dotnet csharpier check . -- reports the file as not formatted, expects single blank line
Error ./TestData.cs - Was not formatted.
  ----------------------------- Expected: Around Line 12 -----------------------------

  namespace TestLib
  {
  ----------------------------- Actual: Around Line 12 -----------------------------


  namespace TestLib

Expected behavior

format and check should produce consistent results. Either format should remove the extra blank line, or check should not flag it.

Version

CSharpier 1.2.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions