Bugzilla – Bug 319645
[PATCH] EventInfo.ReflectedType returns declaring type instead
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by dean@brettle.com 2005-11-26 16:52:12 MST ---- Description of Problem: Here's a very small test case: using System; using System.Reflection; class Base { public event EventHandler EventInBase; } class Derived : Base { public event EventHandler EventInDerived; } class MainClass { public static void Main(string[] args) { Derived o = new Derived(); Type t = o.GetType(); MemberInfo[] memberInfos = t.GetEvents(); foreach (MemberInfo mi in memberInfos) { Console.WriteLine(mi.Name + ": ReflectedType = " + mi.ReflectedType); } } } Actual Results: EventInDerived: ReflectedType = Derived EventInBase: ReflectedType = Base Expected Results: EventInDerived: ReflectedType = Base EventInBase: ReflectedType = Base How often does this happen? Everytime Additional Information: I'm running mono 1.1.10-2 ---- Additional Comments From robertj@gmx.net 2005-11-28 19:36:43 MST ---- The expected result is EventInDerived: ReflectedType = Derived EventInBase: ReflectedType = Derived because ReflectedType is the type that was used to obtain the member info, which is "Derived" in your sample. ---- Additional Comments From dean@brettle.com 2005-11-28 20:24:53 MST ---- Duh. Yeah, that's what I meant to say... :-) Sorry for the confusion. ---- Additional Comments From robertj@gmx.net 2005-11-29 23:22:56 MST ---- --> runtime ---- Additional Comments From robertj@gmx.net 2005-11-29 23:28:23 MST ---- It's a runtime issue. I'm attaching a patch. ---- Additional Comments From robertj@gmx.net 2005-11-29 23:29:13 MST ---- Created an attachment (id=168888) icall.c.diff ---- Additional Comments From robertj@gmx.net 2005-11-30 16:22:53 MST ---- Created an attachment (id=168889) ReflectedTypeTest.cs (Unit Tests for ReflectedType) ---- Additional Comments From robertj@gmx.net 2005-11-30 16:32:26 MST ---- The unit test checks RelectedType for all MemberInfo types. I found it useful because every GetXyz internal call has its own different implementation. The test is suitable to be commited to mcs/class/corlib/Test/System.Reflection/ ---- Additional Comments From miguel@ximian.com 2005-12-02 16:27:21 MST ---- I think this patch is fine, I assume you tested that this does not introduce a regression. Could you commit with a ChangeLog entry? ---- Additional Comments From robertj@gmx.net 2005-12-02 17:26:48 MST ---- Fixed in SVN. Imported an attachment (id=168888) Imported an attachment (id=168889) Unknown operating system unknown. Setting to default OS "Other".