File tree Expand file tree Collapse file tree
ReflectionAnalyzers.Tests/REFL003MemberDoesNotExistTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -220,6 +220,27 @@ public MethodInfo Bar<T>()
220220 AnalyzerAssert . Valid ( Analyzer , ExpectedDiagnostic , code ) ;
221221 }
222222
223+ [ Test ]
224+ public void GetGenericMethod ( )
225+ {
226+ var code = @"
227+ namespace RoslynSandbox
228+ {
229+ using System.Reflection;
230+
231+ public class Foo
232+ {
233+ public Foo()
234+ {
235+ _ = typeof(Foo).GetMethod(nameof(Foo.Id), BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
236+ }
237+
238+ public T Id<T>(T value) => value;
239+ }
240+ }" ;
241+ AnalyzerAssert . Valid ( Analyzer , ExpectedDiagnostic , code ) ;
242+ }
243+
223244 [ TestCase ( "get_Bar" ) ]
224245 [ TestCase ( "set_Bar" ) ]
225246 public void GetPropertyMethods ( string name )
Original file line number Diff line number Diff line change 1+ namespace ValidCode
2+ {
3+ using System . Reflection ;
4+
5+ public class GenericMember
6+ {
7+ public GenericMember ( )
8+ {
9+ _ = typeof ( GenericMember ) . GetMethod ( nameof ( GenericMember . Id ) , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ;
10+ }
11+
12+ public T Id < T > ( T value ) => value ;
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments