dotnet / dotnet/format

Report does not group `FileChanges` by `DocumentId`

Open
#2,208 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
1.9k
Forks
173
Avg merge
10d 13h
Merged PRs (30d)
1

Description

### 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:
```cs
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:
```json
[
{
"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:
```json
[
{
"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."
}
]
}
]
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.