Skip to content

Commit 7e6dfe9

Browse files
committed
Add regression tests for #1834
1 parent f1bf53b commit 7e6dfe9

1 file changed

Lines changed: 43 additions & 1 deletion

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,33 @@ public void Method()
6060
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
6161
}
6262

63+
[Fact]
64+
public async Task TestDocumentationMethodReferenceWithWhitespaceBeforeClosingParenthesisAsync()
65+
{
66+
const string testCode = @"
67+
public class Foo
68+
{
69+
/// <see cref=""Method( )""/>
70+
public void Method()
71+
{
72+
}
73+
}";
74+
const string fixedCode = @"
75+
public class Foo
76+
{
77+
/// <see cref=""Method()""/>
78+
public void Method()
79+
{
80+
}
81+
}";
82+
83+
DiagnosticResult expected = this.CSharpDiagnostic().WithArguments(" not", "preceded").WithLocation(4, 28);
84+
85+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
86+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
87+
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
88+
}
89+
6390
[Fact]
6491
public async Task TestMethodWith2CorrectlySpacedParametersAsync()
6592
{
@@ -656,6 +683,13 @@ public void TestMethod2(
656683
}
657684
658685
public int TestMethod3(int a) { return a; }
686+
687+
public int TestMethod4(string[] args)
688+
{
689+
#if !(X || NOT )
690+
return 1;
691+
#endif
692+
}
659693
}
660694
";
661695

@@ -687,6 +721,13 @@ public void TestMethod2(
687721
}
688722
689723
public int TestMethod3(int a) { return a; }
724+
725+
public int TestMethod4(string[] args)
726+
{
727+
#if !(X || NOT)
728+
return 1;
729+
#endif
730+
}
690731
}
691732
";
692733

@@ -695,7 +736,8 @@ public void TestMethod2(
695736
this.CSharpDiagnostic().WithLocation(10, 9).WithArguments(" not", "preceded"),
696737
this.CSharpDiagnostic().WithLocation(16, 7).WithArguments(" not", "preceded"),
697738
this.CSharpDiagnostic().WithLocation(21, 19).WithArguments(" not", "preceded"),
698-
this.CSharpDiagnostic().WithLocation(25, 17).WithArguments(" not", "preceded")
739+
this.CSharpDiagnostic().WithLocation(25, 17).WithArguments(" not", "preceded"),
740+
this.CSharpDiagnostic().WithLocation(32, 16).WithArguments(" not", "preceded"),
699741
};
700742

701743
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);

0 commit comments

Comments
 (0)