polytronicgr / sharpkit

Automatically exported from code.google.com/p/sharpkit
0 stars 0 forks source link

Array values can get converted into their element values #339

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Compile the following code and note the comment:

    [JsType(JsMode.Clr, Filename = "res/Default.js")]
    public class TestClasses
    {
        public TestClasses()
        {
            // new[] { "foo" } gets converted into "foo" -- the array is destroyed and so the code will
            // break since M expects an array.
            M(new[] { "foo" });
        }

        private void M(params string[] s)
        {
        }
    }

Note the compiled result:

        ctor: function ()
        {
            System.Object.ctor.call(this);
            this.M("foo");
        },
        M: function (s)
        {
        }

It should have been:

        ctor: function ()
        {
            System.Object.ctor.call(this);
            this.M(["foo"]);  // <-- should have been an arry
        },
        M: function (s)
        {
        }

Original issue reported on code.google.com by kirk.w...@sqor.com on 14 Dec 2013 at 4:15

GoogleCodeExporter commented 8 years ago
This feature is already implemented, you can try it out by setting:
[JsMethod(NativeParams=false)] on the method with the params.

It is currently disabled because of backward compatibility. It needs to be 
changed.

Original comment by DanelK...@gmail.com on 12 Feb 2014 at 12:04

GoogleCodeExporter commented 8 years ago
Nice. Can we get a way to apply this assembly-wide?

Original comment by filp...@tin.it on 18 Sep 2014 at 1:24