[Mono-bugs] [Bug 73973][Wis] New - different results for reflection of overriden properties

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 22 Mar 2005 11:23:04 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by sebastien@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=73973

--- shadow/73973	2005-03-22 11:23:04.000000000 -0500
+++ shadow/73973.tmp.8865	2005-03-22 11:23:04.000000000 -0500
@@ -0,0 +1,93 @@
+Bug#: 73973
+Product: Mono: Runtime
+Version: 1.1
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sebastien@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: different results for reflection of overriden properties
+
+Description of Problem:
+
+Mono and MS runtime don't reflect properties (and maybe other stuff too)
+the same way when memebers are overridden.
+
+This means that the most simple calls, e.g. Type.GetProperty (string),
+which are the ones most likely to be used, can fail on MS runtime (while
+running ok on Mono).
+
+
+Steps to reproduce the problem:
+1. Compile this sample code
+
+using System;
+using System.Reflection;
+using System.Threading;
+
+public class TestWaitHandle : WaitHandle {
+	public override IntPtr Handle {
+		get { return base.Handle; }
+		set { base.Handle = value; }
+	}
+}
+
+class Program {
+
+	static void Main ()
+	{
+		BindingFlags bf = BindingFlags.Instance | BindingFlags.Public |
+BindingFlags.DeclaredOnly; 
+		Type t = typeof (TestWaitHandle);
+		PropertyInfo pi = t.GetProperty ("Handle", bf);
+
+		if (pi == null)
+			Console.WriteLine ("NOT FOUND with {0}", bf);
+		else
+			Console.WriteLine ("found with {0}", bf);
+
+		try {
+			pi = t.GetProperty ("Handle");
+
+			if (pi == null)
+				Console.WriteLine ("NOT FOUND with no BindingFlags");
+			else
+				Console.WriteLine ("found with no BindingFlags");
+		}
+		catch (AmbiguousMatchException) {
+			Console.WriteLine ("AmbiguousMatchException with no BindingFlags");
+		}
+	}
+}
+
+2. Execute on Mono runtime (I used HEAD)
+3. Execute on MS runtime
+
+Actual Results (mono runtime):
+
+% mono reflprop.exe
+found with DeclaredOnly, Instance, Public
+found with no BindingFlags
+
+
+Expected Results (MS runtime):
+
+> reflprop
+found with DeclaredOnly, Instance, Public
+AmbiguousMatchException with no BindingFlags
+
+
+How often does this happen? 
+Always
+
+
+Additional Information:
+It seems Mono's reflection doesn't track overrides like the MS runtime.