polytronicgr / sharpkit

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

System.String.GetEnumerator() not working #363

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If I try to run a foreach statement on a string, I get an exception. It looks 
like the jsclr.js implementation of String.GetEnumerator() is calling a 
CharEnumerator constructor that does not actually exist.

Original issue reported on code.google.com by filp...@tin.it on 25 Aug 2014 at 3:21

GoogleCodeExporter commented 8 years ago
Intersting, the code for CharEnumerator is here:
https://github.com/SharpKit/SharpKit-SDK/blob/master/Frameworks/JsClr/System/Str
ingEnumerator.cs

But I'll check it out too.

Original comment by DanelK...@gmail.com on 25 Aug 2014 at 3:42

GoogleCodeExporter commented 8 years ago
Thanks Danel. In my jsclr.js I find this:

var System$CharEnumerator = {
    fullname: "System.CharEnumerator",
    baseTypeName: "System.Object",
    assemblyName: "SharpKit.JsClr",
    interfaceNames: ["System.Collections.Generic.IEnumerator$1", "System.Collections.IEnumerator"],
    Kind: "Class",
    definition: {
        ctor: function (str2){
...

and then this:

String.prototype._toString = String.prototype.toString;
JsTypes.push({ fullname: "System.String", baseTypeName: "System.Object", 
definition:
{
    ctor: String,
    GetEnumerator: function () {
        return new System.CharEnumerator.ctor$$String(this);
    },
...

when that String.GetEnumerator gets called, it throws because the constructor's 
name is "ctor" and not "ctor$$String".

Original comment by filp...@tin.it on 25 Aug 2014 at 3:53