diff --git a/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Array.js b/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Array.js index c8a206ddb..64b1ffa33 100644 --- a/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Array.js +++ b/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Array.js @@ -172,4 +172,23 @@ JSIL.ImplementExternals("System.Array", function ($) { reverseImpl(array, index, length); } ); -}); \ No newline at end of file + + $.Method({ Static: true, Public: true }, "Empty", + new JSIL.MethodSignature($jsilcore.TypeRef("System.Array", ["!!0"]), [], ["T"]), + function Empty(T) { + return $jsilcore.System.Array_EmptyArray$b1.Of(T).Value; + } + ); +}); + + +JSIL.MakeStaticClass("System.Array+EmptyArray`1", false, ["T"], function($) { + $.Field({ Static: true, Public: true, ReadOnly: true }, "Value", $jsilcore.TypeRef("System.Array", [$.GenericParameter("T")])); + + $.Method({ Static: true, Public: false }, ".cctor", + JSIL.MethodSignature.Void, + function EmptyArray$b1__cctor() { + this.Value = JSIL.Array.New(this.T, 0); + } + ); +}); diff --git a/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Enum.js b/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Enum.js index 288e11551..7190eef51 100644 --- a/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Enum.js +++ b/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Enum.js @@ -141,5 +141,12 @@ return result; } ); + + $.Method({ Static: true, Public: true }, "GetUnderlyingType", + new JSIL.MethodSignature($jsilcore.TypeRef("System.Type"), [$jsilcore.TypeRef("System.Type")], []), + function (enm) { + return enm.__StorageType__; + } + ); } ); \ No newline at end of file diff --git a/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Threading.Thread.js b/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Threading.Thread.js index 3696211a5..95746ed3f 100644 --- a/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Threading.Thread.js +++ b/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Threading.Thread.js @@ -24,6 +24,12 @@ return 0; } ); + + $.Method({ Static: true, Public: true }, "MemoryBarrier", + JSIL.MethodSignature.Void, + function thread_MemoryBarrier() { + } + ); } ); diff --git a/JSIL.Libraries/Includes/Bootstrap/Text/Classes/System.Char.js b/JSIL.Libraries/Includes/Bootstrap/Text/Classes/System.Char.js index 57c117152..ee02e38f0 100644 --- a/JSIL.Libraries/Includes/Bootstrap/Text/Classes/System.Char.js +++ b/JSIL.Libraries/Includes/Bootstrap/Text/Classes/System.Char.js @@ -28,6 +28,15 @@ JSIL.ImplementExternals("System.Char", function ($) { } ); + $.Method({ Static: true, Public: true }, "IsNumber", + new JSIL.MethodSignature($.Boolean, [$.Char], []), + function IsNumeric(c) { + // FIXME: Unicode + var charCode = c.charCodeAt(0); + return (charCode >= 48) && (charCode <= 57); + } + ); + $.Method({ Static: true, Public: true }, "IsLetterOrDigit", new JSIL.MethodSignature($.Boolean, [$.Char], []), function IsLetterOrDigit(c) { diff --git a/JSIL.Libraries/Includes/Bootstrap/Text/Classes/System.String.js b/JSIL.Libraries/Includes/Bootstrap/Text/Classes/System.String.js index 3763a0b1f..f20510ddc 100644 --- a/JSIL.Libraries/Includes/Bootstrap/Text/Classes/System.String.js +++ b/JSIL.Libraries/Includes/Bootstrap/Text/Classes/System.String.js @@ -271,9 +271,17 @@ JSIL.ImplementExternals( } } ); + + $.Method({ Static: false, Public: true }, "get_Length", + new JSIL.MethodSignature($.Int32, [], []), + function() { + return this.length; + } + ); } ); JSIL.MakeClass("System.Object", "System.String", true, [], function ($) { $.Field({ Static: true, Public: true }, "Empty", $.String, ""); + $.Property({ Public: true, Static: false }, "Length"); }); \ No newline at end of file diff --git a/JSIL.Libraries/Includes/Bootstrap/Text/Helpers/JSIL.StringFromCharArray.js b/JSIL.Libraries/Includes/Bootstrap/Text/Helpers/JSIL.StringFromCharArray.js index f887414dc..a6f942d34 100644 --- a/JSIL.Libraries/Includes/Bootstrap/Text/Helpers/JSIL.StringFromCharArray.js +++ b/JSIL.Libraries/Includes/Bootstrap/Text/Helpers/JSIL.StringFromCharArray.js @@ -5,7 +5,7 @@ JSIL.StringFromCharArray = function (chars, startIndex, length) { length = chars.length; if (arguments.length > 1) { - var arr = chars.slice(startIndex, length); + var arr = chars.slice(startIndex, startIndex + length); return arr.join(""); } else { return chars.join(""); diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Attribute.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Attribute.js index e51de6e01..bffd39794 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Attribute.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Attribute.js @@ -1,9 +1,2 @@ JSIL.ImplementExternals("System.Attribute", function ($) { - $.Method({ Static: true, Public: true }, "GetCustomAttribute", - (new JSIL.MethodSignature($jsilcore.TypeRef("System.Attribute"), [$jsilcore.TypeRef("System.Reflection.Assembly"), $jsilcore.TypeRef("System.Type")], [])), - function GetCustomAttribute(assembly, attributeType) { - // FIXME: Not implemented - return null; - } - ); }); \ No newline at end of file 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 14748b09b..b03d35d05 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.Assembly.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.Assembly.js @@ -65,6 +65,13 @@ } ); + $.Method({ Static: true, Public: true }, "Load", + (new JSIL.MethodSignature($jsilcore.TypeRef("System.Reflection.Assembly"), [$.String], [])), + function Load(assemblyName) { + return JSIL.GetAssembly(assemblyName).__Assembly__; + } + ); + $.Method({ Static: false, Public: true }, "GetType", (new JSIL.MethodSignature($jsilcore.TypeRef("System.Type"), [ $.String, $.Boolean, diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.MethodBase.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.MethodBase.js index 1aa8a0ca2..a66f04f87 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.MethodBase.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.MethodBase.js @@ -26,6 +26,13 @@ return this._data.signature.toString(this.Name); } ); + + $.Method({ Public: true, Static: false }, "get_IsConstructor", + new JSIL.MethodSignature($.Boolean, []), + function get_IsConstructor() { + return $jsilcore.System.Reflection.ConstructorInfo.$Is(this) && !this.get_IsStatic(); + } + ); } ); diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.MethodInfo.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.MethodInfo.js index 3f6567282..1c4313084 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.MethodInfo.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.MethodInfo.js @@ -94,7 +94,7 @@ if (result) return result; - var parsedTypeName = JSIL.ParseTypeName("System.Reflection.MethodInfo"); + var parsedTypeName = JSIL.ParseTypeName("System.Reflection.RuntimeMethodInfo"); var infoType = JSIL.GetTypeInternal(parsedTypeName, $jsilcore, true); var info = JSIL.CreateInstanceOfType(infoType, null); info._typeObject = this._typeObject; @@ -123,6 +123,13 @@ } ); + $.Method({ Public: true, Static: false }, "get_IsVirtual", + new JSIL.MethodSignature($.Type, []), + function get_IsGenericMethod() { + return this._descriptor.Virtual; + } + ); + $.Method({ Public: true, Static: false }, "get_IsGenericMethodDefinition", new JSIL.MethodSignature($.Type, []), function get_IsGenericMethodDefinition() { @@ -136,6 +143,21 @@ return this.DeclaringType.get_ContainsGenericParameters() || (this._data.signature.genericArgumentNames.length !== 0 && this._data.signature.genericArgumentValues === undefined); } ); + + $.Method({ Static: false, Public: true }, "GetBaseDefinition", + (new JSIL.MethodSignature($jsilcore.TypeRef("System.Reflection.MethodInfo"), [], [])), + function getBaseDefinition() { + var previous; + var current = this; + + do { + previous = current; + current = current.GetParentDefinition(); + } while (current !== null) + + return previous; + } + ); }); JSIL.MakeClass("System.Reflection.MethodBase", "System.Reflection.MethodInfo", true, [], function ($) { diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.ParameterInfo.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.ParameterInfo.js index d927153dd..e082d83dd 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.ParameterInfo.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.ParameterInfo.js @@ -1,23 +1,6 @@ JSIL.ImplementExternals("System.Reflection.ParameterInfo", function ($interfaceBuilder) { var $ = $interfaceBuilder; - $.RawMethod(false, "$fromArgumentTypeAndPosition", function (argumentType, position) { - this.argumentType = argumentType; - this.position = position; - this._name = null; - this.__Attributes__ = []; - }); - - $.RawMethod(false, "$populateWithParameterInfo", function (parameterInfo) { - this._name = parameterInfo.name || null; - - if (parameterInfo.attributes) { - var mb = new JSIL.MemberBuilder(null); - parameterInfo.attributes(mb); - this.__Attributes__ = mb.attributes; - } - }); - $.Method({ Static: false, Public: true }, "get_Attributes", new JSIL.MethodSignature($jsilcore.TypeRef("System.Reflection.ParameterAttributes"), [], []), function get_Attributes() { diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeConstructorInfo.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeConstructorInfo.js new file mode 100644 index 000000000..38631bb24 --- /dev/null +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeConstructorInfo.js @@ -0,0 +1,2 @@ +JSIL.MakeClass("System.Reflection.ConstructorInfo", "System.Reflection.RuntimeConstructorInfo", false, [], function ($) { +}); \ No newline at end of file diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeEventInfo.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeEventInfo.js new file mode 100644 index 000000000..20b3539f4 --- /dev/null +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeEventInfo.js @@ -0,0 +1,2 @@ +JSIL.MakeClass("System.Reflection.EventInfo", "System.Reflection.RuntimeEventInfo", false, [], function ($) { +}); \ No newline at end of file diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeFieldInfo.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeFieldInfo.js new file mode 100644 index 000000000..6bec2ed28 --- /dev/null +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeFieldInfo.js @@ -0,0 +1,2 @@ +JSIL.MakeClass("System.Reflection.FieldInfo", "System.Reflection.RuntimeFieldInfo", false, [], function ($) { +}); \ No newline at end of file diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeMethodInfo.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeMethodInfo.js new file mode 100644 index 000000000..a0f589046 --- /dev/null +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeMethodInfo.js @@ -0,0 +1,22 @@ +JSIL.MakeClass("System.Reflection.MethodInfo", "System.Reflection.RuntimeMethodInfo", false, [], function ($) { + $.Method({ Static: false, Public: false }, "GetParentDefinition", + (new JSIL.MethodSignature($jsilcore.TypeRef("System.Reflection.RuntimeMethodInfo"), [], [])), + function get_ReturnType() { + if (!this._descriptor.Virtual || this._descriptor.Static) { + return null; + } + + var currentType = this.get_DeclaringType(); + while (true) { + currentType = currentType.__BaseType__; + if (!(currentType && currentType.GetType)) { + return null; + } + var foundMethod = JSIL.GetMethodInfo(currentType.__PublicInterface__, this.get_Name(), this._data.signature, false, null); + if (foundMethod != null) { + return foundMethod; + } + } + } +); +}); \ No newline at end of file diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeParameterInfo.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeParameterInfo.js new file mode 100644 index 000000000..0ee7d4b6a --- /dev/null +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimeParameterInfo.js @@ -0,0 +1,18 @@ +JSIL.MakeClass("System.Reflection.ParameterInfo", "System.Reflection.RuntimeParameterInfo", false, [], function ($) { + $.RawMethod(false, "$fromArgumentTypeAndPosition", function (argumentType, position) { + this.argumentType = argumentType; + this.position = position; + this._name = null; + this.__Attributes__ = []; + }); + + $.RawMethod(false, "$populateWithParameterInfo", function (parameterInfo) { + this._name = parameterInfo.name || null; + + if (parameterInfo.attributes) { + var mb = new JSIL.MemberBuilder(null); + parameterInfo.attributes(mb); + this.__Attributes__ = mb.attributes; + } + }); +}); \ No newline at end of file diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimePropertyInfo.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimePropertyInfo.js new file mode 100644 index 000000000..d9dc29b34 --- /dev/null +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Reflection.RuntimePropertyInfo.js @@ -0,0 +1,2 @@ +JSIL.MakeClass("System.Reflection.PropertyInfo", "System.Reflection.RuntimePropertyInfo", false, [], function ($) { +}); \ No newline at end of file diff --git a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.RuntimeType.js b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.RuntimeType.js index fbb0841ad..76d04d4cb 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.RuntimeType.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.RuntimeType.js @@ -1,3 +1,13 @@ JSIL.MakeClass("System.Reflection.TypeInfo", "System.RuntimeType", false, [], function ($) { $jsilcore.RuntimeTypeInitialized = true; + + $.Method({ Public: true, Static: true }, "op_Equality", + new JSIL.MethodSignature($.Boolean, [$.Type, $.Type]), + function(lhs, rhs) { + if (lhs === rhs) + return true; + + return String(lhs) == String(rhs); + } + ); }); \ 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 503e0360a..b1d89cfcf 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Type.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Classes/System.Type.js @@ -171,7 +171,10 @@ function () { return JSIL.GetMembersInternal( this, - defaultFlags() + defaultFlags(), + null, + null, + true ); } ); @@ -180,7 +183,11 @@ new JSIL.MethodSignature(memberArray, [$jsilcore.TypeRef("System.Reflection.BindingFlags")]), function (flags) { return JSIL.GetMembersInternal( - this, flags + this, + flags, + null, + null, + true ); } ); @@ -281,7 +288,9 @@ System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public, - "EventInfo" + "EventInfo", + null, + true ); } ); @@ -290,14 +299,14 @@ new JSIL.MethodSignature(eventArray, [$jsilcore.TypeRef("System.Reflection.BindingFlags")]), function (flags) { return JSIL.GetMembersInternal( - this, flags, "EventInfo" + this, flags, "EventInfo", null, true ); } ); var getConstructorImpl = function (self, flags, argumentTypes) { var constructors = JSIL.GetMembersInternal( - self, flags, "ConstructorInfo" + self, flags, "ConstructorInfo", null, true ); JSIL.$FilterMethodsByArgumentTypes(constructors, argumentTypes); @@ -405,7 +414,9 @@ System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public, - "PropertyInfo" + "PropertyInfo", + null, + true ); } ); @@ -414,13 +425,13 @@ new JSIL.MethodSignature(propertyArray, [$jsilcore.TypeRef("System.Reflection.BindingFlags")]), function (flags) { return JSIL.GetMembersInternal( - this, flags, "PropertyInfo" + this, flags, "PropertyInfo", null, true ); } ); var getSingleFiltered = function (self, name, flags, type) { - var members = JSIL.GetMembersInternal(self, flags, type); + var members = JSIL.GetMembersInternal(self, flags, type, null, true); var result = null; for (var i = 0, l = members.length; i < l; i++) { @@ -471,6 +482,20 @@ } ); + $.Method({ Public: true, Static: false }, "GetProperty", + new JSIL.MethodSignature($jsilcore.TypeRef("System.Reflection.PropertyInfo"), [ + $.String, + $jsilcore.TypeRef("System.Reflection.BindingFlags"), + $jsilcore.TypeRef("System.Reflection.Binder"), + $jsilcore.TypeRef("System.Type"), + $jsilcore.TypeRef("System.Array", [$jsilcore.TypeRef("System.Type")]), + $jsilcore.TypeRef("System.Array", [$jsilcore.TypeRef("System.Reflection.ParameterModifier")])]), + function (name, flags) { + //TODO: Implement it. + return getSingleFiltered(this, name, flags, "PropertyInfo"); + } + ); + $.Method({ Public: true, Static: false }, "get_IsGenericParameter", new JSIL.MethodSignature($.Type, []), JSIL.TypeObjectPrototype.get_IsGenericParameter @@ -587,6 +612,13 @@ } ); + $.Method({ Static: true, Public: true }, "get_EmptyTypes", + new JSIL.MethodSignature($jsilcore.TypeRef("System.Array", [$jsilcore.TypeRef("System.Type")]), []), + function get_EmptyTypes() { + return JSIL.Array.New($jsilcore.System.Type, 0); + } + ); + } ); @@ -604,4 +636,7 @@ JSIL.MakeClass("System.Reflection.MemberInfo", "System.Type", true, [], function $.Property({ Public: true, Static: false }, "IsValueType"); $.Property({ Public: true, Static: false }, "IsEnum"); $.Property({ Public: true, Static: false }, "IsClass"); + + // HACK - it should really be field. + $.Property({ Public: true, Static: true }, "EmptyTypes"); }); \ No newline at end of file diff --git a/JSIL.Libraries/Includes/Core/Reflection/Helpers/$jsilcore.$MethodGetParameters.js b/JSIL.Libraries/Includes/Core/Reflection/Helpers/$jsilcore.$MethodGetParameters.js index 6d631473b..7459e1d43 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Helpers/$jsilcore.$MethodGetParameters.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Helpers/$jsilcore.$MethodGetParameters.js @@ -7,7 +7,7 @@ var argumentTypes = method._data.resolvedSignature.argumentTypes; var parameterInfos = method._data.parameterInfo; - var tParameterInfo = $jsilcore.System.Reflection.ParameterInfo.__Type__; + var tParameterInfo = $jsilcore.System.Reflection.RuntimeParameterInfo.__Type__; if (argumentTypes) { for (var i = 0; i < argumentTypes.length; i++) { diff --git a/JSIL.Libraries/Includes/Core/Reflection/Main.js b/JSIL.Libraries/Includes/Core/Reflection/Main.js index b83df8740..5cf4e5c29 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Main.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Main.js @@ -38,4 +38,11 @@ if (!$jsilcore) //? include("Classes/System.Reflection.AssemblyName.js"); writeln(); -//? include("Classes/System.Reflection.ICustomAttributeProvider.js"); writeln(); \ No newline at end of file +//? include("Classes/System.Reflection.ICustomAttributeProvider.js"); writeln(); + +//? include("Classes/System.Reflection.RuntimeConstructorInfo.js"); writeln(); +//? include("Classes/System.Reflection.RuntimeEventInfo.js"); writeln(); +//? include("Classes/System.Reflection.RuntimeFieldInfo.js"); writeln(); +//? include("Classes/System.Reflection.RuntimeMethodInfo.js"); writeln(); +//? include("Classes/System.Reflection.RuntimeParameterInfo.js"); writeln(); +//? include("Classes/System.Reflection.RuntimePropertyInfo.js"); writeln(); \ No newline at end of file diff --git a/JSIL.Libraries/Includes/Core/Reflection/Utils/$jsilcore.MemberInfoExternals.js b/JSIL.Libraries/Includes/Core/Reflection/Utils/$jsilcore.MemberInfoExternals.js index 16d83852f..c8002640b 100644 --- a/JSIL.Libraries/Includes/Core/Reflection/Utils/$jsilcore.MemberInfoExternals.js +++ b/JSIL.Libraries/Includes/Core/Reflection/Utils/$jsilcore.MemberInfoExternals.js @@ -28,6 +28,13 @@ $jsilcore.MemberInfoExternals = function ($) { } ); + $.Method({ Static: false, Public: true }, "get_IsPrivate", + new JSIL.MethodSignature($jsilcore.TypeRef("System.Boolean"), [], []), + function () { + return !this._descriptor.Public; + } +); + $.Method({ Static: false, Public: true }, "get_IsStatic", new JSIL.MethodSignature($jsilcore.TypeRef("System.Boolean"), [], []), function () { @@ -62,5 +69,17 @@ $jsilcore.MemberInfoExternals = function ($) { throw new Error('Not implemented'); } ); + + $.Method({ Public: true, Static: true }, "op_Equality", + new JSIL.MethodSignature($.Boolean, [$jsilcore.TypeRef("System.Reflection.MemberInfo"), $jsilcore.TypeRef("System.Reflection.MemberInfo")]), + JSIL.ObjectEquals + ); + + $.Method({ Public: true, Static: true }, "op_Inequality", + new JSIL.MethodSignature($.Boolean, [$jsilcore.TypeRef("System.Reflection.MemberInfo"), $jsilcore.TypeRef("System.Reflection.MemberInfo")]), + function (lhs, rhs) { + return !JSIL.ObjectEquals(lhs, rhs); + } + ); }; /*? }*/ \ No newline at end of file diff --git a/JSIL.Libraries/Includes/Core/Types/Classes/System.Array.js b/JSIL.Libraries/Includes/Core/Types/Classes/System.Array.js index 86b046fab..6625200a5 100644 --- a/JSIL.Libraries/Includes/Core/Types/Classes/System.Array.js +++ b/JSIL.Libraries/Includes/Core/Types/Classes/System.Array.js @@ -96,6 +96,10 @@ JSIL.MakeClass("System.Object", "System.Array", true, [], function ($) { $.RawMethod(true, "Of$NoInitialize", of); $.RawMethod(true, "Of", of); + + $.ImplementInterfaces( + $jsilcore.TypeRef("System.Collections.IEnumerable") + ); }); JSIL.ImplementExternals( diff --git a/JSIL.Libraries/Includes/Core/Types/Classes/System.Enum.js b/JSIL.Libraries/Includes/Core/Types/Classes/System.Enum.js index e487fa97f..52d732ff9 100644 --- a/JSIL.Libraries/Includes/Core/Types/Classes/System.Enum.js +++ b/JSIL.Libraries/Includes/Core/Types/Classes/System.Enum.js @@ -8,7 +8,14 @@ JSIL.ImplementExternals("System.Enum", function ($) { $.Method({ Static: true, Public: true }, "ToObject", (new JSIL.MethodSignature($.Object, ["System.Type", $.Int32], [])), function ToObject(enumType, value) { - return enumType[enumType.__ValueToName__[value]]; + return enumType.__PublicInterface__[enumType.__ValueToName__[value]]; + } + ); + + $.Method({ Static: true, Public: true }, "ToObject", + (new JSIL.MethodSignature($.Object, ["System.Type", $.Object], [])), + function ToObject(enumType, value) { + return enumType.__PublicInterface__[enumType.__ValueToName__[value.valueOf()]]; } ); diff --git a/JSIL.Libraries/Includes/Core/Types/Classes/System.Object.js b/JSIL.Libraries/Includes/Core/Types/Classes/System.Object.js index 0bc8de666..f5d20b525 100644 --- a/JSIL.Libraries/Includes/Core/Types/Classes/System.Object.js +++ b/JSIL.Libraries/Includes/Core/Types/Classes/System.Object.js @@ -111,25 +111,5 @@ }); JSIL.MakeClass(Object, "System.Object", true, [], function ($) { - $.ExternalMethod({ Static: false, Public: true }, ".ctor", - new JSIL.MethodSignature(null, [], [], $jsilcore) - ); - - $.ExternalMethod({ Static: false, Public: true }, "GetType", - new JSIL.MethodSignature("System.Type", [], [], $jsilcore) - ); - - $.ExternalMethod({ Static: false, Public: true }, "Object.Equals", - new JSIL.MethodSignature("System.Boolean", [$.Type], [], $jsilcore) - ); - - $.ExternalMethod({ Static: false, Public: true }, "MemberwiseClone", - new JSIL.MethodSignature("System.Object", [], [], $jsilcore) - ); - - $.ExternalMethod({ Static: false, Public: true }, "toString", - new JSIL.MethodSignature("System.String", [], [], $jsilcore) - ); - $jsilcore.SystemObjectInitialized = true; }); \ No newline at end of file diff --git a/JSIL.Libraries/JSIL.Libraries.csproj b/JSIL.Libraries/JSIL.Libraries.csproj index 10b54ee0a..009adc939 100644 --- a/JSIL.Libraries/JSIL.Libraries.csproj +++ b/JSIL.Libraries/JSIL.Libraries.csproj @@ -191,6 +191,12 @@ + + + + + + diff --git a/JSIL.Libraries/Sources/JSIL.Core.js b/JSIL.Libraries/Sources/JSIL.Core.js index 3ce369719..05e3d69c3 100644 --- a/JSIL.Libraries/Sources/JSIL.Core.js +++ b/JSIL.Libraries/Sources/JSIL.Core.js @@ -1572,7 +1572,7 @@ JSIL.GenericParameter.prototype.get_IsGenericParameter = function () { }; JSIL.GenericParameter.prototype.get_Name = function () { - return this.name.humanReadable; + return this.__ShortName__; }; JSIL.GenericParameter.prototype.__IsClosed__ = false; @@ -1580,7 +1580,11 @@ JSIL.GenericParameter.prototype.__IsClosed__ = false; JSIL.PositionalGenericParameter = function (name, context) { this.index = parseInt(name.substr(2)); - JSIL.SetValueProperty(this, "__TypeId__", name); + var realName = name; + if (typeof (context) !== "undefined" && typeof (context.genericArgumentNames) !== "undefined") { + realName = context.genericArgumentNames[this.index]; + } + JSIL.SetValueProperty(this, "__TypeId__", realName); this.__Context__ = context || $jsilcore; var fullNameDecl = { @@ -1596,7 +1600,7 @@ JSIL.PositionalGenericParameter = function (name, context) { JSIL.PositionalGenericParameter.prototype = Object.create(JSIL.TypeObjectPrototype); JSIL.PositionalGenericParameter.prototype.getFullName = function () { - return "!!" + this.index; + return this.__TypeId__; }; JSIL.PositionalGenericParameter.prototype.get = function (context) { @@ -1624,7 +1628,7 @@ JSIL.PositionalGenericParameter.prototype.get_IsGenericParameter = function () { }; JSIL.PositionalGenericParameter.prototype.get_Name = function () { - return "!!" + this.index; + return this.__TypeId__; }; JSIL.PositionalGenericParameter.prototype.__IsClosed__ = false; @@ -6166,13 +6170,12 @@ JSIL.GetType = function (value) { else if (JSIL.IsTypedArray(value)) return JSIL.$GetTypeForTypedArray(value); else if (JSIL.IsArray(value)) - return System.Array.__Type__; + return System.Array.Of(System.Object).__Type__; else return System.Object.__Type__; } else if (type === "string") { return System.String.__Type__; - } else if (type === "number") { if (value === (value | 0)) return System.Int32.__Type__; @@ -8972,14 +8975,14 @@ JSIL.GetReflectionCache = function (typeObject) { var makeTypeInstance = function (type) { // Construct the appropriate subclass of MemberInfo - var parsedTypeName = JSIL.ParseTypeName("System.Reflection." + type); + var parsedTypeName = JSIL.ParseTypeName("System.Reflection.Runtime" + type); var infoType = JSIL.GetTypeInternal(parsedTypeName, $jsilcore, true); var info = JSIL.CreateInstanceOfType(infoType, null); /* // Don't trigger type initialization machinery // FIXME: This will break if any of the memberinfo types rely on static constructors. - var infoType = JSIL.GetTypeByName("System.Reflection." + type, $jsilcore); + var infoType = JSIL.GetTypeByName("System.Reflection.Runtime" + type, $jsilcore); var info = Object.create(infoType.prototype); */ @@ -9015,7 +9018,8 @@ JSIL.GetReflectionCache = function (typeObject) { // Scans the specified type (and its base types, as necessary) to retrieve all the MemberInfo instances appropriate for a request. // If any BindingFlags are specified in flags they are applied as filters to limit the number of members returned. // If memberType is specified and is the short name of a MemberInfo subclass like 'FieldInfo', only members of that type are returned. -JSIL.GetMembersInternal = function (typeObject, flags, memberType, name) { +JSIL.GetMembersInternal = function (typeObject, flags, memberType, name, hideMembers) { + hideMembers |= false; var result = []; var bindingFlags = $jsilcore.BindingFlags; @@ -9039,61 +9043,115 @@ JSIL.GetMembersInternal = function (typeObject, flags, memberType, name) { if (staticOnly && instanceOnly) staticOnly = instanceOnly = false; - var members = []; + var processedProperties = {}; + var processedEvents = {}; + + var shouldProcessProperty= function(property, processed) { + if (property._descriptor.Name in processed) { + var processedList = processed[property._descriptor.Name]; + for (var i = 0, l = processedList.length; i < l; i++) { + if ($jsilcore.System.Type.op_Equality(processedList[i].get_PropertyType(), property.get_PropertyType())) { + var processedParameters = processedList[i].GetIndexParameters(); + var currentParameters = property.GetIndexParameters(); + if (processedParameters.length !== currentParameters.length) { + continue; + } + for (var pi = 0, pl = processedParameters.length; pi < pl; pi++) { + if ($jsilcore.System.Type.op_Inequality(processedParameters[pi].get_ParameterType(), currentParameters[pi].get_ParameterType())) { + continue; + } + } + return false; + } + } + processedList.push(property); + } else { + processed[property._descriptor.Name] = [property]; + } + return true; + } + var shouldProcessEvent = function(event, processed) { + if (event._descriptor.Name in processed) { + return false; + } else { + processed[event._descriptor.Name] = [event._descriptor.Name]; + } + return true; + } + var target = typeObject; + var baseTypeProcessing = false; while (target !== null) { var targetMembers = JSIL.GetReflectionCache(target); if (targetMembers === null) break; - members = targetMembers.concat(members); + for (var i = 0, l = targetMembers.length; i < l; i++) { + var member = targetMembers[i]; - if (!allowInherited) - break; + // HACK: Reflection never seems to enumerate static constructors. This is probably because + // it doesn't make any sense to invoke them explicitly anyway, and they don't have arguments... + if ( + !allMethodsIncludingSpecialNames && + member._descriptor.Static && + member._descriptor.SpecialName && + member._descriptor.Name.indexOf("cctor") >= 0 + ) + continue; - target = target.__BaseType__; - } + if (publicOnly && !member._descriptor.Public) + continue; + else if (nonPublicOnly && member._descriptor.Public) + continue; - for (var i = 0, l = members.length; i < l; i++) { - var member = members[i]; + if (staticOnly && !member._descriptor.Static) + continue; + else if (instanceOnly && member._descriptor.Static) + continue; - // HACK: Reflection never seems to enumerate static constructors. This is probably because - // it doesn't make any sense to invoke them explicitly anyway, and they don't have arguments... - if ( - !allMethodsIncludingSpecialNames && - member._descriptor.Static && - member._descriptor.SpecialName && - member._descriptor.Name.indexOf("cctor") >= 0 - ) - continue; + var currentMemberType = member.__MemberType__; + if (methodOrConstructor) { + if ( + (currentMemberType !== "MethodInfo") && + (currentMemberType !== "ConstructorInfo") + ) + continue; + } else if ((typeof (memberType) === "string") && (memberType !== currentMemberType)) { + continue; + } - if (publicOnly && !member._descriptor.Public) - continue; - else if (nonPublicOnly && member._descriptor.Public) - continue; + if ((typeof (name) === "string") && (name !== member._descriptor.Name)) { + continue; + } - if (staticOnly && !member._descriptor.Static) - continue; - else if (instanceOnly && member._descriptor.Static) - continue; + if (hideMembers) { + if (baseTypeProcessing) { + if (currentMemberType === "ConstructorInfo") + continue; - var currentMemberType = member.__ThisType__.__ShortName__; - if (methodOrConstructor) { - if ( - (currentMemberType != "MethodInfo") && - (currentMemberType != "ConstructorInfo") - ) - continue; - } else if ((typeof (memberType) === "string") && (memberType != currentMemberType)) { - continue; - } + // HACK: Do this check only if type system already prepared. + if (currentMemberType === "PropertyInfo" && !shouldProcessProperty(member, processedProperties)) + continue; - if ((typeof (name) === "string") && (name != member._descriptor.Name)) { - continue; + if (currentMemberType === "EventInfo" && !shouldProcessEvent(member, processedEvents)) + continue; + } else { + if (currentMemberType === "PropertyInfo") + shouldProcessProperty(member, processedProperties); + if (currentMemberType === "EventInfo") + shouldProcessEvent(member, processedProperties); + } + } + + result.push(member); } - result.push(member); + if (!allowInherited) + break; + + baseTypeProcessing = true; + target = target.__BaseType__; } return result; @@ -9664,7 +9722,7 @@ JSIL.GetMemberAttributes = function (memberInfo, inherit, attributeType, result) } return result; - } else if (memberType === "System.Reflection.MethodInfo" && memberInfo._descriptor.Virtual) { + } else if (memberType === "System.Reflection.RuntimeMethodInfo" && memberInfo._descriptor.Virtual) { var currentType = memberInfo.get_DeclaringType(); while (currentType && currentType.GetType) { var foundMethod = JSIL.GetMethodInfo(currentType.__PublicInterface__, memberInfo.get_Name(), memberInfo._data.signature, false, null); diff --git a/Proxies/Array.cs b/Proxies/Array.cs index 4aabd369f..68773751c 100644 --- a/Proxies/Array.cs +++ b/Proxies/Array.cs @@ -168,6 +168,30 @@ public static int BinarySearch(T[] array, int startIndex, int length, T value throw new InvalidOperationException(); } + [JSReplacement("JSIL.Array.New($elementType, $size)")] + internal static System.Array UnsafeCreateInstance(Type elementType, Int32 size) + { + throw new InvalidOperationException(); + } + + [JSReplacement("JSIL.MultidimensionalArray.New.apply(null, [$elementType].concat($sizes))")] + internal static System.Array UnsafeCreateInstance(Type elementType, AnyType[] sizes) + { + throw new InvalidOperationException(); + } + + [JSReplacement("JSIL.MultidimensionalArray.New($elementType, $sizeX, $sizeY)")] + internal static System.Array UnsafeCreateInstance(Type elementType, AnyType sizeX, AnyType sizeY) + { + throw new InvalidOperationException(); + } + + [JSReplacement("JSIL.MultidimensionalArray.New($elementType, $sizeX, $sizeY, $sizeZ)")] + internal static System.Array UnsafeCreateInstance(Type elementType, AnyType sizeX, AnyType sizeY, AnyType sizeZ) + { + throw new InvalidOperationException(); + } + /*Mono methods*/ [JSReplacement("$array[$index]")] internal static T UnsafeLoad(T[] array, int index) diff --git a/Proxies/BCL/JSIL.Bootstrap.cs b/Proxies/BCL/JSIL.Bootstrap.cs index b73d5c410..86547e895 100644 --- a/Proxies/BCL/JSIL.Bootstrap.cs +++ b/Proxies/BCL/JSIL.Bootstrap.cs @@ -142,6 +142,12 @@ public class System_Threading_Volatile { } + [JSProxy(typeof(SemaphoreSlim), JSProxyMemberPolicy.ReplaceNone, JSProxyAttributePolicy.ReplaceDeclared, JSProxyInterfacePolicy.ReplaceNone, false)] + [JSStubOnly] + public class System_Threading_SemaphoreSlim + { + } + [JSProxy(typeof(Comparer<>), JSProxyMemberPolicy.ReplaceNone, JSProxyAttributePolicy.ReplaceDeclared, JSProxyInterfacePolicy.ReplaceNone, false)] [JSStubOnly] public class System_Collections_Generic_Comparer_1 diff --git a/Proxies/SuppressDeclaration.cs b/Proxies/SuppressDeclaration.cs index f24772108..4bbdfe833 100644 --- a/Proxies/SuppressDeclaration.cs +++ b/Proxies/SuppressDeclaration.cs @@ -14,6 +14,7 @@ typeof (MemberInfo), typeof (MethodBase), typeof (MethodInfo), typeof (FieldInfo), typeof (ConstructorInfo), typeof (PropertyInfo), typeof (EventInfo), + typeof (ParameterInfo), typeof (Array), typeof (Delegate), typeof (MulticastDelegate), typeof (Byte), typeof (SByte), typeof (UInt16), typeof (Int16), @@ -22,7 +23,6 @@ typeof (Single), typeof (Double), typeof (Boolean), typeof (Char), typeof (Assembly), - typeof (Attribute), typeof (Decimal), typeof (IntPtr), typeof (UIntPtr), typeof (NumberFormatInfo) @@ -37,7 +37,13 @@ public class SuppressDeclarationByType new[] { "System.Reflection.TypeInfo", "System.RuntimeType", - "System.Reflection.RuntimeAssembly" + "System.Reflection.RuntimeAssembly", + "System.Reflection.RuntimeMethodInfo", + "System.Reflection.RuntimeFieldInfo", + "System.Reflection.RuntimeConstructorInfo", + "System.Reflection.RuntimePropertyInfo", + "System.Reflection.RuntimeEventInfo", + "System.Reflection.RuntimeParameterInfo", }, inheritable: false)] [JSSuppressTypeDeclaration] diff --git a/Tests/ReflectionTestCases/FailsOnMono/GetBaseDefinition.cs b/Tests/ReflectionTestCases/FailsOnMono/GetBaseDefinition.cs new file mode 100644 index 000000000..a62fb2962 --- /dev/null +++ b/Tests/ReflectionTestCases/FailsOnMono/GetBaseDefinition.cs @@ -0,0 +1,103 @@ +using System; +using System.Linq; +using System.Reflection; + +public static class Program +{ + public static void Main(string[] args) + { + WriteMethods(typeof(Derived2)); + //WriteMethods(typeof(Derived2<,>)); //TODO: Look on generic arguments for open generics. + WriteMethods(typeof(Derived2)); + WriteMethods(typeof(PartialGenericHolder<>).GetField("Holder").FieldType); + } + + public static void WriteMethods(Type type) + { + WriteInfo(GetParent(type.GetMethod("Method1"))); + WriteInfo(GetParent(type.GetMethod("Method2"))); + WriteInfo(GetParent(type.GetMethod("NonVirtualMethod"))); + WriteInfo(GetParent(type.GetMethod("GenericMethod"))); + WriteInfo(GetParent(type.GetMethod("GenericMethod").MakeGenericMethod(typeof(Base), typeof(Base)))); + Console.WriteLine(); + } + + public static void WriteInfo(MethodInfo item) + { + if (item == null) + { + Console.WriteLine("null"); + return; + } + + Console.WriteLine( + "{0} {3}.{1}({2})", + item.ReturnType.Name, + item.Name, + string.Join(", ", item.GetParameters().Select(parameter => parameter.ParameterType.Name).ToArray()), + item.DeclaringType.IsGenericType + ? string.Format( + "{0}<{1}>", + item.DeclaringType.Name, + string.Join(",", item.DeclaringType.GetGenericArguments().Select(arg => arg.Name).ToArray())) + : item.DeclaringType.Name); + } + + private static MethodInfo GetParent(MethodInfo item) + { + return item.GetBaseDefinition(); + } +} + +public class Base +{ + public virtual void Method1() { } + public virtual void Method2() { } + + public void NonVirtualMethod() { } + public virtual void GenericMethod(TA in1, TB in2) { } +} + +public class Derived1 : Base +{ + public override void Method1() { } +} + +public class Derived2 : Derived1 +{ + public sealed override void Method1() { } + public override void Method2() { } + + + public new void NonVirtualMethod() { } + public override void GenericMethod(TA in1, TB in2) { } +} + +public class Base +{ + public virtual void Method1() { } + public virtual void Method2() { } + + public void NonVirtualMethod() { } + public virtual void GenericMethod(TA in1, TB in2) { } +} + +public class Derived1 : Base +{ + public override void Method1() { } +} + +public class Derived2 : Derived1 +{ + public sealed override void Method1() { } + public override void Method2() { } + + + public new void NonVirtualMethod() { } + public override void GenericMethod(TA in1, TB in2) { } +} + +public class PartialGenericHolder +{ + public Derived2 Holder; +} \ No newline at end of file diff --git a/Tests/ReflectionTestCases/FailsOnMono/GetParentDefinition.cs b/Tests/ReflectionTestCases/FailsOnMono/GetParentDefinition.cs new file mode 100644 index 000000000..c2eb4ff43 --- /dev/null +++ b/Tests/ReflectionTestCases/FailsOnMono/GetParentDefinition.cs @@ -0,0 +1,105 @@ +using System; +using System.Linq; +using System.Reflection; + +public static class Program +{ + public static void Main(string[] args) + { + WriteMethods(typeof(Derived2)); + WriteMethods(typeof(Derived2<,>)); + WriteMethods(typeof(Derived2)); + WriteMethods(typeof(PartialGenericHolder<>).GetField("Holder").FieldType); + } + + public static void WriteMethods(Type type) + { + WriteInfo(GetParent(type.GetMethod("Method1"))); + WriteInfo(GetParent(type.GetMethod("Method2"))); + WriteInfo(GetParent(type.GetMethod("NonVirtualMethod"))); + WriteInfo(GetParent(type.GetMethod("GenericMethod"))); + WriteInfo(GetParent(type.GetMethod("GenericMethod").MakeGenericMethod(typeof(Base), typeof(Base)))); + Console.WriteLine(); + } + + public static void WriteInfo(MethodInfo item) + { + if (item == null) + { + Console.WriteLine("null"); + return; + } + + Console.WriteLine( + "{0} {3}.{1}({2})", + item.ReturnType.Name, + item.Name, + string.Join(", ", item.GetParameters().Select(parameter => parameter.ParameterType.Name).ToArray()), + item.DeclaringType.IsGenericType + ? string.Format( + "{0}<{1}>", + item.DeclaringType.Name, + string.Join(",", item.DeclaringType.GetGenericArguments().Select(arg => arg.Name).ToArray())) + : item.DeclaringType.Name); + } + + private static MethodInfo GetParent(MethodInfo item) + { + var getParentDefinitionMI = item.GetType().GetMethod("GetParentDefinition", BindingFlags.Instance | BindingFlags.NonPublic); + return (MethodInfo)getParentDefinitionMI.Invoke(item, null); + + } +} + +public class Base +{ + public virtual void Method1() { } + public virtual void Method2() { } + + public void NonVirtualMethod() { } + public virtual void GenericMethod(TA in1, TB in2) { } +} + +public class Derived1 : Base +{ + public override void Method1() { } +} + +public class Derived2 : Derived1 +{ + public sealed override void Method1() { } + public override void Method2() { } + + + public new void NonVirtualMethod() { } + public override void GenericMethod(TA in1, TB in2) { } +} + +public class Base +{ + public virtual void Method1() { } + public virtual void Method2() { } + + public void NonVirtualMethod() { } + public virtual void GenericMethod(TA in1, TB in2) { } +} + +public class Derived1 : Base +{ + public override void Method1() { } +} + +public class Derived2 : Derived1 +{ + public sealed override void Method1() { } + public override void Method2() { } + + + public new void NonVirtualMethod() { } + public override void GenericMethod(TA in1, TB in2) { } +} + +public class PartialGenericHolder +{ + public Derived2 Holder; +} \ No newline at end of file diff --git a/Tests/SimpleTestCases/ArrayType.cs b/Tests/SimpleTestCases/ArrayType.cs new file mode 100644 index 000000000..e739ee4ef --- /dev/null +++ b/Tests/SimpleTestCases/ArrayType.cs @@ -0,0 +1,13 @@ +using System; + +public static class Program { + public static void Main () + { + Write(new object[] {1, 2, 3}); + } + + public static void Write(object input) + { + Console.WriteLine(input.GetType()); + } +} diff --git a/Tests/SimpleTestCases/FailsOnMono/ArrayEmpty.cs b/Tests/SimpleTestCases/FailsOnMono/ArrayEmpty.cs new file mode 100644 index 000000000..cdbcac510 --- /dev/null +++ b/Tests/SimpleTestCases/FailsOnMono/ArrayEmpty.cs @@ -0,0 +1,30 @@ +using System; + +public static class Program { + public static void Main (string[] args) + { + var emptyObj1 = Array.Empty(); + var emptyObj2 = Array.Empty(); + var intObj1 = Array.Empty(); + var intObj2= Array.Empty(); + + Console.WriteLine(emptyObj1.GetType()); + Console.WriteLine(intObj1.GetType()); + Console.WriteLine(emptyObj1 == emptyObj2 ? "true" : "false"); + Console.WriteLine(intObj1 == intObj2 ? "true" : "false"); + Console.WriteLine(Equals(emptyObj1, intObj1) ? "true" : "false"); + } +} + +public static class A +{ + public static T[] Empty() + { + return EmptyArray.Value; + } + + internal static class EmptyArray + { + public static readonly T[] Value = new T[0]; + } +} \ No newline at end of file diff --git a/Tests/SimpleTestCases/FailsOnMono/ReflectionTypes.cs b/Tests/SimpleTestCases/FailsOnMono/ReflectionTypes.cs new file mode 100644 index 000000000..3a87c7185 --- /dev/null +++ b/Tests/SimpleTestCases/FailsOnMono/ReflectionTypes.cs @@ -0,0 +1,38 @@ +using System; + +public static class Program { + public static void Main () + { + Console.WriteLine(typeof(TestClass).GetType()); + Console.WriteLine(typeof(TestClass).Assembly.GetType()); + Console.WriteLine(typeof(TestClass).GetConstructor(new Type[0]).GetType()); + Console.WriteLine(typeof(TestClass).GetMethod("Method").GetType()); + Console.WriteLine(typeof(TestClass).GetMethod("Method").GetParameters()[0].GetType()); + Console.WriteLine(typeof(TestClass).GetProperty("Property").GetType()); + Console.WriteLine(typeof(TestClass).GetEvents()[0].GetType()); + + var fieldRuntimeType = typeof (TestClass).GetField("Field").GetType().FullName; + Console.WriteLine(fieldRuntimeType == "System.Reflection.RuntimeFieldInfo" || + fieldRuntimeType == "System.Reflection.RtFieldInfo" + ? "System.Reflection.RuntimeFieldInfo" + : fieldRuntimeType); + } +} + +public class TestClass +{ + public int Field; + + public event EventHandler Event; + + public TestClass() + { + } + + public int Property { get; set; } + + public void Method(int arg) + { + + } +} \ No newline at end of file diff --git a/Tests/SimpleTestCases/Issue844.cs b/Tests/SimpleTestCases/Issue844.cs new file mode 100644 index 000000000..e9aacb7aa --- /dev/null +++ b/Tests/SimpleTestCases/Issue844.cs @@ -0,0 +1,8 @@ +using System; +public static class Program +{ + public static void Main() + { + Console.WriteLine(typeof(object).GetConstructors().Length); + } +} \ No newline at end of file diff --git a/Tests/SimpleTestCases/ReflectionPositionalGenericNames_Issue509.cs b/Tests/SimpleTestCases/ReflectionPositionalGenericNames_Issue509.cs new file mode 100644 index 000000000..7bfc49d31 --- /dev/null +++ b/Tests/SimpleTestCases/ReflectionPositionalGenericNames_Issue509.cs @@ -0,0 +1,14 @@ +using System; + +public static class Program +{ + public static void Main(string[] args) + { + Console.WriteLine(typeof(Program).GetMethod("TestMethod").ReturnType.Name); + } + + public static T TestMethod() + { + return default(T); + } +} \ No newline at end of file diff --git a/Tests/SimpleTestCasesForTranslatedBcl/FailsOnMono/Attributes.cs b/Tests/SimpleTestCasesForTranslatedBcl/FailsOnMono/Attributes.cs new file mode 100644 index 000000000..461a7eb7c --- /dev/null +++ b/Tests/SimpleTestCasesForTranslatedBcl/FailsOnMono/Attributes.cs @@ -0,0 +1,49 @@ +using System; +using System.Reflection; + +public static class Program +{ + public static void Main(string[] args) + { + WriteInfo(typeof(Derived).GetProperty("Prop")); + } + + public static void WriteInfo(MemberInfo item) + { + Console.WriteLine(item.Name); + Console.WriteLine(Attribute.GetCustomAttributes(item, typeof(CustomAttribute), false).Length); + Console.WriteLine(Attribute.GetCustomAttributes(item, typeof(CustomAttribute), true).Length); + + Console.WriteLine(item.GetCustomAttributes(typeof(CustomAttribute), false).Length); + Console.WriteLine(item.GetCustomAttributes(typeof(CustomAttribute), true).Length); + } +} + +public class Base +{ + [Custom] + public virtual int Prop { get; set; } + + public virtual void Method1() { } + + [Custom] + public virtual void Method2() { } + + [Custom] + public void NonVirtualMethod() { } + + [Custom] + public virtual void GenericMethod(TA in1) { } +} + +public class Derived : Base +{ + public override int Prop { get; set; } +} + + +[AttributeUsage(AttributeTargets.All, Inherited = true)] +public class CustomAttribute : Attribute +{ + public Type T; +} \ No newline at end of file diff --git a/Tests/SimpleTests.csproj b/Tests/SimpleTests.csproj index f002cb30f..bd6d9f99e 100644 --- a/Tests/SimpleTests.csproj +++ b/Tests/SimpleTests.csproj @@ -111,6 +111,7 @@ + @@ -129,6 +130,11 @@ + + + + + diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index dafdf9868..7f8e2c1e3 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -291,6 +291,8 @@ + +