polytronicgr / sharpkit

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

Foreach explicitly implemented IEnumerable<T> fails #332

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If you explicitly implement IEnumerable<T> e.g.

    [JsType(JsMode.Clr, Filename = "res/Tester.js")]
    public class Points : IEnumerable<int>
    {
        IEnumerator<int> IEnumerable<int>.GetEnumerator()
        {
            yield return 1;
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            yield return 1;
        }
    }

Then attempt to foreach over it

    [JsType(JsMode.Clr, Filename = "res/Tester.js")]
    public class Tester
    {

        public static void TestEnumerating()
        {
            var points = new Points();

            foreach (var point in points)
            {
                new jQuery(HtmlContext.document.body).append("Point:" + point);
            }
        }
    }

It will fail at runtime with:

Uncaught TypeError: Object [object Object] has no method 'GetEnumerator' 
Tester.js:29
SharpKitWebApp4$Tester.staticDefinition.TestEnumerating Tester.js:29
btnTest_click Default.js:9
onclick

Using SharpKit 5.2.8

This may related to 

https://code.google.com/p/sharpkit/issues/detail?id=71

Original issue reported on code.google.com by co...@gravill.com on 4 Dec 2013 at 2:25