diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1506UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1506UnitTests.cs
index 6888ed2d7..c692a90a9 100644
--- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1506UnitTests.cs
+++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1506UnitTests.cs
@@ -548,6 +548,48 @@ public event EventHandler TestEvent2
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
}
+ ///
+ /// Verifies that documentation followed by comments are handled properly.
+ ///
+ /// A representing the asynchronous unit test.
+ [Fact]
+ public async Task TestDocumentationFollowedByCommentAsync()
+ {
+ var testCode = @"
+/// some documentation
+
+// some comment
+public class TestClass
+{
+ /// more documentation.
+
+ // another comment
+ public void TestMethod() { }
+}
+";
+
+ var fixedCode = @"
+/// some documentation
+// some comment
+public class TestClass
+{
+ /// more documentation.
+ // another comment
+ public void TestMethod() { }
+}
+";
+
+ DiagnosticResult[] expected =
+ {
+ this.CSharpDiagnostic().WithLocation(2, 1),
+ this.CSharpDiagnostic().WithLocation(7, 5),
+ };
+
+ await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
+ await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
+ await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
+ }
+
protected override IEnumerable GetCSharpDiagnosticAnalyzers()
{
yield return new SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine();
diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1515UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1515UnitTests.cs
index 7ee102b49..7fc3fd96d 100644
--- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1515UnitTests.cs
+++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1515UnitTests.cs
@@ -186,6 +186,27 @@ public async Task TestPreprocessorInteractionAsync()
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}
+ ///
+ /// Verifies the analyzer will properly handle documentation followed by a comment.
+ ///
+ /// A representing the asynchronous unit test.
+ [Fact]
+ public async Task TestDocumentationFollowedByCommentAsync()
+ {
+ var testCode = @"
+/// some documentation
+// some comment
+public class TestClass
+{
+ /// more documentation.
+ // another comment
+ public void TestMethod() { }
+}
+";
+
+ await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
+ }
+
///
protected override IEnumerable GetCSharpDiagnosticAnalyzers()
{