Bug 319645 (MONO76829) - [PATCH] EventInfo.ReflectedType returns declaring type instead
Summary: [PATCH] EventInfo.ReflectedType returns declaring type instead
Status: RESOLVED FIXED
Alias: MONO76829
Product: Mono: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Paolo Molaro
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-26 23:52 UTC by Dean Brettle
Modified: 2007-09-15 21:24 UTC (History)
1 user (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
icall.c.diff (970 bytes, patch)
2005-11-30 06:29 UTC, Thomas Wiest
Details | Diff
ReflectedTypeTest.cs (Unit Tests for ReflectedType) (4.25 KB, text/plain)
2005-11-30 23:22 UTC, Thomas Wiest
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:39:22 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".