dotnet/format

Report does not group `FileChanges` by `DocumentId`

just-ero opened this issue · 0 comments

Version

9.0.100-preview.7.24407.12+d672b8a0459b4888b3e9a6530646e61dd14941b2

Description

The report file created by passing --report indicates that changes should be grouped by file. This is supported by FileChanges being an array. This array consistently only contains 1 item, however, even if the DocumentId matches.

Reproduction

  1. Create or open a C# project.
  2. Add the below code:
    var foo = (int)0;
    var bar = (int)0;
  3. Add the following rule to an .editorconfig file (Cast is redundant):
    dotnet_diagnostic.IDE0004.severity = warning
    
  4. Run dotnet format --report report.json on the project containing the code.

Expected Behavior

The report collects all warnings from the offending file in its FileChanges property:

[
  {
    "DocumentId": {
      "ProjectId": {
        "Id": "c8ac1ffd-ad20-46fe-bf3c-48900b4c79e3"
      },
      "Id": "6960fa6a-fec1-4515-84c9-d8bd515c9a7d"
    },
    "FileName": "Program.cs",
    "FilePath": "...\\Program.cs",
    "FileChanges": [
      {
        "LineNumber": 1,
        "CharNumber": 11,
        "DiagnosticId": "IDE0004",
        "FormatDescription": "warning IDE0004: Cast is redundant."
      },
      {
        "LineNumber": 2,
        "CharNumber": 11,
        "DiagnosticId": "IDE0004",
        "FormatDescription": "warning IDE0004: Cast is redundant."
      }
    ]
  }
]

Actual Behavior

Each warning is in its own entry and FileChanges only has 1 element at all times:

[
  {
    "DocumentId": {
      "ProjectId": {
        "Id": "c8ac1ffd-ad20-46fe-bf3c-48900b4c79e3"
      },
      "Id": "6960fa6a-fec1-4515-84c9-d8bd515c9a7d"
    },
    "FileName": "Program.cs",
    "FilePath": "...\\Program.cs",
    "FileChanges": [
      {
        "LineNumber": 1,
        "CharNumber": 11,
        "DiagnosticId": "IDE0004",
        "FormatDescription": "warning IDE0004: Cast is redundant."
      }
    ]
  },
  {
    "DocumentId": {
      "ProjectId": {
        "Id": "c8ac1ffd-ad20-46fe-bf3c-48900b4c79e3"
      },
      "Id": "6960fa6a-fec1-4515-84c9-d8bd515c9a7d"
    },
    "FileName": "Program.cs",
    "FilePath": "...\\Program.cs",
    "FileChanges": [
      {
        "LineNumber": 2,
        "CharNumber": 11,
        "DiagnosticId": "IDE0004",
        "FormatDescription": "warning IDE0004: Cast is redundant."
      }
    ]
  }
]