@@ -49,5 +49,52 @@ public void TestMethod()
4949 await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
5050 await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
5151 }
52+
53+ [ Fact ]
54+ public async Task TestSpacingAroundColonInCasePatternSwitchLabelAsync ( )
55+ {
56+ const string testCode = @"
57+ public class Foo
58+ {
59+ public void TestMethod()
60+ {
61+ switch (new object())
62+ {
63+ case int a when (a > 0):
64+ case short b when (b > 0) :
65+ case int x:
66+ case short y :
67+ default:
68+ break;
69+ }
70+ }
71+ }" ;
72+ const string fixedCode = @"
73+ public class Foo
74+ {
75+ public void TestMethod()
76+ {
77+ switch (new object())
78+ {
79+ case int a when (a > 0):
80+ case short b when (b > 0):
81+ case int x:
82+ case short y:
83+ default:
84+ break;
85+ }
86+ }
87+ }" ;
88+
89+ DiagnosticResult [ ] expected =
90+ {
91+ this . CSharpDiagnostic ( ) . WithLocation ( 9 , 35 ) . WithArguments ( " not" , "preceded" , string . Empty ) ,
92+ this . CSharpDiagnostic ( ) . WithLocation ( 11 , 22 ) . WithArguments ( " not" , "preceded" , string . Empty ) ,
93+ } ;
94+
95+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
96+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
97+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
98+ }
5299 }
53100}
0 commit comments