Scramasax / sharpkit

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

Typed array and LINQ #311

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The typed arrays don't seem to be compatible with LINQ. They create the 
required enumerator but need the GetEnumerator e.g.

        public static void filterArray()
        {
            var numbers = new[] { 4, 5, 6};
            var filtered = numbers.Where(i => i > 5);
            foreach (var num in filtered)
            {
                new jQuery(HtmlContext.document.body).append(num.ToString());    
            }
        }

leads to an error:

Uncaught TypeError: Object #<Int32Array> has no method 'GetEnumerator' 
jsclr.js:5866
System$Linq$Enumerable$WhereEnumerableIterator.definition.MoveNext jsclr.js:5866
SharpKitWebApp1$Init.staticDefinition.filterArray

/*Generated by SharpKit 5 v5.2.0*/

You can workaround it by copying the type initialisation from the array e.g. 
for just the Int32Array case

JsTypes.push({
    fullname: "Int32Array",
    definition:
    {
        GetEnumerator: function () {
            return new ArrayEnumerator.ctor(this);
        }
    }
});

Original issue reported on code.google.com by co...@gravill.com on 8 Aug 2013 at 10:01

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
It's "fixed" with the given workarround, sdk rev. 1456.

Original comment by sebastia...@gmail.com on 4 Nov 2013 at 6:08

GoogleCodeExporter commented 9 years ago

Original comment by sebastia...@gmail.com on 4 Nov 2013 at 6:09

GoogleCodeExporter commented 9 years ago

Original comment by sebastia...@gmail.com on 4 Nov 2013 at 6:17