- Notifications
You must be signed in to change notification settings - Fork749
Closed
Description
Environment
- Pythonnet version: 2.3.0 and 2.4.0
- Python version: 3.6.5
- Operating System: W10
Details
- I'm having issues disambiguating an overloaded C# method that has multiple parameters. I've foundTypeError when calling a method with an enum argument #935 which is a very similar issue but can't get it to work. I'm following the same steps but I still get the same error.
The C# side
publicenumMyEnum:byte{Success=(byte)'S',Error=(byte)'E'}publicclassMyClass{publicDictionary<Enum,BlockingCollection<ISomeInterface>>MyDictionary{get;}publicMyClass(){MyDictionary=newDictionary<Enum,BlockingCollection<ISomeInterface>>();}}
On the python side, I began with this code
fromSystem.Collections.ConcurrentimportBlockingCollectionfromMyModuleimportMyClass,ISomeInterface,MyEnumobj=MyClass()collection=BlockingCollection[ISomeInterface]()obj.MyDictionary.Add(MyEnum.Success,collection)
This fails withTypeError: No method matches given arguments for Add
. I've tried what seemed to solve it for#935 but get the same results
fromSystem.Collections.ConcurrentimportBlockingCollectionfromSystemimportEnumfromMyModuleimportMyClass,ISomeInterface,MyEnumobj=MyClass()collection=BlockingCollection[ISomeInterface]()obj.MyDictionary.Add[Enum,BlockingCollection[ISomeInterface]](MyEnum.Success,collection)
This fails withTypeError: No match found for given type params
- The output of
print(obj.MyDictionary.Add.__overloads__)
is
VoidAdd(System.Enum,System.Collections.Concurrent.BlockingCollection`1[MyModule.ISomeInterface])
UPDATE
Running this code alone actually works,add
shows as a bound method in the debugger:
add=obj.MyDictionary.Add.Overloads[Enum,BlockingCollection[ISomeInterface]]
However, attempting to call the function always fails. I've attempted passing System.byte and 0, instead of the enum, but none of them work.
add(MyEnum.Success,collection)obj.MyDictionary.Add[Enum,BlockingCollection[ISomeInterface]](MyEnum.Success,collection)obj.MyDictionary.Add.Overloads[Enum,BlockingCollection[ISomeInterface]](MyEnum.Success,collection)
Metadata
Metadata
Assignees
Labels
No labels