@@ -96,6 +96,42 @@ public Foo()
96
96
AnalyzerAssert . Valid ( Analyzer , ExpectedDiagnostic , code ) ;
97
97
}
98
98
99
+ [ TestCase ( "GetMethod(nameof(Static), BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly, null, new[] { typeof(int) }, null)" ) ]
100
+ [ TestCase ( "GetMethod(nameof(Static), BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly, null, new[] { i.GetType() }, null)" ) ]
101
+ [ TestCase ( "GetMethod(nameof(Static), BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly, null, new Type[] { typeof(int) }, null)" ) ]
102
+ [ TestCase ( "GetMethod(nameof(Static), BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly, null, new Type[1] { typeof(int) }, null)" ) ]
103
+ [ TestCase ( "GetMethod(nameof(this.Instance), BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, null, new[] { typeof(int) }, null)" ) ]
104
+ [ TestCase ( "GetMethod(nameof(this.Instance), BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, null, new[] { i.GetType() }, null)" ) ]
105
+ [ TestCase ( "GetMethod(nameof(this.Instance), BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, null, new Type[] { typeof(int) }, null)" ) ]
106
+ [ TestCase ( "GetMethod(nameof(this.Instance), BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, null, new Type[1] { typeof(int) }, null)" ) ]
107
+ public void OverloadsFilteredByType ( string call )
108
+ {
109
+ var code = @"
110
+ namespace RoslynSandbox
111
+ {
112
+ using System;
113
+ using System.Reflection;
114
+
115
+ class Foo
116
+ {
117
+ public Foo(int i)
118
+ {
119
+ var methodInfo = typeof(Foo).GetMethod(nameof(Static), BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly, null, new[] { typeof(int) }, null);
120
+ }
121
+
122
+ public static double Static(int value) => value;
123
+
124
+ public static double Static(double value) => value;
125
+
126
+ public int Instance(int value) => value;
127
+
128
+ public double Instance(double value) => value;
129
+ }
130
+ }" . AssertReplace ( "GetMethod(nameof(Static), BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly, null, new[] { typeof(int) }, null)" , call ) ;
131
+
132
+ AnalyzerAssert . Valid ( Analyzer , ExpectedDiagnostic , code ) ;
133
+ }
134
+
99
135
[ TestCase ( "GetMethod(\" Bar\" )" ) ]
100
136
[ TestCase ( "GetMethod(\" Bar\" , BindingFlags.Public | BindingFlags.Instance)" ) ]
101
137
[ TestCase ( "GetMethod(\" Bar\" , BindingFlags.NonPublic | BindingFlags.Instance)" ) ]
0 commit comments