Author: zoltan
Date: 2008-01-21 18:59:45 -0500 (Mon, 21 Jan 2008)
New Revision: 93462

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/reflection.c
Log:
2008-01-22  Zoltan Varga  <[EMAIL PROTECTED]>

        * reflection.c (mono_reflection_create_runtime_class): Remove already 
created
        instantiations from the type cache.


Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2008-01-21 23:18:19 UTC (rev 93461)
+++ trunk/mono/mono/metadata/ChangeLog  2008-01-21 23:59:45 UTC (rev 93462)
@@ -1,3 +1,8 @@
+2008-01-22  Zoltan Varga  <[EMAIL PROTECTED]>
+
+       * reflection.c (mono_reflection_create_runtime_class): Remove already 
created
+       instantiations from the type cache.
+
 2008-01-21 Rodrigo Kumpera  <[EMAIL PROTECTED]>
 
        * verify.c (do_ldstr): fixed token verification. previous code was 100% 
broken.

Modified: trunk/mono/mono/metadata/reflection.c
===================================================================
--- trunk/mono/mono/metadata/reflection.c       2008-01-21 23:18:19 UTC (rev 
93461)
+++ trunk/mono/mono/metadata/reflection.c       2008-01-21 23:59:45 UTC (rev 
93462)
@@ -9431,6 +9431,20 @@
        }
 }
 
+static gboolean
+remove_instantiations_of (gpointer key,
+                                                 gpointer value,
+                                                 gpointer user_data)
+{
+       MonoType *type = (MonoType*)key;
+       MonoClass *klass = (MonoClass*)user_data;
+
+       if ((type->type == MONO_TYPE_GENERICINST) && 
(type->data.generic_class->container_class == klass))
+               return TRUE;
+       else
+               return FALSE;
+}
+
 MonoReflectionType*
 mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb)
 {
@@ -9512,6 +9526,15 @@
        typebuilder_setup_events (klass);
        
        klass->wastypebuilder = TRUE;
+
+       /* 
+        * If we are a generic TypeBuilder, there might be instantiations in 
the type cache
+        * which have type System.Reflection.MonoGenericClass, but after the 
type is created, 
+        * we want to return normal System.MonoType objects, so clear these out 
from the cache.
+        */
+       if (domain->type_hash && klass->generic_container)
+               mono_g_hash_table_foreach_remove (domain->type_hash, 
remove_instantiations_of, klass);
+
        mono_loader_unlock ();
        mono_domain_unlock (domain);
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to