[runtime] Fix resolution of a type with an incorrect assembly name.
authorAlexander Kyte <alexander.kyte@xamarin.com>
Mon, 18 May 2015 19:21:34 +0000 (15:21 -0400)
committerAlexander Kyte <alexmkyte@gmail.com>
Thu, 28 May 2015 21:56:52 +0000 (21:56 +0000)
mono/metadata/reflection.c
mono/tests/Makefile.am
mono/tests/bug-30085.cs [new file with mode: 0644]

index d085e1c008e29a830f876bc7655a531ae86e8695..d12b0ea05ff68f82903cd3205dbd3bbb8a665f11 100644 (file)
@@ -7484,6 +7484,9 @@ mono_reflection_get_type_internal (MonoImage *rootimage, MonoImage* image, MonoT
        if (!image)
                image = mono_defaults.corlib;
 
+       if (!rootimage)
+               rootimage = mono_defaults.corlib;
+
        if (ignorecase) {
                MonoError error;
                klass = mono_class_from_name_case_checked (image, info->name_space, info->name, &error);
index 7d2e1acde3927d18df8577cd5817208a22cd9e02..60fd4038041bcc555156f6faeedf141e47438ec5 100644 (file)
@@ -411,6 +411,7 @@ BASE_TEST_CS_SRC=           \
        thread_static_gc_layout.cs \
        sleep.cs \
        bug-27147.cs    \
+       bug-30085.cs    \
        bug-17537.cs
 
 TEST_CS_SRC_DIST=      \
diff --git a/mono/tests/bug-30085.cs b/mono/tests/bug-30085.cs
new file mode 100644 (file)
index 0000000..80c985b
--- /dev/null
@@ -0,0 +1,35 @@
+using System;
+
+class Program
+{
+
+       static void MissingImage ()
+       {
+               Type good = System.Type.GetType("System.Nullable`1[[System.Int32, mscorlib]]");
+               Type bad = System.Type.GetType("System.Nullable`1[[System.Int32, mscorlibBAD]]");
+
+               if (good.Assembly.FullName.Split (',') [0] != "mscorlib")
+                       throw new Exception ("Wrong assembly name");
+
+               if (bad != null)
+                       throw new Exception ("Should not have loaded type");
+       }
+
+       static void ProbeCorlib ()
+       {
+               Type good = System.Type.GetType("System.Nullable`1[[System.Int32, mscorlib]]"); 
+               Type bad = System.Type.GetType("System.Nullable`1[[System.IO.Pipes.PipeOptions, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]");
+
+               if (good.Assembly.FullName.Split (',') [0] != "mscorlib")
+                       throw new Exception ("Wrong assembly name");
+
+               if (good == null || bad == null)
+                       throw new Exception ("Missing image did not probe corlib");
+       }
+
+       static void Main()
+       {
+               MissingImage ();
+               ProbeCorlib ();
+       }
+}