[Mono-bugs] [Bug 77040][Nor] New - Instance and class properties handling problem

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Dec 19 18:10:26 EST 2005


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 mono at evain.net.

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

--- shadow/77040	2005-12-19 18:10:26.000000000 -0500
+++ shadow/77040.tmp.25296	2005-12-19 18:10:26.000000000 -0500
@@ -0,0 +1,90 @@
+Bug#: 77040
+Product: Mono: Runtime
+Version: 1.0
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: mono at evain.net               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Instance and class properties handling problem
+
+Mono's Runtime doesn't make a difference between class and instance properties.
+The bug can be reproduced using programs compiled with csc 1.1. (not tested under 2.0)
+
+Compile the following code using csc 1.1:
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+class A {
+
+	string _s = "A";
+
+	public virtual string S {
+		get { return _s; }
+	}
+}
+
+class B : A {
+
+	public override string S {
+		get { return ""; }
+	}
+}
+
+class Test {
+
+	static void Main ()
+	{
+		string t = "Test";
+		AssemblyName name = new AssemblyName ();
+		name.Name = t;
+
+		AssemblyBuilder asm = AppDomain.CurrentDomain.DefineDynamicAssembly (name, 
+AssemblyBuilderAccess.Run);
+		ModuleBuilder mod = asm.DefineDynamicModule (t);
+
+		TypeBuilder type = mod.DefineType ("C", TypeAttributes.Public, typeof (B));
+
+		PropertyBuilder pb = type.DefineProperty ("S",
+			PropertyAttributes.None, typeof (string), new Type[0]);
+			
+		MethodBuilder mb = type.DefineMethod ("get_S", MethodAttributes.Public |
+			MethodAttributes.Virtual | MethodAttributes.HideBySig |
+			MethodAttributes.SpecialName | MethodAttributes.ReuseSlot,
+			typeof (string), new Type [0]);
+		ILGenerator ilg = mb.GetILGenerator ();
+		ilg.Emit (OpCodes.Ret);
+
+		pb.SetSetMethod (mb);
+
+		Type res = type.CreateType ();
+		
+		foreach (PropertyInfo pi in res.GetProperties ())
+			Console.WriteLine (pi.Name);
+	}
+}
+
+run it with mono!
+
+Actual Results:
+It prints one S.
+
+Expected Results:
+.net 1.1 prints two S.
+
+Additional Information:
+When csc emits properties, it sets bit hasThis in the property CallingConvention to 1.
+Both .net S.R.E and Mono S.R.E emits only properties without setting this bit to one.
+So in the example, there is two S properties, one instance property and a class one.
+
+I will attach the compiled program.


More information about the mono-bugs mailing list