Skip to content

Commit cdaa845

Browse files
committed
Added test case for multi-line documentation comment for SA1028
1 parent 564fcc5 commit cdaa845

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1028UnitTests.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,51 @@ public async Task TrailingWhitespaceAfterTextTokenAsync()
329329
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
330330
}
331331

332+
/// <summary>
333+
/// Verifies that trailing whitespace after a multi-line documentation comment is handled properly.
334+
/// This is a regression test for #821
335+
/// </summary>
336+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
337+
[Fact]
338+
public async Task VerifyTrailingWhitespaceInsideMultiLineXmlDocumentationCommentAsync()
339+
{
340+
string testCode = new StringBuilder()
341+
.AppendLine("/**")
342+
.AppendLine(" * <summary> ")
343+
.AppendLine(" * Some description ")
344+
.AppendLine(" * </summary> ")
345+
.AppendLine(" */")
346+
.AppendLine("class Foo { }")
347+
.ToString();
348+
349+
string fixedCode = new StringBuilder()
350+
.AppendLine("/**")
351+
.AppendLine(" * <summary>")
352+
.AppendLine(" * Some description")
353+
.AppendLine(" * </summary>")
354+
.AppendLine(" */")
355+
.AppendLine("class Foo { }")
356+
.ToString();
357+
358+
DiagnosticResult[] expected =
359+
{
360+
this.CSharpDiagnostic().WithLocation(2, 13),
361+
this.CSharpDiagnostic().WithLocation(3, 20),
362+
this.CSharpDiagnostic().WithLocation(4, 14)
363+
};
364+
365+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
366+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
367+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
368+
}
369+
370+
/// <inheritdoc/>
332371
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
333372
{
334373
yield return new SA1028CodeMustNotContainTrailingWhitespace();
335374
}
336375

376+
/// <inheritdoc/>
337377
protected override CodeFixProvider GetCSharpCodeFixProvider()
338378
{
339379
return new SA1028CodeFixProvider();

0 commit comments

Comments
 (0)