Skip to content

Commit 3f5836c

Browse files
committed
Merge pull request #1591 from Noryoko/fix-1585
Fix SA1008 not reported in cref attributes
2 parents 51cab26 + ce8d434 commit 3f5836c

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1008UnitTests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,41 @@ public void TestMethod()
17271727
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
17281728
}
17291729

1730+
/// <summary>
1731+
/// This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#1585:
1732+
/// https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1585
1733+
/// </summary>
1734+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
1735+
[Fact]
1736+
public async Task TestCrefAttributeAsync()
1737+
{
1738+
var testCode = @"
1739+
public class TestClass
1740+
{
1741+
/// <see cref=""Method ()""/>
1742+
public void Method()
1743+
{
1744+
}
1745+
}
1746+
";
1747+
1748+
var fixedCode = @"
1749+
public class TestClass
1750+
{
1751+
/// <see cref=""Method()""/>
1752+
public void Method()
1753+
{
1754+
}
1755+
}
1756+
";
1757+
1758+
var expected = this.CSharpDiagnostic().WithLocation(4, 27).WithArguments(" not", "preceded");
1759+
1760+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
1761+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
1762+
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
1763+
}
1764+
17301765
/// <inheritdoc/>
17311766
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
17321767
{

StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1008OpeningParenthesisMustBeSpacedCorrectly.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private static void HandleCompilationStart(CompilationStartAnalysisContext conte
7777
private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context)
7878
{
7979
SyntaxNode root = context.Tree.GetCompilationUnitRoot(context.CancellationToken);
80-
foreach (var token in root.DescendantTokens().Where(t => t.IsKind(SyntaxKind.OpenParenToken)))
80+
foreach (var token in root.DescendantTokens(descendIntoTrivia: true).Where(t => t.IsKind(SyntaxKind.OpenParenToken)))
8181
{
8282
HandleOpenParenToken(context, token);
8383
}

0 commit comments

Comments
 (0)