Skip to content

Commit 004a9e7

Browse files
committed
Confirm REFL017 does not nag when explicit implementation. Fix #90.
1 parent a5a1313 commit 004a9e7

File tree

1 file changed

+23
-0
lines changed
  • ReflectionAnalyzers.Tests/REFL017DontUseNameofTests

1 file changed

+23
-0
lines changed

ReflectionAnalyzers.Tests/REFL017DontUseNameofTests/ValidCode.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff 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
{

0 commit comments

Comments
 (0)