Skip to content

Commit 8ba637b

Browse files
committed
Test REFL014 #94
1 parent ef2c7af commit 8ba637b

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

ReflectionAnalyzers.Tests/REFL014PreferGetMemberThenAccessorTests/CodeFix.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,41 @@ public Foo()
287287
var message = $"Prefer typeof(Foo).{after}.";
288288
AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic.WithMessage(message), code, fixedCode);
289289
}
290+
291+
[Test]
292+
//// ReSharper disable once InconsistentNaming
293+
public void IEnumeratorGetCurrent()
294+
{
295+
var code = @"
296+
namespace RoslynSandbox
297+
{
298+
using System.Collections;
299+
300+
public class Foo
301+
{
302+
public void Meh(object value)
303+
{
304+
_ = typeof(IEnumerator).GetMethod(""get_Current"");
305+
}
306+
}
307+
}";
308+
var fixedCode = @"
309+
namespace RoslynSandbox
310+
{
311+
using System.Collections;
312+
using System.Reflection;
313+
314+
public class Foo
315+
{
316+
public void Meh(object value)
317+
{
318+
_ = typeof(IEnumerator).GetProperty(nameof(IEnumerator.Current), BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).GetMethod;
319+
}
320+
}
321+
}";
322+
323+
var message = "Prefer typeof(IEnumerator).GetProperty(nameof(IEnumerator.Current), BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).GetMethod.";
324+
AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic.WithMessage(message), code, fixedCode);
325+
}
290326
}
291327
}

ReflectionAnalyzers.Tests/REFL016UseNameofTests/ValidCode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public class Generic<T>
127127
}
128128

129129
[Test]
130-
// ReSharper disable once InconsistentNaming
130+
//// ReSharper disable once InconsistentNaming
131131
public void IEnumeratorGetCurrent()
132132
{
133133
var testCode = @"

0 commit comments

Comments
 (0)