Skip to content

Commit 1204682

Browse files
committed
Merge pull request #1763 from vweijsters/fix-1001
Added multi-line comment XML documentation test for SA1004
2 parents 7d97301 + acb256e commit 1204682

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1004UnitTests.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,58 @@ private void Method3()
166166
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
167167
}
168168

169+
/// <summary>
170+
/// Verifies that a multi-line documentation comment without leading spaces is handled correctly.
171+
/// </summary>
172+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
173+
[Fact]
174+
public async Task TestMultilineDocumentationCommentWithoutLeadingSpacesAsync()
175+
{
176+
string testCode = @"
177+
public class TypeName
178+
{
179+
/**
180+
*<summary>
181+
* The summary text.
182+
*</summary>
183+
* <param name=""x"">The document root.</param>
184+
* <param name=""y"">The XML header token.</param>
185+
*/
186+
private void Method1(int x, int y)
187+
{
188+
}
189+
}
190+
";
191+
192+
string fixedCode = @"
193+
public class TypeName
194+
{
195+
/**
196+
* <summary>
197+
* The summary text.
198+
* </summary>
199+
* <param name=""x"">The document root.</param>
200+
* <param name=""y"">The XML header token.</param>
201+
*/
202+
private void Method1(int x, int y)
203+
{
204+
}
205+
}
206+
";
207+
208+
DiagnosticResult[] expected =
209+
{
210+
this.CSharpDiagnostic().WithLocation(5, 7),
211+
this.CSharpDiagnostic().WithLocation(7, 7),
212+
this.CSharpDiagnostic().WithLocation(8, 7),
213+
this.CSharpDiagnostic().WithLocation(9, 7)
214+
};
215+
216+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
217+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
218+
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
219+
}
220+
169221
/// <inheritdoc/>
170222
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
171223
{

0 commit comments

Comments
 (0)