Skip to content

Commit a86a962

Browse files
authored
[CLI] Add more information about the found diagnostics to the XML output file (#1078)
1 parent 4a99e26 commit a86a962

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111

1212
- [CLI] Bump Roslyn to 4.5.0 ([#1043](https://github.com/josefpihrt/roslynator/pull/1043)).
13+
- [CLI] Add more information about the found diagnostics to the XML output file ([#1078](https://github.com/josefpihrt/roslynator/pull/1078) by @PeterKaszab).
1314

1415
### Fixed
1516

src/CommandLine/Xml/DiagnosticXmlSerializer.cs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,30 @@ private static XElement CreateSummary(IEnumerable<DiagnosticInfo> diagnostics, I
8686
diagnostics
8787
.GroupBy(f => f.Descriptor, DiagnosticDescriptorComparer.Id)
8888
.OrderBy(f => f.Key, DiagnosticDescriptorComparer.Id)
89-
.Select(f => new XElement(
90-
"Diagnostic",
91-
new XAttribute("Id", f.Key.Id),
92-
new XAttribute("Title", f.Key.Title.ToString(formatProvider)),
93-
new XAttribute("Count", f.Count()))));
89+
.Select(f => SerializeSummaryDiagnosticGroup(f, formatProvider)));
90+
}
91+
92+
private static XElement SerializeSummaryDiagnosticGroup(
93+
IGrouping<DiagnosticDescriptor, DiagnosticInfo> group,
94+
IFormatProvider formatProvider)
95+
{
96+
XElement descriptionElement = null;
97+
XElement helpLinkElement = null;
98+
99+
string descriptionText = group.Key.Description?.ToString(formatProvider);
100+
if (!string.IsNullOrEmpty(descriptionText))
101+
descriptionElement = new XElement("Description", descriptionText);
102+
103+
if (!string.IsNullOrEmpty(group.Key.HelpLinkUri))
104+
helpLinkElement = new XElement("HelpLink", group.Key.HelpLinkUri);
105+
106+
return new XElement(
107+
"Diagnostic",
108+
new XAttribute("Id", group.Key.Id),
109+
new XAttribute("Title", group.Key.Title.ToString(formatProvider)),
110+
new XAttribute("Count", group.Count()),
111+
descriptionElement,
112+
helpLinkElement);
94113
}
95114

96115
private static void SerializeDocument(string filePath, XElement summary, params object[] projects)

0 commit comments

Comments
 (0)