kevingadd/JSIL — Issue #71: Wrong generated code for overloaded constructors
Author: sejerpz
Created: 2012-02-22 23:01:55+00:00
State: open

This is the c# class snippet:
```
public class Element
{
private object _element;
public string DummyField;

public Element(string type)
: this(Verbatim.Expression("document.createElement(type)"))
{
this.DummyField = "initialized only from ctor 0";
}

public Element(object element)
{
this._element = element;
}

public static Element GetById(string id)
{
return new Element(Verbatim.Expression("document.getElementById(id)"));
}

[JSReplacement("$this._element.appendChild($childElement._element)")]
public virtual void AppendChild(Element childElement)
{
}

public string InnerHtml
{
get { return (string)Verbatim.Expression("this._element.innerHTML"); }
set { Verbatim.Expression("this._element.innerHTML = value"); }
}
}
```
This the JS code:

```
SIL.MakeClass(new JSIL.TypeRef($asm02, "System.Object"), "SimpleTest.Element", true, [], function ($) {
$.prototype._ctor$0 = function (element) {
$asm02.System.Object.prototype._ctor.call(this);
this._element = element;
};
$.prototype._ctor$1 = function (element) {
$asm02.System.Object.prototype._ctor.call(this);
this._element = element;
};
$.GetById = function (id) {
return JSIL.New($asm01.SimpleTest.Element, "_ctor$1", [document.getElementById(id)]);
};
$.prototype.get_InnerHtml = function () {
return JSIL.Cast(this._element.innerHTML, $asm02.System.String);
};
$.prototype.set_InnerHtml = function (value) {
this._element.innerHTML = value;
};
$.prototype._element = null;
$.prototype.DummyField = null;
JSIL.OverloadedMethod($.prototype, "_ctor", [
[0, [new JSIL.TypeRef($asm02, "System.String")]],
[1, [new JSIL.TypeRef($asm02, "System.Object")]]
], $asm01);
JSIL.MakeProperty($.prototype, "InnerHtml",
$.prototype.get_InnerHtml, $.prototype.set_InnerHtml);

});
```
May be is related to issue #69?
(as always tested on linux)