Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report does not group FileChanges by DocumentId #2208

Open
just-ero opened this issue Sep 2, 2024 · 0 comments
Open

Report does not group FileChanges by DocumentId #2208

just-ero opened this issue Sep 2, 2024 · 0 comments

Comments

@just-ero
Copy link

just-ero commented Sep 2, 2024

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."
      }
    ]
  }
]
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

No branches or pull requests

1 participant