From 427a0256ace322104aac1981e7661c897d275829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kaszab?= <27868208+PeterKaszab@users.noreply.github.com> Date: Sun, 23 Apr 2023 16:49:25 +0200 Subject: [PATCH 1/5] [CLI] Add more about the found diagnostics to the XML output file --- src/CommandLine/Xml/DiagnosticXmlSerializer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CommandLine/Xml/DiagnosticXmlSerializer.cs b/src/CommandLine/Xml/DiagnosticXmlSerializer.cs index ec8f3ab461..68f3f672f6 100644 --- a/src/CommandLine/Xml/DiagnosticXmlSerializer.cs +++ b/src/CommandLine/Xml/DiagnosticXmlSerializer.cs @@ -75,6 +75,8 @@ private static XElement SerializeDiagnostic(DiagnosticInfo diagnostic, IFormatPr new XAttribute("Id", diagnostic.Descriptor.Id), new XElement("Severity", diagnostic.Severity), new XElement("Message", diagnostic.Descriptor.Title.ToString(formatProvider)), + new XElement("Description", diagnostic.Descriptor.Description.ToString(formatProvider)), + new XElement("HelpLink", diagnostic.Descriptor.HelpLinkUri.ToString(formatProvider)), filePathElement, locationElement); } From 228fae652e870a24b84ca7384a62f5b453ccbf8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kaszab?= <27868208+PeterKaszab@users.noreply.github.com> Date: Sun, 23 Apr 2023 16:54:42 +0200 Subject: [PATCH 2/5] Update ChangeLog.md --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index 690fdc4920..2d53e93d49 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - [CLI] Bump Roslyn to 4.5.0 ([#1043](https://github.com/josefpihrt/roslynator/pull/1043)). +- [CLI] Add more about the found diagnostics to the XML output file ([#1078](https://github.com/josefpihrt/roslynator/pull/1078) by @PeterKaszab). ### Fixed From ba21a3c7fedf77b56324d714eb982fc823b48d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kaszab?= <27868208+PeterKaszab@users.noreply.github.com> Date: Sun, 23 Apr 2023 17:07:41 +0200 Subject: [PATCH 3/5] Move Description and HelpLink to summary --- src/CommandLine/Xml/DiagnosticXmlSerializer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CommandLine/Xml/DiagnosticXmlSerializer.cs b/src/CommandLine/Xml/DiagnosticXmlSerializer.cs index 68f3f672f6..d562ef39ec 100644 --- a/src/CommandLine/Xml/DiagnosticXmlSerializer.cs +++ b/src/CommandLine/Xml/DiagnosticXmlSerializer.cs @@ -75,8 +75,6 @@ private static XElement SerializeDiagnostic(DiagnosticInfo diagnostic, IFormatPr new XAttribute("Id", diagnostic.Descriptor.Id), new XElement("Severity", diagnostic.Severity), new XElement("Message", diagnostic.Descriptor.Title.ToString(formatProvider)), - new XElement("Description", diagnostic.Descriptor.Description.ToString(formatProvider)), - new XElement("HelpLink", diagnostic.Descriptor.HelpLinkUri.ToString(formatProvider)), filePathElement, locationElement); } @@ -92,6 +90,8 @@ private static XElement CreateSummary(IEnumerable diagnostics, I "Diagnostic", new XAttribute("Id", f.Key.Id), new XAttribute("Title", f.Key.Title.ToString(formatProvider)), + new XAttribute("Description", f.Key.Description.ToString(formatProvider)), + new XAttribute("HelpLink", f.Key.HelpLinkUri), new XAttribute("Count", f.Count())))); } From 738cb3dd25518835ad171751b1674a94d68b71bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kaszab?= <27868208+PeterKaszab@users.noreply.github.com> Date: Sun, 23 Apr 2023 17:53:06 +0200 Subject: [PATCH 4/5] Add Description and HelpLink as elements --- .../Xml/DiagnosticXmlSerializer.cs | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/CommandLine/Xml/DiagnosticXmlSerializer.cs b/src/CommandLine/Xml/DiagnosticXmlSerializer.cs index d562ef39ec..6cd84ec70a 100644 --- a/src/CommandLine/Xml/DiagnosticXmlSerializer.cs +++ b/src/CommandLine/Xml/DiagnosticXmlSerializer.cs @@ -86,13 +86,30 @@ private static XElement CreateSummary(IEnumerable diagnostics, I diagnostics .GroupBy(f => f.Descriptor, DiagnosticDescriptorComparer.Id) .OrderBy(f => f.Key, DiagnosticDescriptorComparer.Id) - .Select(f => new XElement( - "Diagnostic", - new XAttribute("Id", f.Key.Id), - new XAttribute("Title", f.Key.Title.ToString(formatProvider)), - new XAttribute("Description", f.Key.Description.ToString(formatProvider)), - new XAttribute("HelpLink", f.Key.HelpLinkUri), - new XAttribute("Count", f.Count())))); + .Select(f => SerializeSummaryDiagnosticGroup(f, formatProvider))); + } + + private static XElement SerializeSummaryDiagnosticGroup( + IGrouping group, + IFormatProvider formatProvider) + { + XElement descriptionElement = null; + XElement helpLinkElement = null; + + string descriptionText = group.Key.Description?.ToString(formatProvider); + if (!string.IsNullOrEmpty(descriptionText)) + descriptionElement = new XElement("Description", descriptionText); + + if (!string.IsNullOrEmpty(group.Key.HelpLinkUri)) + helpLinkElement = new XElement("HelpLink", group.Key.HelpLinkUri); + + return new XElement( + "Diagnostic", + new XAttribute("Id", group.Key.Id), + new XAttribute("Title", group.Key.Title.ToString(formatProvider)), + new XAttribute("Count", group.Count()), + descriptionElement, + helpLinkElement); } private static void SerializeDocument(string filePath, XElement summary, params object[] projects) From 9c478fc110cd13b6642dc2a1fcf6fbddde900798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kaszab?= <27868208+PeterKaszab@users.noreply.github.com> Date: Sun, 23 Apr 2023 18:03:29 +0200 Subject: [PATCH 5/5] Update ChangeLog.md --- ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 2d53e93d49..074d8eaa6f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - [CLI] Bump Roslyn to 4.5.0 ([#1043](https://github.com/josefpihrt/roslynator/pull/1043)). -- [CLI] Add more about the found diagnostics to the XML output file ([#1078](https://github.com/josefpihrt/roslynator/pull/1078) by @PeterKaszab). +- [CLI] Add more information about the found diagnostics to the XML output file ([#1078](https://github.com/josefpihrt/roslynator/pull/1078) by @PeterKaszab). ### Fixed