mgusmano / sharpkit

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

count() on Enumerable #151

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When I try to use count I get a JavaScript error

Uncaught TypeError: Object #<Object> has no method 'Count$1$$IEnumerable$1' 

Chrome (19.0.1084.56 m)

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

using SharpKit.JavaScript;
using SharpKit.Html4;
using SharpKit.jQuery;

namespace SharpKitWebApp1
{
    [JsType(JsMode.Global, Filename = "res/Default.js")]
    public class main : HtmlContext
    {
        public static void go()
        {
            IEnumerable<int> test = new List<int> { 1, 3, 4 };

            int testCount = test.Count();
        }
    }
}

/*Generated by SharpKit 5 v4.28.1000*/
function go()
{
    var test=(function()
    {
        var $v1=new System.Collections.Generic.List$1.ctor(System.Int32);
        $v1.Add(1);
        $v1.Add(3);
        $v1.Add(4);
        return $v1;
    }).call(this);
    var testCount=System.Linq.Enumerable.Count$1$$IEnumerable$1(System.Int32,test);
Uncaught TypeError: Object #<Object> has no method 'Count$1$$IEnumerable$1'
};

There's a count method implemented in:

http://code.google.com/p/sharpkit/source/browse/trunk/SharpKit.JsClr/System/Linq
/Linq.cs

Should it work in this situation? Inspecting the runtime object it has a count 
method but it's mangled down to Count$1 rather than the longer versions.

Original issue reported on code.google.com by co...@gravill.com on 18 Jun 2012 at 5:04

GoogleCodeExporter commented 8 years ago
Fixed in SVN, you can get latest and recompile to get it now.

Original comment by DanelK...@gmail.com on 18 Jun 2012 at 6:13