Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemberInfo.ReflectedType returns wrong reflected type for an event method #13350

Closed
non-conformances-research opened this issue Mar 7, 2019 · 1 comment
Assignees

Comments

@non-conformances-research
Copy link

@non-conformances-research non-conformances-research commented Mar 7, 2019

According to specification of MemberInfo.ReflectedType (https://docs.microsoft.com/en-us/dotnet/api/system.reflection.memberinfo.reflectedtype?view=netcore-2.1), it "gets the class object that was used to obtain this instance of MemberInfo". But using the following program the output is different:

using System;
using System.Reflection;

public class A
{
    public event Action Event { add { } remove { } }
}

public class B : A
{
    public static void Main(string[] args)
    {
        Type type = typeof(B);
        EventInfo eventInfo = type.GetEvent(nameof(A.Event));
        MemberInfo memberInfo = eventInfo.AddMethod;
        Console.WriteLine(memberInfo.ReflectedType);
    }
}

Steps to reproduce:

  1. Compile above program
  2. Run it using mono

Current result:

A

Expected result:

B

On which platforms did you notice this:

[ ] macOS
[X] Linux
[ ] Windows

Version Used:

5.4.1

@MaximLipnin

This comment has been minimized.

Copy link
Collaborator

@MaximLipnin MaximLipnin commented Mar 11, 2019

#10277 related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.