File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
ReflectionAnalyzers.Tests/REFL017DontUseNameofTests Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,29 @@ public Bar()
46
46
AnalyzerAssert . Valid ( Analyzer , ExpectedDiagnostic , fooCode , testCode ) ;
47
47
}
48
48
49
+ [ TestCase ( "GetMethod(nameof(IConvertible.ToBoolean))" ) ]
50
+ [ TestCase ( "GetMethod(nameof(IConvertible.ToBoolean), BindingFlags.NonPublic | BindingFlags.Instance)" ) ]
51
+ [ TestCase ( "GetMethod(nameof(IConvertible.ToBoolean), BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)" ) ]
52
+ public void WhenExplicitImplementation ( string call )
53
+ {
54
+ var code = @"
55
+ namespace RoslynSandbox
56
+ {
57
+ using System;
58
+ using System.Reflection;
59
+
60
+ class Foo
61
+ {
62
+ public Foo()
63
+ {
64
+ var methodInfo = typeof(string).GetMethod(nameof(IConvertible.ToBoolean));
65
+ }
66
+ }
67
+ }" . AssertReplace ( "GetMethod(nameof(IConvertible.ToBoolean))" , call ) ;
68
+
69
+ AnalyzerAssert . Valid ( Analyzer , ExpectedDiagnostic , code ) ;
70
+ }
71
+
49
72
[ Test ]
50
73
public void AnonymousTypeNameofInstanceProperty ( )
51
74
{
You can’t perform that action at this time.
0 commit comments