Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Proposal: Implement binding manager to hold binding overrides #2543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

koubaa
Copy link
Contributor

@koubaa koubaa commented Jan 13, 2025

What does this implement/fix? Explain your changes.

This adds a place to register at runtime options to customize the binding of types. This customization can be specified at a type or assembly level.

Does this close any currently open issues?

No, but it can be used as a way to close issues going forwards - especially in cases where there is disagreement about what the correct way to bind to python, or if there are legacy compatibility reasons to bind in a way that is not the default way. For example, in the ansys-pythonnet fork, this is proposed to be used in two ways:

  1. to bind properties and methods coming from explicit interface implementation in order to satisfy a requirement in one library for compatibility with legacy IronPython scripts. In IronPython, explicit interface implementations are provided in Python, even when that is not the idiomatic choice.
  2. to automatically add pep8 aliases, allowing python code to use normal python style even when the C# library uses the normal C# style.

As this is just a proposal - I will move forward with the checklist if the maintainers of pythonnet agree with the direction.

Example usage (from python)

m = clr.AddReference('MyLib')
from Python.Runtime import BindingManager, BindingOptions
binding_options = BindingOptions()
binding_options.SuppressDocs = True
BindingManager.SetBindingOptions(m, binding_options)

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Ensure you have signed the .NET Foundation CLA
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant