Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1036 from SabaSoftware/Assembly_GetType_1035
Browse files Browse the repository at this point in the history
Assembly.GetType fixed
  • Loading branch information
kg authored Feb 24, 2017
2 parents 855b753 + 0cfbf85 commit 2751b07
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
);

Expand All @@ -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);
}
);

Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}

Expand Down
17 changes: 17 additions & 0 deletions Tests/SimpleTestCases/GetTypeFromAssembly_Issue1035.cs
Original file line number Diff line number Diff line change
@@ -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
);

}
}
1 change: 1 addition & 0 deletions Tests/SimpleTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
<None Include="SimpleTestCases\BoxNumeric_Issue981.cs" />
<None Include="SimpleTestCases\NullableUnary_Issue997.cs" />
<None Include="SimpleTestCasesForTranslatedBcl\Issue1008_MethodReturnType.cs" />
<None Include="SimpleTestCases\GetTypeFromAssembly_Issue1035.cs" />
<Compile Include="SimpleTests.cs" />
<None Include="SimpleTestCases\BaseAutoProperties.cs" />
<None Include="SimpleTestCases\OverloadedVirtualMethods.cs" />
Expand Down

0 comments on commit 2751b07

Please sign in to comment.