[Ironpython-users] How to call parameterless overload of generic method?

Markus Schaber m.schaber at codesys.com
Wed Jan 7 09:16:00 CET 2015


Hi, Jeff,

I thought I had attached the source code to my original email, maybe it has been eaten by the list.

I copied the C# source up to http://www.paste.org/76738 for further reference.

I know that this is a corner case, but it just happened to one of my coworkers who consulted me for a solution / workaround. :-)

(Note that this test case is simplified. In the real case, the method in question is defined on an interface, and both overloads have an identical set of input parameters before the optional out parameter. It is an API clearly designed with C# in mind, and our QA tries to call it from python in our automated regression test suite.)

Best regards

Markus Schaber

CODESYS® a trademark of 3S-Smart Software Solutions GmbH

Inspiring Automation Solutions

3S-Smart Software Solutions GmbH
Dipl.-Inf. Markus Schaber | Product Development Core Technology
Memminger Str. 151 | 87439 Kempten | Germany
Tel. +49-831-54031-979 | Fax +49-831-54031-50

E-Mail: m.schaber at codesys.com | Web: http://www.codesys.com | CODESYS store: http://store.codesys.com
CODESYS forum: http://forum.codesys.com

Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner | Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received
this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure
or distribution of the material in this e-mail is strictly forbidden.
> -----Ursprüngliche Nachricht-----
> Von: Jeff Hardy [mailto:jdhardy at gmail.com]
> Gesendet: Freitag, 19. Dezember 2014 23:37
> An: Markus Schaber
> Cc: Discussion of IronPython
> Betreff: Re: [Ironpython-users] How to call parameterless overload of
> generic method?
> 
> On Fri, Dec 19, 2014 at 12:38 PM, Markus Schaber
> <m.schaber at codesys.com> wrote:
> > Hi,
> >
> > The attached C# file demonstrates a small problem we currently
> encountered using IronPython 2.7.4:
> >
> > We have a C# method which has two overloads - one is parameterless,
> and the other one has a single out parameter.
> >
> > For non-generic methods, it is possible to call both variants when
> calling with and without clr.Reference, but this does not work for
> generic methods.
> >
> > When trying to call the parameterless generic method directly, the
> following exception appears:
> >
> > Microsoft.Scripting.ArgumentTypeException was unhandled
> >   HResult=-2146233088
> >   Message=Multiple targets could match: Method(), Method()
> >   Source=Microsoft.Dynamic
> >   StackTrace:
> > [snipped]
> >
> > The workaround is to use the .Overloads[] syntax:
> >
> > print instance.Method[str].Overloads[()]()
> 
> Probably just a bug in the generic method binder. You're into
> *really* edge case territory there. :) If you can proved C#
> signatures that work and don't work, and the IronPython code used to
> call them, it would be helpful.
> 
> - Jeff


More information about the Ironpython-users mailing list