X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Freflection.c;h=d7c958f1bd2442d782558548316f59bfe94b7882;hb=0f128ab73f1d67e6847eed513038b338fe780099;hp=ec77522142dbda1b6322271d089c9475be1789db;hpb=05d3f9e3beeecb211fb31952b141dd3c98f44d6b;p=mono.git diff --git a/mono/metadata/reflection.c b/mono/metadata/reflection.c index ec77522142d..d7c958f1bd2 100644 --- a/mono/metadata/reflection.c +++ b/mono/metadata/reflection.c @@ -1382,11 +1382,11 @@ type_get_fully_qualified_name (MonoType *type) { klass = my_mono_class_from_mono_type (type); ta = klass->image->assembly; - /* missing public key */ - result = g_strdup_printf ("%s, %s, Version=%d.%d.%d.%d, Culture=%s", + result = g_strdup_printf ("%s, %s, Version=%d.%d.%d.%d, Culture=%s, PublicKeyToken=%s", name, ta->aname.name, ta->aname.major, ta->aname.minor, ta->aname.build, ta->aname.revision, - ta->aname.culture && *ta->aname.culture? ta->aname.culture: "neutral"); + ta->aname.culture && *ta->aname.culture? ta->aname.culture: "neutral", + ta->aname.public_tok_value ? ta->aname.public_tok_value : "null"); g_free (name); return result; } @@ -1551,7 +1551,16 @@ encode_marshal_blob (MonoDynamicImage *assembly, MonoReflectionMarshal *minfo) { mono_metadata_encode_value (minfo->type, p, &p); mono_metadata_encode_value (minfo->count, p, &p); break; - /* FIXME: handle ARRAY and other unmanaged types that need extra info */ + case MONO_NATIVE_LPARRAY: + mono_metadata_encode_value (minfo->type, p, &p); + if (minfo->eltype || (minfo->count > 0)) { + mono_metadata_encode_value (minfo->eltype, p, &p); + if (minfo->count > 0) { + mono_metadata_encode_value (0, p, &p); + mono_metadata_encode_value (minfo->count, p, &p); + } + } + break; case MONO_NATIVE_CUSTOM: mono_metadata_encode_value (minfo->type, p, &p); if (minfo->guid) { @@ -1964,7 +1973,12 @@ mono_image_get_generic_param_info (MonoReflectionGenericParam *gparam, guint32 o param = gparam->type.type->data.generic_param; values [MONO_GENERICPARAM_OWNER] = owner; - values [MONO_GENERICPARAM_FLAGS] = param->flags; + if (gparam->has_value_type) + values [MONO_GENERICPARAM_FLAGS] = 0x18; + else if (gparam->has_reference_type) + values [MONO_GENERICPARAM_FLAGS] = 0x04; + else + values [MONO_GENERICPARAM_FLAGS] = 0x00; values [MONO_GENERICPARAM_NUMBER] = param->num; values [MONO_GENERICPARAM_NAME] = string_heap_insert (&assembly->sheap, param->name); values [MONO_GENERICPARAM_KIND] = 0; @@ -2014,10 +2028,7 @@ resolution_scope_from_image (MonoDynamicImage *assembly, MonoImage *image) table->rows ++; alloc_table (table, table->rows); values = table->values + token * MONO_ASSEMBLYREF_SIZE; - if (strcmp ("corlib", image->assembly_name) == 0) - values [MONO_ASSEMBLYREF_NAME] = string_heap_insert (&assembly->sheap, "mscorlib"); - else - values [MONO_ASSEMBLYREF_NAME] = string_heap_insert (&assembly->sheap, image->assembly_name); + values [MONO_ASSEMBLYREF_NAME] = string_heap_insert (&assembly->sheap, image->assembly_name); values [MONO_ASSEMBLYREF_MAJOR_VERSION] = cols [MONO_ASSEMBLY_MAJOR_VERSION]; values [MONO_ASSEMBLYREF_MINOR_VERSION] = cols [MONO_ASSEMBLY_MINOR_VERSION]; values [MONO_ASSEMBLYREF_BUILD_NUMBER] = cols [MONO_ASSEMBLY_BUILD_NUMBER]; @@ -2045,8 +2056,7 @@ resolution_scope_from_image (MonoDynamicImage *assembly, MonoImage *image) * recognized by ms, yuck! * FIXME: need to add more assembly names, as needed. */ - if (strcmp (image->assembly_name, "corlib") == 0 || - strcmp (image->assembly_name, "mscorlib") == 0 || + if (strcmp (image->assembly_name, "mscorlib") == 0 || strcmp (image->assembly_name, "System") == 0 || strcmp (image->assembly_name, "System.Runtime.Remoting") == 0 || strcmp (image->assembly_name, "System.Xml") == 0 || @@ -5172,7 +5182,8 @@ assembly_name_to_aname (MonoAssemblyName *assembly, char *p) { memset (assembly, 0, sizeof (MonoAssemblyName)); assembly->name = p; assembly->culture = ""; - + assembly->public_tok_value = NULL; + while (*p && (isalnum (*p) || *p == '.' || *p == '-' || *p == '_' || *p == '$' || *p == '@')) p++; found_sep = 0; @@ -5185,7 +5196,7 @@ assembly_name_to_aname (MonoAssemblyName *assembly, char *p) { if (!found_sep) return 1; while (*p) { - if (*p == 'V' && strncmp (p, "Version=", 8) == 0) { + if (*p == 'V' && g_ascii_strncasecmp (p, "Version=", 8) == 0) { p += 8; assembly->major = strtoul (p, &s, 10); if (s == p || *s != '.') @@ -5202,10 +5213,11 @@ assembly_name_to_aname (MonoAssemblyName *assembly, char *p) { assembly->revision = strtoul (p, &s, 10); if (s == p) return 1; - } else if (*p == 'C' && strncmp (p, "Culture=", 8) == 0) { + p = s; + } else if (*p == 'C' && g_ascii_strncasecmp (p, "Culture=", 8) == 0) { p += 8; - if (strncmp (p, "neutral", 7) == 0) { - assembly->culture = ""; + if (g_ascii_strncasecmp (p, "neutral", 7) == 0) { + assembly->culture = g_strdup (""); p += 7; } else { assembly->culture = p; @@ -5213,26 +5225,16 @@ assembly_name_to_aname (MonoAssemblyName *assembly, char *p) { p++; } } - } else if (*p == 'P' && strncmp (p, "PublicKeyToken=", 15) == 0) { + } else if (*p == 'P' && g_ascii_strncasecmp (p, "PublicKeyToken=", 15) == 0) { p += 15; - s = p; - while (*s && isxdigit (*s)) { - *s = tolower (*s); - s++; - } - assembly->hash_len = s - p; - if (!(s-p) || ((s-p) & 1)) - return 1; - assembly->hash_value = s = p; - while (*s && isxdigit (*s)) { - int val; - val = *s >= '0' && *s <= '9'? *s - '0': *s - 'a' + 10; - s++; - *p = val << 4; - *p |= *s >= '0' && *s <= '9'? *s - '0': *s - 'a' + 10; - p++; + if (strncmp (p, "null", 4) == 0) { + p += 4; + } else { + assembly->public_tok_value = p; + while (*p && *p != ',') { + p++; + } } - p = s; } else { while (*p && *p != ',') p++; @@ -5475,9 +5477,36 @@ mono_reflection_get_type (MonoImage* image, MonoTypeNameParse *info, gboolean ig assembly = mono_domain_try_type_resolve ( mono_domain_get (), fullName->str, NULL); - if (assembly && (!image || (assembly->assembly->image == image))) - type = mono_reflection_get_type_internal (assembly->assembly->image, - info, ignorecase); + if (assembly && (!image || (assembly->assembly->image == image))) { + + if (assembly->assembly->dynamic) { + /* Enumerate all modules */ + MonoReflectionAssemblyBuilder *abuilder = (MonoReflectionAssemblyBuilder*)assembly; + int i; + + type = NULL; + if (abuilder->modules) { + for (i = 0; i < mono_array_length (abuilder->modules); ++i) { + MonoReflectionModuleBuilder *mb = mono_array_get (abuilder->modules, MonoReflectionModuleBuilder*, i); + type = mono_reflection_get_type_internal (&mb->dynamic_image->image, info, ignorecase); + if (type) + break; + } + } + + if (!type && abuilder->loaded_modules) { + for (i = 0; i < mono_array_length (abuilder->loaded_modules); ++i) { + MonoReflectionModule *mod = mono_array_get (abuilder->loaded_modules, MonoReflectionModule*, i); + type = mono_reflection_get_type_internal (mod->image, info, ignorecase); + if (type) + break; + } + } + } + else + type = mono_reflection_get_type_internal (assembly->assembly->image, + info, ignorecase); + } g_string_free (fullName, TRUE); return type; } @@ -7677,8 +7706,11 @@ mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam image = &gparam->tbuilder->module->dynamic_image->image; mono_class_from_generic_parameter (param, image, gparam->mbuilder != NULL); + param->pklass->reflection_info = gparam; + gparam->type.type = g_new0 (MonoType, 1); gparam->type.type->type = gparam->mbuilder ? MONO_TYPE_MVAR : MONO_TYPE_VAR; + gparam->type.type->attrs = TYPE_ATTRIBUTE_PUBLIC; gparam->type.type->data.generic_param = param; }