mgusmano / sharpkit

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

Property initializers in ctors don't respect JsProperty.Name #261

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
    using SharpKit.JavaScript;
    [JsType(JsMode.Prototype, Filename = "~/Foo.js")]
    public class Foo
    {
        public Foo()
        {
            this.CSharpName = "Bar";
        }
        [JsProperty(Name = "jsName", NativeField = true)]
        public JsString CSharpName { get; private set; }
    }

I get the following JavaScript:

/*Generated by SharpKit 5 v5.00.0000*/
if (typeof(SharpKitWebApp1) == "undefined")
    var SharpKitWebApp1 = {};
SharpKitWebApp1.Foo = function ()
{
    this.CSharpName = null;
    this.jsName = "Bar";
};

So, the constructor in the JavaScript code nulls the C# property name instead 
of the name defined in the JsProperty attribute. A constructor that doesn't set 
CSharpName leaves the jsName property undefined.

----
-Michael Heyman

Original issue reported on code.google.com by DanelK...@gmail.com on 15 Dec 2012 at 1:10

GoogleCodeExporter commented 8 years ago

Original comment by DanelK...@gmail.com on 18 Dec 2012 at 3:20