Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Noryoko committed Aug 7, 2015
1 parent 1a40d62 commit 93b1374
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,19 +285,42 @@ public async Task TestCommentFollowedByMultiLineDocumentationCommentAsync()
{
var testCode = @"// some comment
/* <summary>Test summary.</summary> */
/** <summary>Test summary.</summary> */
public class TestClass
{
// another comment
/* <summary>Test summary.</summary> */
/** <summary>Test summary.</summary> */
public void TestMethod() { }
}
";

await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

/// <summary>
/// Verifies that the analyzer will properly handle comments followed by multi-line comments.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact]
public async Task TestCommentFollowedByMultiLineCommentAsync()
{
var testCode = @"namespace TestNamespace {
// some comment
/* multi-line comment */
internal class TestClass
{
// another comment
/* another multi-line comment */
}
}
";

await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

/// <inheritdoc/>
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,17 @@ private void HandleSyntaxTreeAnalysis(SyntaxTreeAnalysisContext context, Immutab
}
else
{
if ((triviaIndex < triviaList.Count) && triviaList[triviaIndex].IsKind(SyntaxKind.SingleLineCommentTrivia))
if (triviaIndex < triviaList.Count)
{
// ignore a single blank line in between two single line comments.
continue;
switch (triviaList[triviaIndex].Kind())
{
case SyntaxKind.SingleLineCommentTrivia:
case SyntaxKind.SingleLineDocumentationCommentTrivia:
case SyntaxKind.MultiLineCommentTrivia:
case SyntaxKind.MultiLineDocumentationCommentTrivia:
// ignore a single blank line in between two comments.
continue;
}
}
}

Expand Down

0 comments on commit 93b1374

Please sign in to comment.