In C#/.NET constants are inlined into the calling code instead of having a
reference to the constant. It would be nice for SharpKit to do this as well for
performance reasons.
Example code:
using SharpKit.JavaScript;
using SharpKit.Html4;
using SharpKit.jQuery;
namespace MyNamespace
{
[JsType(JsMode.Clr)]
public class MyClass
{
public const int MyConst = 10;
public void MyMethod()
{
int x = MyConst;
}
}
}
Gets compiled to:
/*@Generated by SharpKit v4.23.4000*/
if(typeof(JsTypes) == "undefined")
JsTypes = [];
var MyNamespace$MyClass=
{
fullname:"MyNamespace.MyClass",
baseTypeName:"System.Object",
staticDefinition:{MyConst:10},
assemblyName:"9c81f42b284046a88352d29b8daa12f5",
Kind:"Class",
definition:
{
ctor:function()
{
System.Object.ctor.call(this);
},
MyMethod:function()
{
var x=MyNamespace.MyClass.MyConst;
}
}
};
JsTypes.push(MyNamespace$MyClass);
It should be:
var x = 10
instead of var x = MyNamespace.MyClass.MyConst;
Original issue reported on code.google.com by warthog1...@gmail.com on 8 Mar 2012 at 5:46
Original issue reported on code.google.com by
warthog1...@gmail.com
on 8 Mar 2012 at 5:46