Skip to content

Commit 5c2178b

Browse files
committed
Add DiagnosticId to the format report
1 parent 93a0403 commit 5c2178b

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/Analyzers/AnalyzerFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static void LogDiagnosticLocations(Solution solution, IEnumerable<Diagnostic> di
162162
logger.LogDiagnosticIssue(document, diagnosticPosition, diagnostic, changesAreErrors);
163163
}
164164

165-
formattedFiles.Add(new FormattedFile(document, new[] { new FileChange(diagnosticPosition, $"{diagnostic.Severity.ToString().ToLower()} {diagnostic.Id}: {diagnostic.GetMessage()}") }));
165+
formattedFiles.Add(new FormattedFile(document, new[] { new FileChange(diagnosticPosition, diagnostic.Id, $"{diagnostic.Severity.ToString().ToLower()} {diagnostic.Id}: {diagnostic.GetMessage()}") }));
166166
}
167167
}
168168
}

src/FileChange.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ public class FileChange
1010

1111
public int CharNumber { get; }
1212

13+
public string DiagnosticId { get; }
14+
1315
public string FormatDescription { get; }
1416

15-
public FileChange(LinePosition changePosition, string formatDescription)
17+
public FileChange(LinePosition changePosition, string diagnosticId, string formatDescription)
1618
{
1719
// LinePosition is zero based so we need to increment to report numbers people expect.
1820
LineNumber = changePosition.Line + 1;
1921
CharNumber = changePosition.Character + 1;
22+
DiagnosticId = diagnosticId;
2023
FormatDescription = formatDescription;
2124
}
2225
}

src/Formatters/DocumentFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private ImmutableArray<FileChange> GetFileChanges(FormatOptions formatOptions, D
168168

169169
var changePosition = originalText.Lines.GetLinePosition(change.Span.Start);
170170

171-
var fileChange = new FileChange(changePosition, $"{FormatWarningDescription}{changeMessage}");
171+
var fileChange = new FileChange(changePosition, Name, $"{FormatWarningDescription}{changeMessage}");
172172
fileChanges.Add(fileChange);
173173

174174
if (!formatOptions.SaveFormattedFiles || formatOptions.LogLevel == LogLevel.Debug)

0 commit comments

Comments
 (0)