Skip to content

Commit bc6bb96

Browse files
authored
Merge pull request #2811 from pdelvo/sa1642codeFixImprovement
Improve SA1642 to work better with single-line empty elements
2 parents 4de63e9 + 5f00c93 commit bc6bb96

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1642SA1643CodeFixProvider.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ private static Task<Document> GetTransformedDocumentAsync(Document document, Syn
149149

150150
var newContent = RemoveMalformattedStandardText(node.Content, typeDeclaration.Identifier, standardText[0], standardText[1], ref trailingString);
151151

152+
if (newContent.Count == 1 && newContent[0] is XmlTextSyntax xmlText)
153+
{
154+
if (string.IsNullOrWhiteSpace(xmlText.ToString()))
155+
{
156+
newContent = default;
157+
}
158+
}
159+
152160
var list = BuildStandardTextSyntaxList(typeDeclaration, newLineText, standardText[0], standardText[1] + trailingString);
153161
newContent = newContent.InsertRange(0, list);
154162

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1642UnitTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ public ClassName()
940940
public class ClassName
941941
{{
942942
/// <summary>
943-
/// Initializes a new instance of the <see cref=""ClassName""/> class.{emptyContent}</summary>
943+
/// Initializes a new instance of the <see cref=""ClassName""/> class.</summary>
944944
public ClassName()
945945
{{
946946
}}

0 commit comments

Comments
 (0)