} while (InterlockedCompareExchange (&data->refcount, count, count - 1) != count);
}
-static void
-deregister_reflection_info_roots_nspace_table (gpointer key, gpointer value, gpointer image)
-{
- guint32 index = GPOINTER_TO_UINT (value);
- MonoClass *class = mono_class_get (image, MONO_TOKEN_TYPE_DEF | index);
-
- g_assert (class);
-
- mono_class_free_ref_info (class);
-}
-
-static void
-deregister_reflection_info_roots_name_space (gpointer key, gpointer value, gpointer user_data)
-{
- g_hash_table_foreach (value, deregister_reflection_info_roots_nspace_table, user_data);
-}
-
static void
deregister_reflection_info_roots_from_list (MonoImage *image)
{
No need to take the image lock here since dynamic images are appdomain bound and at this point the mutator is gone.
Taking the image lock here would mean promoting it from a simple lock to a complex lock, which we better avoid if possible.
*/
- if (image->dynamic) {
- if (image->name_cache)
- g_hash_table_foreach (image->name_cache, deregister_reflection_info_roots_name_space, image);
+ if (image->dynamic)
deregister_reflection_info_roots_from_list (image);
- }
+
for (i = 0; i < image->module_count; ++i) {
MonoImage *module = image->modules [i];
- if (module && module->dynamic) {
- if (module->name_cache) {
- g_hash_table_foreach (module->name_cache,
- deregister_reflection_info_roots_name_space, module);
- }
+ if (module && module->dynamic)
deregister_reflection_info_roots_from_list (module);
- }
}
}
mono_domain_assemblies_unlock (domain);
/* Put into cache so mono_class_get () will find it.
Skip nested types as those should not be available on the global scope. */
- if (!tb->nesting_type) {
+ if (!tb->nesting_type)
mono_image_add_to_name_cache (klass->image, klass->name_space, klass->name, tb->table_idx);
- } else {
- mono_image_append_class_to_reflection_info_set (klass);
- }
+
+ /*
+ We must register all types as we cannot rely on the name_cache hashtable since we find the class
+ by performing a mono_class_get which does the full resolution.
+
+ Working around this semantics would require us to write a lot of code for no clear advantage.
+ */
+ mono_image_append_class_to_reflection_info_set (klass);
} else {
g_assert (mono_class_get_ref_info (klass) == tb);
}