зеркало из https://github.com/mono/ikvm-fork.git
Fixed resolving nested type by name.
This commit is contained in:
Родитель
44dc4dfabc
Коммит
29d4433de5
|
@ -374,7 +374,8 @@ namespace IKVM.Reflection.Reader
|
|||
case TypeRefTable.Index:
|
||||
{
|
||||
Type outer = ResolveType(scope, null);
|
||||
typeRefs[index] = outer.GetNestedType(GetString(TypeRef.records[index].TypeName), BindingFlags.Public | BindingFlags.NonPublic);
|
||||
string typeName = GetTypeName(TypeRef.records[index].TypeNameSpace, TypeRef.records[index].TypeName);
|
||||
typeRefs[index] = outer.GetNestedTypeCorrectly(typeName);
|
||||
break;
|
||||
}
|
||||
case ModuleTable.Index:
|
||||
|
|
|
@ -747,6 +747,38 @@ namespace IKVM.Reflection
|
|||
return GetConstructor(bindingAttr, binder, types, modifiers);
|
||||
}
|
||||
|
||||
private static bool MatchTypeNames(string ns, string name, string fullName)
|
||||
{
|
||||
if (ns == null)
|
||||
{
|
||||
return name == fullName;
|
||||
}
|
||||
else if (ns.Length + 1 + name.Length == fullName.Length)
|
||||
{
|
||||
return fullName[ns.Length] == '.'
|
||||
&& String.CompareOrdinal(ns, 0, fullName, 0, ns.Length) == 0
|
||||
&& String.CompareOrdinal(name, 0, fullName, ns.Length + 1, name.Length) == 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// unlike the public API, this takes the namespace and name into account
|
||||
internal Type GetNestedTypeCorrectly(string name)
|
||||
{
|
||||
CheckBaked();
|
||||
foreach (Type type in __GetDeclaredTypes())
|
||||
{
|
||||
if (MatchTypeNames(type.__Namespace, type.__Name, name))
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Type GetNestedType(string name)
|
||||
{
|
||||
return GetNestedType(name, BindingFlags.Public);
|
||||
|
|
|
@ -407,7 +407,7 @@ namespace IKVM.Reflection
|
|||
{
|
||||
foreach (string nest in nested)
|
||||
{
|
||||
type = type.GetNestedType(nest, BindingFlags.Public | BindingFlags.NonPublic);
|
||||
type = type.GetNestedTypeCorrectly(TypeNameParser.Unescape(nest));
|
||||
if (type == null)
|
||||
{
|
||||
if (throwOnError)
|
||||
|
|
Загрузка…
Ссылка в новой задаче