Open
Description
Assembly referenced through a binary (compiled) metadata reference:
internal interface IFoo
{
object Bar { get; }
}
public class Foo : IFoo
{
internal object Bar { get; }
object IFoo.Bar => Bar;
}
Assembly with analyzer gives erroneous REFL041. This is probably because it can't see internal members, so it makes the invalid assumption that GetProperty must be targeting IFoo.Bar
rather than the Foo.Bar
that may or may not be there:
class C
{
void M()
{
Delegate.CreateDelegate(
// REFL041 Delegate type is not matching expected Func<IFoo, object>
// ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
typeof(Func<Foo, object>),
typeof(Foo).GetProperty("Bar", BindingFlags.NonPublic | BindingFlags.Instance).GetMethod);
}
}
However, this form does not give REFL041. Potentially a second bug where these two forms are not seen as equivalent:
class C
{
void M()
{
Delegate.CreateDelegate(
typeof(Func<Foo, object>),
typeof(Foo).GetMethod("get_Bar", BindingFlags.NonPublic | BindingFlags.Instance));
}
}
Metadata
Metadata
Assignees
Labels
No labels