nikhilk / scriptsharp

Script# Project - a C# to JavaScript compiler, to power your HTML5 and Node.js web development.
http://scriptsharp.com
Other
658 stars 182 forks source link

Duplicate-named member error - overloaded methods and constructors #447

Closed larrywelch closed 7 years ago

larrywelch commented 7 years ago

Is there a trick to overloaded methods and constructors or are they just not supported?

Ex: [ScriptName("tryLocationToPixel")] public MapPoint[] TryLocationsToPixels(MapLocation[] locations) { return null; }

    [ScriptName("tryLocationToPixel")]
    public MapPoint[] TryLocationsToPixels(MapLocation[] locations, MapPointReference pointReference) {
        return null;
    }

or public Map(Element element, MapViewOptions options) {} public Map(string elementName, MapOptions options) { } public Map(string elementName, MapViewOptions options) { }

scottdurow commented 7 years ago

You can overload methods provided the class is marked as Imported

[Imported]
    public class ImportedClass
    {

        public ImportedClass(string s)
        {

        }
        public ImportedClass(int i)
        {

        }
        public void Foo(int i)
        {

        }

        public void Foo(string s)
        {

        }
    }
larrywelch commented 7 years ago

Perfect!