Skip to content

Commit d9cad6e

Browse files
authored
Fix analyzer RCS1253 (#1687)
1 parent ff84cfa commit d9cad6e

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
- Fix analyzer [RCS1043](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1043) ([PR](https://github.com/dotnet/roslynator/pull/1684))
2222
- Fix analyzer [RCS1213](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1213) ([PR](https://github.com/dotnet/roslynator/pull/1686))
2323
- Add unity method `OnRectTransformDimensionsChange`
24+
- Fix analyzer [RCS1253](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1253) ([PR](https://github.com/dotnet/roslynator/pull/1687))
2425
- Fix refactoring [Check expression for null](https://josefpihrt.github.io/docs/roslynator/refactorings/RR0024) ([PR](https://github.com/dotnet/roslynator/pull/1682))
2526

2627
## [4.14.0] - 2025-07-26

src/Analyzers/CSharp/Analysis/FormatDocumentationCommentSummaryAnalyzer.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ private static void AnalyzeSingleLineDocumentationCommentTrivia(SyntaxNodeAnalys
9292
if (endTag?.IsMissing == false
9393
&& startTag.GetSpanEndLine() < endTag.GetSpanStartLine())
9494
{
95+
foreach (XmlNodeSyntax node in summaryElement.Content)
96+
{
97+
if (node is XmlElementSyntax xmlElement)
98+
{
99+
switch (xmlElement.GetTag())
100+
{
101+
case XmlTag.Code:
102+
case XmlTag.List:
103+
case XmlTag.Para:
104+
return;
105+
}
106+
}
107+
}
108+
95109
Match match = SingleLineSummaryRegex.Match(
96110
summaryElement.ToString(),
97111
startTag.Span.End - summaryElement.SpanStart,

src/Tests/Analyzers.Tests/RCS1253FormatDocumentationCommentSummaryTests.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ public async Task Test_ToSingleLine()
7777
{
7878
await VerifyDiagnosticAndFixAsync(@"
7979
/// [|<summary>
80-
/// a<code>b</code>c
80+
/// a<c>b</c>c
8181
/// </summary>|]
8282
class C
8383
{
8484
}
8585
", @"
86-
/// <summary>a<code>b</code>c</summary>
86+
/// <summary>a<c>b</c>c</summary>
8787
class C
8888
{
8989
}
@@ -179,6 +179,19 @@ await VerifyNoDiagnosticAsync(@"
179179
class C
180180
{
181181
}
182+
", options: Options.AddConfigOption(ConfigOptionKeys.DocCommentSummaryStyle, ConfigOptionValues.DocCommentSummaryStyle_SingleLine));
183+
}
184+
185+
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.FormatDocumentationCommentSummary)]
186+
public async Task TestNoDiagnostic_ParaElement_ToSingleLine()
187+
{
188+
await VerifyNoDiagnosticAsync(@"
189+
/// <summary>
190+
/// <para>x</para>
191+
/// </summary>
192+
class C
193+
{
194+
}
182195
", options: Options.AddConfigOption(ConfigOptionKeys.DocCommentSummaryStyle, ConfigOptionValues.DocCommentSummaryStyle_SingleLine));
183196
}
184197
}

0 commit comments

Comments
 (0)