Skip to content

Cannot get correct overload of generic method #821

Open
@Tobimaru

Description

@Tobimaru

Environment

  • Pythonnet version: zip archive of master branch
  • Python version: 3.6
  • Operating System: Ubuntu 18.04

Details

  • Describe what you were trying to get done.

Invoke a generic method with multiple overloads.

  • What commands did you run to trigger this issue?

On the C# side I have the following generic method with overloads:

Variable<T> Variable.Constant<T>(T)
VariableArray<T> Variable.Constant<T>(T[])    

On the python side, I'm trying to invoke the second overload by doing:

a = Variable.Constant(System.Array[System.Double]([1.0, 2.0, 3.0]))

But when I check the type of a, it gives Variable[System.Double[]] and not VariableArray[System.Double]. This makes sense since it's ambiguous without specifying the type of the output variable or specifying the type for the function. Since in python I can't pin the output variable to a specific type, I tried to resolve the ambiguity with:

a = Variable.Constant[System.Double](System.Array[System.Double]([1.0, 2.0, 3.0]))

but then I get the exception:

TypeError: No method matches given arguments for Constant

I also tried:

a = Variable.Constant.Overloads[System.Double](System.Array[System.Double]([1.0, 2.0, 3.0]))

but then I get the exception:

TypeError: No match found for signature

It seems that there is pull-request (#227) ongoing, but it looks to have been work in progress for quite a while now. Is this is not priority, is there a workaround that I can try?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions