Skip to content

Commit

Permalink
Merge pull request #1591 from Noryoko/fix-1585
Browse files Browse the repository at this point in the history
Fix SA1008 not reported in cref attributes
  • Loading branch information
sharwell committed Oct 3, 2015
2 parents 51cab26 + ce8d434 commit 3f5836c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,41 @@ public void TestMethod()
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
}

/// <summary>
/// This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#1585:
/// https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1585
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact]
public async Task TestCrefAttributeAsync()
{
var testCode = @"
public class TestClass
{
/// <see cref=""Method ()""/>
public void Method()
{
}
}
";

var fixedCode = @"
public class TestClass
{
/// <see cref=""Method()""/>
public void Method()
{
}
}
";

var expected = this.CSharpDiagnostic().WithLocation(4, 27).WithArguments(" not", "preceded");

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);
}

/// <inheritdoc/>
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private static void HandleCompilationStart(CompilationStartAnalysisContext conte
private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context)
{
SyntaxNode root = context.Tree.GetCompilationUnitRoot(context.CancellationToken);
foreach (var token in root.DescendantTokens().Where(t => t.IsKind(SyntaxKind.OpenParenToken)))
foreach (var token in root.DescendantTokens(descendIntoTrivia: true).Where(t => t.IsKind(SyntaxKind.OpenParenToken)))
{
HandleOpenParenToken(context, token);
}
Expand Down

0 comments on commit 3f5836c

Please sign in to comment.