Skip to content

Commit 4cda401

Browse files
authored
Merge pull request #2495 from vweijsters/additional-testcase-2494
Added testcase for #2494
2 parents 7579553 + e41a9f6 commit 4cda401

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1009CSharp7UnitTests.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,5 +1041,39 @@ public void TestMethod()
10411041

10421042
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
10431043
}
1044+
1045+
[Fact]
1046+
[WorkItem(2494, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2494")]
1047+
public async Task TestNullableVariableDeclarationAsync()
1048+
{
1049+
var testCode = @"public class TestClass
1050+
{
1051+
public void TestMethod()
1052+
{
1053+
(int a, string b)? testVar1;
1054+
(int a, string b) ? testVar2;
1055+
}
1056+
}
1057+
";
1058+
1059+
var fixedCode = @"public class TestClass
1060+
{
1061+
public void TestMethod()
1062+
{
1063+
(int a, string b)? testVar1;
1064+
(int a, string b)? testVar2;
1065+
}
1066+
}
1067+
";
1068+
1069+
DiagnosticResult[] expectedDiagnostics =
1070+
{
1071+
this.CSharpDiagnostic().WithArguments(" not", "followed").WithLocation(6, 25),
1072+
};
1073+
1074+
await this.VerifyCSharpDiagnosticAsync(testCode, expectedDiagnostics, CancellationToken.None).ConfigureAwait(false);
1075+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
1076+
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
1077+
}
10441078
}
10451079
}

0 commit comments

Comments
 (0)