[Mono-bugs] [Bug 80344][Nor] Changed - GetMembers behaviour does not match MS with BindingFlags.FlattenHierarchy

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Dec 24 05:25:53 EST 2006


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 rolfkvinge at ya.com.

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

--- shadow/80344	2006-12-23 20:02:30.000000000 -0500
+++ shadow/80344.tmp.5554	2006-12-24 05:25:53.000000000 -0500
@@ -58,6 +58,71 @@
 
 The real problem seems to be that MS.NET implies DeclaredOnly while
 Mono doesn't: if you change the flags to 
 Public | Instance | DeclaredOnly, the test case succeeds on both
 runtimes.
 
+
+------- Additional Comments From rolfkvinge at ya.com  2006-12-24 05:25 -------
+I do not want to specify DeclaredOnly, this test case might clearify:
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Text;
+
+class Base {
+	public int P1 {get { return 1; }}
+	public int P2 {get { return 2; }}
+}
+
+class Derived : Base {
+	public new int P1 { get { return -1; }}
+	public new int GetHashCode () { }
+}
+
+
+class vbnc_bugs {
+	public const BindingFlags flags = BindingFlags.Public | 
+BindingFlags.Instance;
+	
+	static void Main ()
+	{
+		Type t = typeof(Derived);
+		MemberInfo [] members = t.GetMembers (flags);
+
+		foreach (MemberInfo m in members) {
+			Console.WriteLine (m.MemberType.ToString () + 
+" " + m.DeclaringType.FullName + ":" + m.Name);
+		}
+	}
+}
+
+Output on MS:
+Method Derived:get_P1
+Method Derived:GetHashCode
+Method Base:get_P1
+Method Base:get_P2
+Method System.Object:GetType
+Method System.Object:ToString
+Method System.Object:Equals
+Method System.Object:GetHashCode
+Constructor Derived:.ctor
+Property Derived:P1
+Property Base:P2
+
+Output on Mono:
+Constructor Derived:.ctor
+Method Derived:get_P1
+Method Derived:GetHashCode
+Method Base:get_P1
+Method Base:get_P2
+Method System.Object:Equals
+Method System.Object:GetHashCode
+Method System.Object:GetType
+Method System.Object:ToString
+Property Derived:P1
+Property Base:P1
+Property Base:P2
+
+The property Base:P1 is returned on Mono, but not on MS. 
+Looks like MS won't return hidden base properties.


More information about the mono-bugs mailing list