File tree Expand file tree Collapse file tree
ReflectionAnalyzers.Tests/REFL017DontUseNameofTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,6 +46,29 @@ public Bar()
4646 AnalyzerAssert . Valid ( Analyzer , ExpectedDiagnostic , fooCode , testCode ) ;
4747 }
4848
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+
4972 [ Test ]
5073 public void AnonymousTypeNameofInstanceProperty ( )
5174 {
You can’t perform that action at this time.
0 commit comments