Page 1 of 1

JSIL.Core Array.new

Posted: Sat Sep 12, 2015 11:08 pm
by CyborgDE
Hello,

I must made there changes in JSIL.Core Line 8788 to prevent a exception :

Code: Select all

JSIL.Array.New = function Array_New (elementType, sizeOrInitializer) {
  var elementTypeObject = null, elementTypePublicInterface = null;

  if (typeof (elementType.__Type__) === "object") {
    elementTypeObject = elementType.__Type__;
    elementTypePublicInterface = elementType;
  } else if (typeof (elementType.__PublicInterface__) !== "undefined") {
    elementTypeObject = elementType;
    elementTypePublicInterface = elementType.__PublicInterface__;
  }

  var result = null, size = 0;
  var initializerIsArray = JSIL.IsArray(sizeOrInitializer);

  if (initializerIsArray) {
    size = sizeOrInitializer.length;
  } else {
    size = Number(sizeOrInitializer);
+   if (size.toString() == "NaN") {
+      size = 0;
+   }
  }


Regard,
Uwe

Re: JSIL.Core Array.new

Posted: Wed Sep 16, 2015 7:33 am
by JS-Support @Userware
Hello,

Thanks a lot for the contribution!

In order for us to keep track of the changes and cover them with unit tests, may I ask you an example of C# line of code that causes the exception? In fact, I have tested several different array initialization syntax with the following code but I am unable to reproduce the exception:

Code: Select all

            string[] array1 = new string[2];
            string[] array2 = new string[] { "A", "B" };
            string[] array3 = { "A", "B" };


Thanks again,
Regards,
JS-Support

Re: JSIL.Core Array.new

Posted: Wed Sep 16, 2015 10:10 am
by CyborgDE
Hello,

sorry, I'm not sure, but I think it comes from a type.GetGenericArguments()
and the Size was defined with NaN.

Regards, Uwe

Re: JSIL.Core Array.new

Posted: Mon Oct 05, 2015 12:23 am
by CyborgDE
Hello,

not solved in Beta 5 !

It comes from :

Code: Select all

$.Method({Static:false, Public:true }, "GetGenericArguments",
      (new JSIL.MethodSignature($jsilcore.TypeRef("System.Array", [$.Type]), [], [])),
      function GetGenericArguments () {
        return JSIL.Array.New(typeReference.get(), this.__GenericArgumentValues__);
      }
    );


The parameter sizeOrInitializer is undefined and then

Code: Select all

    size = Number(sizeOrInitializer);

gives a "NaN as size !!!

Regards, Uwe

Re: JSIL.Core Array.new

Posted: Sun Oct 25, 2015 7:06 am
by CyborgDE
Hello,

not solved in Beta 5.1 !

Regards,
Uwe

Re: JSIL.Core Array.new

Posted: Fri Apr 29, 2016 11:53 pm
by CyborgDE
Hello,

still not solved ...

JSIL.Core.js 9194 :

Code: Select all

    size = Number(sizeOrInitializer);
+    if (size.toString() == "NaN") {
+      size = 0;
+   }


Regards,
Uwe