@@ -110,5 +110,46 @@ public async Task TestDeconstructionInTopLevelProgramAsync(string prefix)
110110 FixedCode = fixedCode ,
111111 } . RunAsync ( CancellationToken . None ) . ConfigureAwait ( false ) ;
112112 }
113+
114+ [ Fact ]
115+ [ WorkItem ( 3968 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3968" ) ]
116+ public async Task TestLogicalPatternsWithParenthesesAsync ( )
117+ {
118+ const string testCode = @"
119+ class C
120+ {
121+ void M(int value)
122+ {
123+ _ = value is not{|#0:(|}> 0);
124+ _ = value is > 0 and{|#1:(|}< 5);
125+ _ = value is > 0 and {|#2:(|} < 5);
126+ _ = value is > 10 or{|#3:(|}< 5);
127+ _ = value is > 10 or {|#4:(|} < 5);
128+ }
129+ }" ;
130+
131+ const string fixedCode = @"
132+ class C
133+ {
134+ void M(int value)
135+ {
136+ _ = value is not (> 0);
137+ _ = value is > 0 and (< 5);
138+ _ = value is > 0 and (< 5);
139+ _ = value is > 10 or (< 5);
140+ _ = value is > 10 or (< 5);
141+ }
142+ }" ;
143+
144+ DiagnosticResult [ ] expected =
145+ {
146+ Diagnostic ( DescriptorPreceded ) . WithLocation ( 0 ) ,
147+ Diagnostic ( DescriptorPreceded ) . WithLocation ( 1 ) ,
148+ Diagnostic ( DescriptorNotFollowed ) . WithLocation ( 2 ) ,
149+ Diagnostic ( DescriptorPreceded ) . WithLocation ( 3 ) ,
150+ Diagnostic ( DescriptorNotFollowed ) . WithLocation ( 4 ) ,
151+ } ;
152+ await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
153+ }
113154 }
114155}
0 commit comments