mgusmano / sharpkit

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

Default Interface attribute PropertiesAsFields and AutomaticPropertiesAsFields does not match to Default attribute for Classes #200

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
C# code:

public interface Iface
{
     Message message { get; set;}
}

[JsType(JsMode.Prototype)]
public class MyClass : Iface
{
     Message message { get; set;}
}

//generated coded
IFace a; a.message ---->  a.get_message //!!! not match with default attribute
MyClass b; b.message ---->  b.message //!!! not match with default attribute

//Resolve
[JsType(PropertiesAsFields=true)]
public interface Iface {...}

it solved by adding PropertiesAsFields to Iface but it take much time for me to 
solve it. I think the default behavior should be same.

Original issue reported on code.google.com by Madnik7@gmail.com on 16 Aug 2012 at 1:51

GoogleCodeExporter commented 8 years ago
The default attribute for all types is Clr mode - which means that the 
generated code is ok. You can add assembly level JsType attribute and change 
this behaviour. Although on interfaces you'll have to set Export=false to avoid 
compiler error - since interfaces cannot be exported in Prototype mode.

Original comment by DanelK...@gmail.com on 19 Aug 2012 at 7:25

GoogleCodeExporter commented 8 years ago
I think this is conceptual conflict. Perhaps when you implement "Support native 
javascript get/set properties", this conflict and all other get_ set_ conflict 
with native filed will be solved automatically. 

by the way in current version the following code generate wrong code.
       public static void foo2(Iface obj1, MyClass obj2)
        {
            var msg1 = obj1.message;
            var msg2 = obj2.message;
        }

    }

    [JsType(JsMode.Prototype, Export = false)]
    public interface Iface
    {
        JsString message { get; set; }
    }

    [JsType(JsMode.Prototype)]
    public class MyClass : Iface
    {
        private JsString _message;
        public JsString message
        {
            get { return _message; }
            set { _message = value; }
        }
    }

Generate:
shetab.common.Test.foo2 = function(obj1,obj2)
{
    var msg1=obj1.message;  /* RunTime ERROR */
    var msg2=obj2.get_message();  
};

Original comment by Madnik7@gmail.com on 19 Aug 2012 at 8:34

GoogleCodeExporter commented 8 years ago
AutomaticPropertiesAsFields is now being solved.

Original comment by DanelK...@gmail.com on 19 Aug 2012 at 1:33