Skip to content

pythonnet 3.0 breaks access to methods whos signature returns an interface but clients want to use the concrete type #1914

Description

@koubaa

Environment

  • Pythonnet version: 3.0+
  • Python version: any
  • Operating System: any
  • .NET Runtime: any

tldr;
#1240 changes the behavior of pythonnet to wrap only the interface methods/members of objects returned by a .NET method whose method declaration states that it returns an interface. Prior to this change, the python object that pythonnet created for the return object wrapped the returned object instance, but did not necessarily implement the interface. The prior behavior was useful for idiomatic C# patterns like the factory pattern.

This was discussed on the mailing list and I wanted to file an issue here.

Apparently, the change was also reverted in the QuantConnect fork.

My preferred fix, for what its worth, is option 4 (from the list of options mentioned by Victor in that thread):

IronPython apparently allows explicit interface implementations to be called (instead of returning interface-wrapped instances), if there’s no conflict with regular methods. Perhaps we should consider this as an option.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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