Enable C# objects to be callable

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.