2008-03-14 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Fri, 14 Mar 2008 18:50:24 +0000 (18:50 -0000)
committerZoltan Varga <vargaz@gmail.com>
Fri, 14 Mar 2008 18:50:24 +0000 (18:50 -0000)
* MonoGenericClass.cs (GetField): Construct a FieldOnTypeBuilderInst object
instead of using GetCorrespondingInflatedField. This is needed so this class can
reflect the changes made to the type builder after initialize () has been called.

svn path=/trunk/mcs/; revision=98330

mcs/class/corlib/System.Reflection/ChangeLog
mcs/class/corlib/System.Reflection/MonoGenericClass.cs

index 24b7cd8ea54e733a4d225b089222cc93dfcabf5c..278f4f85ef21f3a78250ebd8efbdd0b1cc0ed5ca 100644 (file)
@@ -1,5 +1,9 @@
 2008-03-14  Zoltan Varga  <vargaz@gmail.com>
 
+       * MonoGenericClass.cs (GetField): Construct a FieldOnTypeBuilderInst object
+       instead of using GetCorrespondingInflatedField. This is needed so this class can
+       reflect the changes made to the type builder after initialize () has been called.
+
        * Binder.cs (ChangeType): Add support for Char->Double/Single conversations. Fixes
        #367655.
 
index 9f76d5b6cba2c9e6d5dbb20ef8a4adf206658ddc..13c0e83921ffc123d05e5aa600ab0491562e1e01 100644 (file)
@@ -50,8 +50,12 @@ namespace System.Reflection
         */
        internal class MonoGenericClass : MonoType
        {
+               #region Keep in sync with object-internals.h
                protected TypeBuilder generic_type;
                bool initialized;
+               #endregion
+
+               Hashtable fields;
 
                internal MonoGenericClass ()
                        : base (null)
@@ -149,6 +153,17 @@ namespace System.Reflection
                {
                        initialize ();
 
+#if NET_2_0
+                       if (fromNoninstanciated is FieldBuilder) {
+                               FieldBuilder fb = (FieldBuilder)fromNoninstanciated;
+                               if (fields == null)
+                                       fields = new Hashtable ();
+                               if (!fields.ContainsKey (fb))
+                                       fields [fb] = new FieldOnTypeBuilderInst (this, fb);
+                               return (FieldInfo)fields [fb];
+                       }
+#endif
+                       /* Keep the old code for a while in case the code above needs to be reverted */
                        return GetCorrespondingInflatedField (fromNoninstanciated.Name);
                }