Skip to content

Commit f50ce2e

Browse files
authored
Merge pull request #2231 from vweijsters/fix-2230
Fixed crash in PropertySummaryDocumentationAnalyzer
2 parents 4da56fd + 7364ec9 commit f50ce2e

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1623UnitTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,25 @@ public class TestClass
225225
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
226226
}
227227

228+
/// <summary>
229+
/// Verifies that an empty tag summary is ignored (should be handled by SA1606)
230+
/// This is a regression test for #2230
231+
/// </summary>
232+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
233+
[Fact]
234+
public async Task VerifyEmptySummaryTagIsIgnoredAsync()
235+
{
236+
var testCode = @"
237+
public class TestClass
238+
{
239+
/// <summary/>
240+
public int TestProperty { get; set; }
241+
}
242+
";
243+
244+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
245+
}
246+
228247
/// <inheritdoc/>
229248
protected override CodeFixProvider GetCSharpCodeFixProvider()
230249
{

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1624UnitTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,25 @@ public int TestProperty
185185
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
186186
}
187187

188+
/// <summary>
189+
/// Verifies that an empty tag summary is ignored (should be handled by SA1606)
190+
/// This is a regression test for #2230
191+
/// </summary>
192+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
193+
[Fact]
194+
public async Task VerifyEmptySummaryTagIsIgnoredAsync()
195+
{
196+
var testCode = @"
197+
public class TestClass
198+
{
199+
/// <summary/>
200+
public int TestProperty { get; set; }
201+
}
202+
";
203+
204+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
205+
}
206+
188207
/// <inheritdoc/>
189208
protected override CodeFixProvider GetCSharpCodeFixProvider()
190209
{

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PropertySummaryDocumentationAnalyzer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml
113113
}
114114
}
115115

116-
XmlElementSyntax summaryElement = (XmlElementSyntax)syntax;
116+
XmlElementSyntax summaryElement = syntax as XmlElementSyntax;
117117
if (summaryElement == null)
118118
{
119-
// This is reported by SA1604.
119+
// This is reported by SA1604 or SA1606.
120120
return;
121121
}
122122

0 commit comments

Comments
 (0)