diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.IntrospectionExtensions.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.IntrospectionExtensions.js index 2e10dd37b..6aab7db7b 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.IntrospectionExtensions.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.IntrospectionExtensions.js @@ -7,4 +7,7 @@ } ); } -); \ No newline at end of file +); + +JSIL.MakeStaticClass("System.Reflection.IntrospectionExtensions", true, [], function ($) { +}); \ No newline at end of file diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Type.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Type.js index 62f5d63eb..732f9bec2 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Type.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Type.js @@ -71,6 +71,13 @@ } ); + $.Method({ Static: false, Public: true }, "get_GenericTypeArguments", + (new JSIL.MethodSignature($jsilcore.TypeRef("System.Array", [$.Type]), [], [])), + function GetGenericArguments() { + return this.GetGenericArguments(); + } + ); + $.Method({ Static: false, Public: true }, "MakeGenericType", (new JSIL.MethodSignature($.Type, [$jsilcore.TypeRef("System.Array", [$.Type])], [])), function (typeArguments) { @@ -403,6 +410,13 @@ } ); + $.Method({ Static: false, Public: true }, "get_DeclaredConstructors", + new JSIL.MethodSignature($jsilcore.TypeRef("System.Collections.Generic.IEnumerable`1", [$jsilcore.TypeRef("System.Reflection.ConstructorInfo")]), []), + function () { + return this.GetConstructors(); + } + ); + $.Method({ Public: true, Static: false }, "GetFields", new JSIL.MethodSignature(fieldArray, []), function () { diff --git a/JSIL.Libraries/Sources/JSIL.Core.js b/JSIL.Libraries/Sources/JSIL.Core.js index 773d5ff9c..f3894df76 100644 --- a/JSIL.Libraries/Sources/JSIL.Core.js +++ b/JSIL.Libraries/Sources/JSIL.Core.js @@ -7539,7 +7539,7 @@ JSIL.MethodSignature.prototype.toString = function (name, includeReturnType) { } else if (this.returnType !== null) { signature = JSIL.TypeReferenceToName(this.returnType) + " "; } else { - signature = "void "; + signature = "Void "; } if (typeof (name) === "string") { diff --git a/Proxies/BCL/JSIL.Core.Reflection.cs b/Proxies/BCL/JSIL.Core.Reflection.cs index a975306bf..238863081 100644 --- a/Proxies/BCL/JSIL.Core.Reflection.cs +++ b/Proxies/BCL/JSIL.Core.Reflection.cs @@ -1,4 +1,5 @@ -using System.Reflection; +using System; +using System.Reflection; using JSIL.Meta; using JSIL.Proxy; @@ -15,4 +16,15 @@ public class System_Reflection_ParameterInfo public class System_Reflection_EventInfo { } + + [JSProxy("System.Reflection.IntrospectionExtensions", JSProxyMemberPolicy.ReplaceNone, JSProxyAttributePolicy.ReplaceDeclared, JSProxyInterfacePolicy.ReplaceNone, false)] + [JSStubOnly] + public class System_Reflection_IntrospectionExtensions + { + [JSExternal] + public static AnyType /* System.Reflection.TypeInfo */ GetTypeInfo(Type type) + { + throw new NotImplementedException(); + } + } } diff --git a/Tests/MetadataTests.cs b/Tests/MetadataTests.cs index 62c2cafdc..dc65e70d5 100644 --- a/Tests/MetadataTests.cs +++ b/Tests/MetadataTests.cs @@ -187,7 +187,7 @@ public void StubbedAssembliesDoNotGenerateMethodBodies () { var generatedJs = GenericIgnoreTest( @"SpecialTestCases\StubbedMethodBodies.cs", "", - "The external method 'void Main(System.String[])' of type 'Program'", + "The external method 'Void Main(System.String[])' of type 'Program'", new [] { ".*" } ); @@ -330,7 +330,7 @@ public void RenameStaticClass () { public void ExternalMethod () { var generatedJs = GenericIgnoreTest( @"SpecialTestCases\ExternalMethod.cs", - "Method", "external method 'void Method()' of type 'Program' has not" + "Method", "external method 'Void Method()' of type 'Program' has not" ); Assert.IsTrue(generatedJs.Contains("$thisType.Method(")); @@ -541,7 +541,7 @@ public void CanForceTranslationOfTypeInStubbedAssembly () { var generatedJs = GenericIgnoreTest( @"SpecialTestCases\TranslateTypeInStubbedAssembly.cs", "", - "method 'void Main(System.String[])' of type 'Program'", + "method 'Void Main(System.String[])' of type 'Program'", new[] { ".*" } ); @@ -563,7 +563,7 @@ public void CanForceTranslationOfMethodInStubbedAssembly () { var generatedJs = GenericIgnoreTest( @"SpecialTestCases\TranslateMethodInStubbedAssembly.cs", expectedOutput, - "method 'void Main(System.String[])' of type 'Program'", + "method 'Void Main(System.String[])' of type 'Program'", new[] { ".*" } ); diff --git a/Tests/SimpleTestCases/TypeInfoApi.cs b/Tests/SimpleTestCases/TypeInfoApi.cs new file mode 100644 index 000000000..fc47b8022 --- /dev/null +++ b/Tests/SimpleTestCases/TypeInfoApi.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +public static class Program { + public static void Main (string[] args) + { + var assertion = IntrospectionExtensions.GetTypeInfo(typeof(Exception)).DeclaredConstructors + .Any(obj => obj.GetParameters().Length == 2 + && obj.GetParameters()[0].ParameterType == typeof(string) + && obj.GetParameters()[1].ParameterType == typeof(Exception)); + if (!assertion) + { + throw new Exception("Invalid result for DeclaredConstructors"); + } + + Console.WriteLine(assertion ? "true" : "false"); + + Console.WriteLine(typeof(List).GetTypeInfo().GenericTypeArguments[0] == typeof(int) ? "true" : "false"); + } +} \ No newline at end of file diff --git a/Tests/SimpleTests.csproj b/Tests/SimpleTests.csproj index dc6faeada..917e886c7 100644 --- a/Tests/SimpleTests.csproj +++ b/Tests/SimpleTests.csproj @@ -147,6 +147,7 @@ +