Skip to content

Enable C# objects to be callable #890

@lostmsu

Description

@lostmsu

Environment

  • Pythonnet version: 2.4.0
  • Python version: ANY
  • Operating System: ANY

Details

Given C# class Callable

class Callable {
  public int __call__(int arg) => arg * 2;
}

Be able call an instance of it like a function in Python:

callable = Callable()
print(callable(21))

Expected: should print 42
Actual: TypeError : object is not callable

Note

I am actually working on this. This is a tracking issue to reference in commits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions