Attempting to initialise a list from an array fails at run time.
[JsType(JsMode.Clr, Filename = "res/Init.js")]
public static class Init
{
public static void createList()
{
var numbers = new[] { 4, 5, 6};
var aList = new List<int>(numbers);
new jQuery(HtmlContext.document.body).append(aList.ToString());
}
}
[JsType(JsMode.Global, Filename = "res/Default.js")]
public class DefaultClient
{
static void DefaultClient_Load()
{
new jQuery(HtmlContext.document.body).append("Ready<br/>");
}
static void btnTest_click(DOMEvent e)
{
Init.createList();
}
}
The issue is that GetEnumerator is missing
Uncaught TypeError: Object #<Int32Array> has no method 'GetEnumerator'
jsclr.js:6861
System$Collections$Generic$List$1.definition.AddRange jsclr.js:6861
System$Collections$Generic$List$1.definition.ctor$$IEnumerable$1 jsclr.js:6819
SharpKitWebApp1$Init.staticDefinition.createList Init.js:15
btnTest_click Default.js:8
onclick
/*Generated by SharpKit 5 v5.2.0*/
You can workaround it by copying the type initialisation from the array e.g.
JsTypes.push({
fullname: "Int32Array",
definition:
{
GetEnumerator: function () {
return new ArrayEnumerator.ctor(this);
}
}
});
Original issue reported on code.google.com by co...@gravill.com on 7 Aug 2013 at 12:44
Original issue reported on code.google.com by
co...@gravill.com
on 7 Aug 2013 at 12:44