[Mono-bugs] [Bug 23946] Changed - Convert.ChangeType fails on TypeBuilder-created types

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
29 Apr 2002 19:26:51 -0000


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 martin@gnome.org.

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

--- shadow/23946	Mon Apr 29 15:17:28 2002
+++ shadow/23946.tmp.11794	Mon Apr 29 15:26:51 2002
@@ -39,6 +39,39 @@
 
 
 ------- Additional Comments From martin@gnome.org  2002-04-29 15:17 -------
 This problem only exists when compiling with --nostdlib.
 Changed priority to Critical since it prevents us from compiling
 corlib with mcs.
+
+------- Additional Comments From martin@gnome.org  2002-04-29 15:26 -------
+There's another problem with this:
+
+You cannot call FieldBuilder.SetConstant() for a constant with a 
+user-defined type - so `default_value' must be of the "real" system 
+type (typeof (int)).
+
+So if we were doing this correctly, we would
+
+a.) Fix the Convert.ChangeType() to set `default_value's type
+    to the new TypeBuilder generated System.Int32 type
+
+b.) Call FieldBuilder.SetConstant (default_value) where the
+    FieldBuilder is using the new type as well.
+
+This doesn't work - FieldBuilder.SetConstant () throws an exception 
+if it's called with an user defined type.
+
+So we need to
+
+a'.) Convert `default_value' to the "real" system type (it already
+     has that type if it's 0).
+
+b'.) Use the "real" system type for TypeBuilder.DefineField() to
+     create a constant of the system type.
+
+c'.) Call FieldBuilder.SetConstant(default_value).
+
+However - won't it be easier to use the "real" types for
+TypeBuilder.int_type etc. ?
+
+Martin