@@ -521,7 +521,55 @@ public void Test()
521
521
[ InlineData ( "Method1" , "Const1" , false ) ]
522
522
[ InlineData ( "Method2" , "Const1" , false ) ]
523
523
[ WorkItem ( 3677 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3677" ) ]
524
- public async Task TestMethodsAsync ( string expr1 , string expr2 , bool shouldTrigger )
524
+ public async Task TestSimpleMethodsAsync ( string expr1 , string expr2 , bool shouldTrigger )
525
+ {
526
+ await this . TestMethodAsync ( expr1 , expr2 , shouldTrigger ) . ConfigureAwait ( false ) ;
527
+ }
528
+
529
+ [ Theory ]
530
+ [ InlineData ( "TestClass.Method1" , "arg" , true ) ]
531
+ [ InlineData ( "this.Method2" , "arg" , true ) ]
532
+ [ InlineData ( "TestClass.Method1" , "field1" , true ) ]
533
+ [ InlineData ( "this.Method2" , "field1" , true ) ]
534
+ [ InlineData ( "TestClass.Method1" , "field2" , true ) ]
535
+ [ InlineData ( "this.Method2" , "field2" , true ) ]
536
+ [ InlineData ( "Const1" , "TestClass.Method1" , false ) ]
537
+ [ InlineData ( "Const1" , "this.Method2" , false ) ]
538
+ [ InlineData ( "TestClass.Method1" , "Const1" , false ) ]
539
+ [ InlineData ( "this.Method2" , "Const1" , false ) ]
540
+ [ InlineData ( "Method3<int>" , "arg" , true ) ]
541
+ [ InlineData ( "TestClass.Method3<int>" , "arg" , true ) ]
542
+ [ WorkItem ( 3759 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3759" ) ]
543
+ public async Task TestComplexMethodsAsync ( string expr1 , string expr2 , bool shouldTrigger )
544
+ {
545
+ await this . TestMethodAsync ( expr1 , expr2 , shouldTrigger ) . ConfigureAwait ( false ) ;
546
+ }
547
+
548
+ [ Theory ]
549
+ [ InlineData ( "==" ) ]
550
+ [ InlineData ( "!=" ) ]
551
+ [ InlineData ( ">=" ) ]
552
+ [ InlineData ( "<=" ) ]
553
+ [ InlineData ( ">" ) ]
554
+ [ InlineData ( "<" ) ]
555
+ [ WorkItem ( 3759 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3759" ) ]
556
+ public async Task TestComplexLeftHandSideExpressionAsync ( string @operator )
557
+ {
558
+ var testCode = $@ "
559
+ using System;
560
+ public class TypeName
561
+ {{
562
+ public void Test(int x, int y, Func<int> a)
563
+ {{
564
+ var r1 = x + 1 { @operator } y;
565
+ var r2 = -x { @operator } y;
566
+ var r3 = a() { @operator } y;
567
+ }}
568
+ }}" ;
569
+ await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
570
+ }
571
+
572
+ private async Task TestMethodAsync ( string expr1 , string expr2 , bool shouldTrigger )
525
573
{
526
574
var testExpr = $ "{ expr1 } == { expr2 } ";
527
575
var testCode = $@ "
@@ -546,6 +594,10 @@ private static void Method1()
546
594
private void Method2()
547
595
{{
548
596
}}
597
+
598
+ private static void Method3<T>()
599
+ {{
600
+ }}
549
601
}}
550
602
" ;
551
603
@@ -572,6 +624,10 @@ private static void Method1()
572
624
private void Method2()
573
625
{{
574
626
}}
627
+
628
+ private static void Method3<T>()
629
+ {{
630
+ }}
575
631
}}
576
632
" ;
577
633
0 commit comments