diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.Assembly.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.Assembly.js index b03d35d05..3436e57c7 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.Assembly.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.Assembly.js @@ -54,14 +54,14 @@ $.Method({ Static: false, Public: true }, "GetType", (new JSIL.MethodSignature($jsilcore.TypeRef("System.Type"), [$.String], [])), function GetType(name) { - return JSIL.GetTypeFromAssembly(this, name, null, false); + return JSIL.ReflectionGetTypeInternal(this, name, false, false, true); } ); $.Method({ Static: false, Public: true }, "GetType", (new JSIL.MethodSignature($jsilcore.TypeRef("System.Type"), [$.String, $.Boolean], [])), function GetType(name, throwOnError) { - return JSIL.GetTypeFromAssembly(this, name, null, throwOnError); + return JSIL.ReflectionGetTypeInternal(this, name, throwOnError, false, true); } ); @@ -81,7 +81,7 @@ if (ignoreCase) throw new Error("ignoreCase not implemented"); - return JSIL.GetTypeFromAssembly(this, name, null, throwOnError); + return JSIL.ReflectionGetTypeInternal(this, name, throwOnError, ignoreCase, true); } ); diff --git a/JSIL.Libraries/Includes/Core/Reflection/Helpers/JSIL.ReflectionGetTypeInternal.js b/JSIL.Libraries/Includes/Core/Reflection/Helpers/JSIL.ReflectionGetTypeInternal.js index d93db72ba..be349762b 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Helpers/JSIL.ReflectionGetTypeInternal.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Helpers/JSIL.ReflectionGetTypeInternal.js @@ -1,10 +1,10 @@ -JSIL.ReflectionGetTypeInternal = function (thisAssembly, name, throwOnFail, ignoreCase) { +JSIL.ReflectionGetTypeInternal = function (thisAssembly, name, throwOnFail, ignoreCase, onlySpecificAssembly) { var parsed = JSIL.ParseTypeName(name); var result = JSIL.GetTypeInternal(parsed, thisAssembly, false); // HACK: Emulate fallback to global namespace search. - if (!result) { + if (!result && !onlySpecificAssembly) { result = JSIL.GetTypeInternal(parsed, JSIL.GlobalNamespace, false); } diff --git a/Tests/SimpleTestCases/GetTypeFromAssembly_Issue1035.cs b/Tests/SimpleTestCases/GetTypeFromAssembly_Issue1035.cs new file mode 100644 index 000000000..8570e88cd --- /dev/null +++ b/Tests/SimpleTestCases/GetTypeFromAssembly_Issue1035.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +public static class Program +{ + public static void Main(string[] args) + { + var typeInt32 = typeof(object).Assembly.GetType("System.Int32"); + var typeDictionary = + typeof (object).Assembly.GetType( + "System.Collections.Generic.Dictionary`2[[System.Int32, mscorlib],[System.Object, mscorlib]]"); + Console.WriteLine( + "{0} {1}", typeInt32.Name, typeDictionary.Name + ); + + } +} \ No newline at end of file diff --git a/Tests/SimpleTests.csproj b/Tests/SimpleTests.csproj index 6c9957201..fe2112c10 100644 --- a/Tests/SimpleTests.csproj +++ b/Tests/SimpleTests.csproj @@ -143,6 +143,7 @@ +