JSIL.Core Array.new

Please report bugs here. If you are unsure whether something is a bug or an expected behavior, please post it on the "Technical Support" forum instead, and wait for a moderator to handle/move the post.
CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

JSIL.Core Array.new

Postby CyborgDE » Sat Sep 12, 2015 11:08 pm

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

JS-Support @Userware
Site Admin
Posts: 1093
Joined: Tue Apr 08, 2014 3:42 pm

Re: JSIL.Core Array.new

Postby JS-Support @Userware » Wed Sep 16, 2015 7:33 am

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

CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

Re: JSIL.Core Array.new

Postby CyborgDE » Wed Sep 16, 2015 10:10 am

Hello,

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

Regards, Uwe

CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

Re: JSIL.Core Array.new

Postby CyborgDE » Mon Oct 05, 2015 12:23 am

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

CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

Re: JSIL.Core Array.new

Postby CyborgDE » Sun Oct 25, 2015 7:06 am

Hello,

not solved in Beta 5.1 !

Regards,
Uwe

CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

Re: JSIL.Core Array.new

Postby CyborgDE » Fri Apr 29, 2016 11:53 pm

Hello,

still not solved ...

JSIL.Core.js 9194 :

Code: Select all

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


Regards,
Uwe


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 1 guest