dotnet / format

Home for the dotnet-format command

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No deterministic result between Linux and Windows for Whitespace check

Herve-M opened this issue · comments

Context

Linux

  • dotnet --info
.NET SDK:
 Version:           8.0.100
 Commit:            57efcf1350
 Workload version:  8.0.100-manifests.6c33ef20

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/8.0.100/

Host:
  Version:      8.0.0
  Architecture: x64
  Commit:       5535e31a71
  • dotnet format --version: 8.0.453106+2651752953c0d41c8c7b8d661cf2237151af33d0

Windows

  • dotnet --info
.NET SDK:
 Version:           8.0.100
 Commit:            57efcf1350
 Workload version:  8.0.100-manifests.8d38d0cc

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100\

Host:
  Version:      8.0.0
  Architecture: x64
  Commit:       5535e31a71
  • dotnet format --version: 8.0.453106+2651752953c0d41c8c7b8d661cf2237151af33d0

Testing code

tests/projects/for_code_formatter/unformatted_project

Output

Current (extract)

cmd used: dotnet format unformatted_project.csproj --verify-no-changes --report test-{os}.json

Linux

{
    "DocumentId": {
      "ProjectId": {
        "Id": "dc560f51-7e85-446e-b9bd-1851c5297bc5"
      },
      "Id": "2b916861-f979-4513-8985-e273e92a5465"
    },
    "FileName": "OtherClass.cs",
    "FilePath": "/for_code_formatter/unformatted_project/other_items/OtherClass.cs",
    "FileChanges": [
      {
        "LineNumber": 4,
        "CharNumber": 2,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Replace 6 characters with \u0027\\n\\s\\s\u0027."
      },
      {
        "LineNumber": 5,
        "CharNumber": 18,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Replace 6 characters with \u0027\\n\\s\\s\u0027."
      },
      {
        "LineNumber": 6,
        "CharNumber": 6,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Replace 10 characters with \u0027\\n\\s\\s\\s\\s\u0027."
      },
      {
        "LineNumber": 7,
        "CharNumber": 40,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Replace 10 characters with \u0027\\n\\s\\s\\s\\s\u0027."
      },
      {
        "LineNumber": 8,
        "CharNumber": 10,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Replace 14 characters with \u0027\\n\\s\\s\\s\\s\\s\\s\u0027."
      },
      {
        "LineNumber": 9,
        "CharNumber": 47,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Replace 10 characters with \u0027\\n\\s\\s\\s\\s\u0027."
      },
      {
        "LineNumber": 10,
        "CharNumber": 10,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Replace 6 characters with \u0027\\n\\s\\s\u0027."
      }
    ]
  },

Windows

{
    "DocumentId": {
      "ProjectId": {
        "Id": "fafc9893-b6ef-427a-87fe-9d14f5e35909"
      },
      "Id": "cdba3da3-6199-4537-97ef-c1c29214a626"
    },
    "FileName": "OtherClass.cs",
    "FilePath": "for_code_formatter\\unformatted_project\\other_items\\OtherClass.cs",
    "FileChanges": [
      {
        "LineNumber": 5,
        "CharNumber": 3,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Delete 2 characters."
      },
      {
        "LineNumber": 6,
        "CharNumber": 3,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Delete 2 characters."
      },
      {
        "LineNumber": 7,
        "CharNumber": 5,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Delete 4 characters."
      },
      {
        "LineNumber": 8,
        "CharNumber": 5,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Delete 4 characters."
      },
      {
        "LineNumber": 9,
        "CharNumber": 7,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Delete 6 characters."
      },
      {
        "LineNumber": 10,
        "CharNumber": 5,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Delete 4 characters."
      },
      {
        "LineNumber": 11,
        "CharNumber": 3,
        "DiagnosticId": "WHITESPACE",
        "FormatDescription": "Fix whitespace formatting. Delete 2 characters."
      }
    ]
  },

Expected

  • Line & Offset should match between OS
  • FormatDescription should be same

After re-searching found the solution in #1955, end_of_line = crlf is currently commented making the diff.