Fix corlib type lookup
authorJb Evain <jbevain@gmail.com>
Tue, 23 Nov 2010 10:11:20 +0000 (11:11 +0100)
committerJb Evain <jbevain@gmail.com>
Tue, 23 Nov 2010 10:13:00 +0000 (11:13 +0100)
mcs/class/Mono.Cecil/Mono.Cecil/AssemblyReader.cs
mcs/class/Mono.Cecil/Mono.Cecil/TypeSystem.cs

index 18175fc5d1aa993c27f6a0621ac43b94d57e11f1..9e2e01fb17dba89feaf180ff1503976d7c39c1f9 100644 (file)
@@ -900,7 +900,7 @@ namespace Mono.Cecil {
                        return (TypeReference) LookupToken (token);
                }
 
-               TypeDefinition GetTypeDefinition (uint rid)
+               public TypeDefinition GetTypeDefinition (uint rid)
                {
                        InitializeTypeDefinitions ();
 
index d818d57d0b89c3d880afc6a0fc41344a8646d6c7..0848dcbac8b2ff677c04ced90eddc7cd8dcf03a6 100644 (file)
@@ -47,14 +47,32 @@ namespace Mono.Cecil {
                                if (metadata.Types == null)
                                        Initialize (module.Types);
 
-                               var types = metadata.Types;
+                               return module.Read (this, (_, reader) => {
+                                       var types = reader.metadata.Types;
 
+                                       for (int i = 0; i < types.Length; i++) {
+                                               if (types [i] == null)
+                                                       types [i] = reader.GetTypeDefinition ((uint) i + 1);
+
+                                               var type = types [i];
+
+                                               if (type.Name == name && type.Namespace == @namespace)
+                                                       return type;
+                                       }
+
+                                       return null;
+                               });
+                       }
+
+                       internal TypeReference GetType (string fullname)
+                       {
+                               var types = module.MetadataSystem.Types;
                                for (int i = 0; i < types.Length; i++) {
                                        var type = types [i];
                                        if (type == null)
                                                continue;
 
-                                       if (type.Name == name && type.Namespace == @namespace)
+                                       if (type.FullName == fullname)
                                                return type;
                                }