diff options
author | jfrijters <jfrijters> | 2011-03-09 10:11:38 +0300 |
---|---|---|
committer | jfrijters <jfrijters> | 2011-03-09 10:11:38 +0300 |
commit | 013223a4f2787879b80eb26265e477fa36e9be29 (patch) | |
tree | ef2a4f07c9e07e67b0b4165682be43c85aa910d7 /reflect/TypeNameParser.cs | |
parent | b56b990a64c914605da625dd3439b5cbda5dc2d1 (diff) |
- Fixed support for missing types in generic type parameters in custom attribute values.
- Fixed TypeParser.GetType() not to throw MissingAssemblyException.
- Unified type name parsing again.
Diffstat (limited to 'reflect/TypeNameParser.cs')
-rw-r--r-- | reflect/TypeNameParser.cs | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/reflect/TypeNameParser.cs b/reflect/TypeNameParser.cs index 025d7f69..2b4c5589 100644 --- a/reflect/TypeNameParser.cs +++ b/reflect/TypeNameParser.cs @@ -439,8 +439,9 @@ namespace IKVM.Reflection } } - internal Type GetType(Universe universe, Assembly context, bool throwOnError, string originalName) + internal Type GetType(Universe universe, Assembly context, bool throwOnError, string originalName, bool resolve) { + TypeName name = TypeName.Split(this.name); Type type; if (assemblyName != null) { @@ -449,24 +450,42 @@ namespace IKVM.Reflection { return null; } - type = asm.GetTypeImpl(name); + if (resolve) + { + type = asm.ResolveType(name); + } + else + { + type = asm.FindType(name); + } } else if (context == null) { - type = universe.Mscorlib.GetTypeImpl(name); + if (resolve) + { + type = universe.Mscorlib.ResolveType(name); + } + else + { + type = universe.Mscorlib.FindType(name); + } } else { - type = context.GetTypeImpl(name); + type = context.FindType(name); if (type == null && context != universe.Mscorlib) { - type = universe.Mscorlib.GetTypeImpl(name); + type = universe.Mscorlib.FindType(name); + } + if (type == null && resolve) + { + type = context.ResolveType(name); } } - return Expand(type, context, throwOnError, originalName); + return Expand(type, context, throwOnError, originalName, resolve); } - internal Type Expand(Type type, Assembly context, bool throwOnError, string originalName) + internal Type Expand(Type type, Assembly context, bool throwOnError, string originalName, bool resolve) { if (type == null) { @@ -478,16 +497,26 @@ namespace IKVM.Reflection } if (nested != null) { + Type outer; foreach (string nest in nested) { - type = type.FindNestedType(TypeName.Split(TypeNameParser.Unescape(nest))); + outer = type; + TypeName name = TypeName.Split(TypeNameParser.Unescape(nest)); + type = outer.FindNestedType(name); if (type == null) { - if (throwOnError) + if (resolve) + { + type = outer.Module.universe.GetMissingTypeOrThrow(outer.Module, outer, name); + } + else if (throwOnError) { throw new TypeLoadException(originalName); } - return null; + else + { + return null; + } } } } @@ -496,7 +525,7 @@ namespace IKVM.Reflection Type[] typeArgs = new Type[genericParameters.Length]; for (int i = 0; i < typeArgs.Length; i++) { - typeArgs[i] = genericParameters[i].GetType(type.Assembly.universe, context, throwOnError, originalName); + typeArgs[i] = genericParameters[i].GetType(type.Assembly.universe, context, throwOnError, originalName, resolve); if (typeArgs[i] == null) { return null; |