You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failure in function selection according to parameters #226
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()
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()
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#.
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 [email protected] 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 [email protected] 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 [email protected]
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.