I have a C# class with overloaded static methods like these:
// Added to the Simple class in Tutorial\Extend\csextend.cs
public static int Foo(IEnumerable<int> values)
{
return 1;
}
public static int Foo(IEnumerable<string> values)
{
return 2;
}
I get an error when I try to call these from IronPython 2.6. I am passing a python list that contains strings.
import clr
clr.AddReferenceToFile("csextend.dll")
import Simple
Simple.Foo(["alpha", "bravo", "charlie"])
TypeError: Multiple targets could match: Foo(IEnumerable[str]), Foo(IEnumerable[ int])
My first question is why doesn't this work? It seems like overload resolution should work on this. Is this a bug in IronPython? What is the cleanest workaround. I could rename the routines so they don't overload each other, but then I am letting ironpython quirks alter the design of the C# class.
Is there a clean way to give python a clue that the list is entirely composed of one type, and that it should pick a specific overload?
Related to this question