The following patch fixes the problem described in the subject line.
Please let me know if there is a problem with the patch :)
(For the curious: types with "." in their name can occur as a result
of ILMerge.)
=== Mono.Cecil/Mono.Cecil/MetadataResolver.cs
@@ -69,11 +69,11 @@
}
static TypeDefinition GetType (ModuleDefinition module,
TypeReference type)
{
if (!type.IsNested)
- return module.GetType (type.FullName);
+ return module.GetType (type.Namespace, type.Name);
var declaring_type = type.DeclaringType.Resolve ();
if (declaring_type == null)
return null;
@@ -69,11 +69,11 @@
}
static TypeDefinition GetType (ModuleDefinition module,
TypeReference type)
{
if (!type.IsNested)
return module.GetType (type.FullNameNamespace,
type.Name);
var declaring_type = type.DeclaringType.Resolve ();
if (declaring_type == null)
return null;
=== Mono.Cecil/Mono.Cecil/ModuleDefinition.cs
@@ -415,10 +415,19 @@
return GetNestedType (fullName);
return ((TypeDefinitionCollection) this.Types).GetType
(fullName);
}
+ public TypeDefinition GetType (string @namespace, string
typeName)
+ {
+ if (@namespace == null)
+ throw new ArgumentNullException ("namespace");
+ if (typeName == null)
+ throw new ArgumentNullException ("typeName");
+ return ((TypeDefinitionCollection) this.Types).GetType
(@namespace, typeName);
+ }
+
static void CheckFullName (string fullName)
{
if (fullName == null)
throw new ArgumentNullException ("fullName");
if (fullName.Length == 0)
@@ -415,10 +415,19 @@
return GetNestedType (fullName);
return ((TypeDefinitionCollection) this.Types).GetType
(fullName);
}
public TypeDefinition GetType (string @namespace, string
typeName)
{
if (@namespace == null)
throw new ArgumentNullException("namespace");
if (typeName == null)
throw new ArgumentNullException("typeName");
return ((TypeDefinitionCollection)
this.Types).GetType(@namespace, typeName);
}
static void CheckFullName (string fullName)
{
if (fullName == null)
throw new ArgumentNullException ("fullName");
if (fullName.Length == 0)
=== Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs
@@ -98,13 +98,17 @@
public TypeDefinition GetType (string fullname)
{
string @namespace, name;
TypeParser.SplitFullName (fullname, out @namespace, out
name);
+ return GetType (@namespace, name);
+ }
+ public TypeDefinition GetType (string @namespace, string
typeName)
+ {
TypeDefinition type;
- if (name_cache.TryGetValue (new Slot (@namespace, name),
out type))
+ if (name_cache.TryGetValue (new Slot (@namespace,
typeName), out type))
return type;
return null;
}
}
--
--
mono-cecil