Skip to content

Commit

Permalink
Add test for nameof(Containing.Member) when public.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanLarsson committed Apr 26, 2020
1 parent 86b8a38 commit ea13f85
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions ReflectionAnalyzers.Tests/REFL016UseNameofTests/CodeFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,5 +473,56 @@ class C : BaseClass

RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, new[] { baseClass, before }, after);
}

[Test]
public static void InNestedType()
{
var @base = @"
namespace N
{
class Base
{
public void M1() { }
}
}";

var before = @"
namespace N
{
using System;
using System.Reflection;
class C : Base
{
class Nested
{
void M2()
{
typeof(Base).GetMethod(↓""M1"");
}
}
}
}";

var after = @"
namespace N
{
using System;
using System.Reflection;
class C : Base
{
class Nested
{
void M2()
{
typeof(Base).GetMethod(nameof(Base.M1));
}
}
}
}";

RoslynAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, new[] { @base, before }, after);
}
}
}

0 comments on commit ea13f85

Please sign in to comment.