-
Notifications
You must be signed in to change notification settings - Fork 750
Added ToPythonAs()
extension method for explicit conversion using an arbitrary type
#2419
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
base: master
Are you sure you want to change the base?
Added ToPythonAs()
extension method for explicit conversion using an arbitrary type
#2419
Conversation
Can you please provide an example of how this can be used? Even better if it is a real-world usage example. |
ToPythonAs()
extension method for explicit conversion using an arbitrary type
@microsoft-github-policy-service agree
Revert unintentional changes
@@ -2,6 +2,7 @@ | |||
|
|||
<PropertyGroup> | |||
<TargetFrameworks>net472;net6.0</TargetFrameworks> | |||
<RollForward>LatestMajor</RollForward> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows anyone that has recent versions of .net to run these tests. I can revert but I think its usefull, otherwise one needs to install .net6 which is already deprecated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be conditioned on not running in CI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any config/env var which I can check?
Added a test. |
@@ -2,6 +2,7 @@ | |||
|
|||
<PropertyGroup> | |||
<TargetFrameworks>net472;net6.0</TargetFrameworks> | |||
<RollForward>LatestMajor</RollForward> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be conditioned on not running in CI
src/runtime/PythonTypes/PyObject.cs
Outdated
public static PyObject FromManagedObject(object ob) | ||
public static PyObject FromManagedObject(object ob, Type? type = null) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a use case and a test for this change as well.
Also, you have to add a separate overload because AFAIK adding default arguments breaks binary compatibility (e.g. libs compiled prior to this change will fail with MissingMethodException
when they'll try to call the original method)
…oaompneves/pythonnet into support-specific-type-encoding * 'support-specific-type-encoding' of https://github.com/joaompneves/pythonnet: Update CHANGELOG.md Update CHANGELOG.md Update CHANGELOG.md
What does this implement/fix? Explain your changes.
When you have an object that implements multiple interfaces in an explicit way, there's no easy way to specify which of the interface we want to encode, when the interface type is not known at build time.
This PR allows that, by introducing an overload with and extra type parameter in the ToPythonAs method.
...
Does this close any currently open issues?
...
Any other comments?
...
Checklist
Check all those that are applicable and complete.
AUTHORS
CHANGELOG