Description
Hi,
until pythonnet 2.1.0 it was possible to call functions with the same name and different parameters. This fails with pythonnet 2.1.0
I have prepared minimal test functions like this, which return the input para string as string, int or float:
public String Function(String para, ref String myout)
public String Function(String para,ref int myout)
public String Function(String para,ref float myout)
and call them like this
from Test import TestClass
dummy=TestClass()
print dummy.Function('Echo',str())
print dummy.Function('42',int())
print dummy.Function('3.144',float())
With pythonnet==2.0.0 the result is as expected
(u'Echo', u'Echo')
(u'42', 42.0)
(u'3.144', 3.144)
pythonnet==2.1.0 returns a TypeError: No method matches given arguments
I have a sample dll and py as a zip, but unfortunately the upload fails.
(Unfortunately, we don’t support that file type. )
Activity
den-run-ai commentedon Jun 8, 2016
Method overloading was improved since pythonnet 2.0 - it could give you
wrong overloaded method before!
However ByRef is really complicated, since python does not support such a
concept directly.
In your case try this work-around by passing the actual CLR type:
import System
dummy.Function('Echo',System.String(""))
Here is WIP patch that handles ByRef argument types. Just need to do more
testing:
#227
On Wed, Jun 8, 2016 at 6:05 AM, uenz notifications@github.com wrote:
uenz commentedon Jun 9, 2016
Thanks for the response.
The workaround with
dummy.Function('Echo',System.String(""))
unfortunately gives the same type error as mentioned.
den-run-ai commentedon Jun 9, 2016
Are you calling static or instance methods? If instance method, then did
you initialize the object?
Can you share your full example (both C# and python) in a gist on github?
On Thursday, June 9, 2016, uenz notifications@github.com wrote:
den-run-ai commentedon Jun 9, 2016
Anyway you can grab the branch from my pull request and build it yourself.
On Thursday, June 9, 2016, Denis Akhiyarov denis.akhiyarov@gmail.com
wrote:
uenz commentedon Jun 10, 2016
The code of the branch works well!
A gist with the code is here:
https://gist.github.com/uenz/b5eec565e4484595af98e0a620194229
The DLL code is stripped down only to show the issue.
Unfortunaltey i found no way to add also the compiled C# dll.
den-run-ai commentedon Sep 14, 2016
This issue requires implemented clr.Reference type properly in pythonnet. The issue is that during overload it is not possible to distinguish 2 overloads with the same signature except byref switched to byval. This is perfectly valid code in C#.
Also related issues here:
#228
#236
heri16 commentedon May 6, 2017
Is there a fix or workaround for this yet?
den-run-ai commentedon May 6, 2017
no fix yet, the workaround is using Reflection.
filmor commentedon Jun 14, 2022
This should be fixed nowadays, if not, we should treat that as a new issue.