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

Assembly.GetType fixed #1036

Merged
merged 2 commits into from
Feb 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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