explicit this argument to the call signature.
(mono_marshal_get_icall_wrapper): Ditto.
+2009-11-03 Rodrigo Kumpera <rkumpera@novell.com>
+
+ * reflection.c (fieldref_encode_signature): Add new field_image parameter
+ to indicate which assembly to use when resolving a custom-mod.
+
+ Fixes handling of volatile fields used across assemblies as reported in #551513.
+
2009-11-03 Rodrigo Kumpera <rkumpera@novell.com>
* loader.c: Improve error messages.
}
#ifndef DISABLE_REFLECTION_EMIT
+/*field_image is the image to which the eventual custom mods have been encoded against*/
static guint32
-fieldref_encode_signature (MonoDynamicImage *assembly, MonoType *type)
+fieldref_encode_signature (MonoDynamicImage *assembly, MonoImage *field_image, MonoType *type)
{
SigBuffer buf;
guint32 idx, i;
sigbuffer_add_value (&buf, 0x06);
/* encode custom attributes before the type */
- /* FIXME: This should probably go in encode_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 (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, type->modifiers [i].token);
+ sigbuffer_add_value (&buf, mono_image_typedef_or_ref (assembly, &class->byval_arg));
}
}
encode_type (assembly, type, &buf);
}
token = mono_image_get_memberref_token (assembly, &f->field->parent->byval_arg,
mono_field_get_name (f->field),
- fieldref_encode_signature (assembly, type));
+ fieldref_encode_signature (assembly, field->parent->image, type));
g_hash_table_insert (assembly->handleref, f, GUINT_TO_POINTER(token));
return token;
}
/* 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, custom);
+ sig = fieldref_encode_signature (assembly, (MonoImage*)assembly, custom);
g_free (custom);
} else {
- sig = fieldref_encode_signature (assembly, mono_reflection_type_get_handle ((MonoReflectionType*)fb->type));
+ sig = fieldref_encode_signature (assembly, (MonoImage*)assembly, mono_reflection_type_get_handle ((MonoReflectionType*)fb->type));
}
parent = create_generic_typespec (assembly, (MonoReflectionTypeBuilder *) fb->typeb);