2009-11-04 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Wed, 4 Nov 2009 13:36:19 +0000 (13:36 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 4 Nov 2009 13:36:19 +0000 (13:36 -0000)
* reflection.c (fieldref_encode_signature): If field_image is NULL then
the token is already properly encoded. Fixs 4.0 build.

svn path=/trunk/mono/; revision=145396

mono/metadata/ChangeLog
mono/metadata/reflection.c

index 97175929963876951bfc61c8aa8c7c3545e8b8ba..ad1aeb693bdfbefc7a062e509050fab9b8abad66 100644 (file)
@@ -1,3 +1,8 @@
+2009-11-04  Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * reflection.c (fieldref_encode_signature): If field_image is NULL then
+       the token is already properly encoded. Fixs 4.0 build.
+
 2009-11-04  Rolf Bjarne Kvinge  <RKvinge@novell.com>
 
        * locales.c (construct_number_format): Check if the number index is
index 14ba7f91da67c88a3843edcc3ea36eab03750a3e..fa290ed805fe25b857190fae23c3978521a64d32 100644 (file)
@@ -1622,7 +1622,7 @@ static guint32
 fieldref_encode_signature (MonoDynamicImage *assembly, MonoImage *field_image, MonoType *type)
 {
        SigBuffer buf;
-       guint32 idx, i;
+       guint32 idx, i, token;
 
        if (!assembly->save)
                return 0;
@@ -1633,12 +1633,20 @@ fieldref_encode_signature (MonoDynamicImage *assembly, MonoImage *field_image, M
        /* encode custom attributes before the type */
        if (type->num_mods) {
                for (i = 0; i < type->num_mods; ++i) {
-                       MonoClass *class = mono_class_get (field_image, type->modifiers [i].token);
+                       if (field_image) {
+                               MonoClass *class = mono_class_get (field_image, type->modifiers [i].token);
+                               g_assert (class);
+                               token = mono_image_typedef_or_ref (assembly, &class->byval_arg);
+                       } else {
+                               token = type->modifiers [i].token;
+                       }
+
                        if (type->modifiers [i].required)
                                sigbuffer_add_byte (&buf, MONO_TYPE_CMOD_REQD);
                        else
                                sigbuffer_add_byte (&buf, MONO_TYPE_CMOD_OPT);
-                       sigbuffer_add_value (&buf, mono_image_typedef_or_ref (assembly, &class->byval_arg));
+
+                       sigbuffer_add_value (&buf, token);
                }
        }
        encode_type (assembly, type, &buf);
@@ -3008,10 +3016,10 @@ mono_image_get_generic_field_token (MonoDynamicImage *assembly, MonoReflectionFi
        /* FIXME: We should do this in one place when a fieldbuilder is created */
        if (fb->modreq || fb->modopt) {
                custom = add_custom_modifiers (assembly, mono_reflection_type_get_handle ((MonoReflectionType*)fb->type), fb->modreq, fb->modopt);
-               sig = fieldref_encode_signature (assembly, (MonoImage*)assembly, custom);
+               sig = fieldref_encode_signature (assembly, NULL, custom);
                g_free (custom);
        } else {
-               sig = fieldref_encode_signature (assembly, (MonoImage*)assembly, mono_reflection_type_get_handle ((MonoReflectionType*)fb->type));
+               sig = fieldref_encode_signature (assembly, NULL, mono_reflection_type_get_handle ((MonoReflectionType*)fb->type));
        }
 
        parent = create_generic_typespec (assembly, (MonoReflectionTypeBuilder *) fb->typeb);