Proposal: Implement binding manager to hold binding overrides by koubaa · Pull Request #2543 · pythonnet/pythonnet
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:
- 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.
- 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