Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AddedToPythonAs() 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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
joaompneves wants to merge13 commits intopythonnet:master
base:master
Choose a base branch
Loading
fromjoaompneves:support-specific-type-encoding

Conversation

joaompneves
Copy link

@joaompnevesjoaompneves commentedJul 17, 2024
edited
Loading

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.

  • 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 toAUTHORS
  • Updated theCHANGELOG

@lostmsu
Copy link
Member

lostmsu commentedJul 17, 2024
edited
Loading

Can you please provide an example of how this can be used? Even better if it is a real-world usage example.

@joaompnevesjoaompneves changed the titleEncoders no support specifying the target encoding typeAddedToPythonAs() extension method for explicit conversion using an arbitrary typeJul 18, 2024
joaompnevesand others added4 commitsJuly 18, 2024 18:10
@@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<RollForward>LatestMajor</RollForward>
Copy link
Author

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

Copy link
Member

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

Copy link
Author

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?

@joaompnevesjoaompneves marked this pull request as ready for reviewJuly 18, 2024 17:17
@joaompneves
Copy link
Author

Can you please provide an example of how this can be used? Even better if it is a real-world usage example.

Added a test.

@@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<RollForward>LatestMajor</RollForward>
Copy link
Member

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

Comment on lines 139 to 140
public static PyObject FromManagedObject(object ob)
public static PyObject FromManagedObject(object ob, Type? type = null)
{
Copy link
Member

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 withMissingMethodException when they'll try to call the original method)

…oaompneves/pythonnet into support-specific-type-encoding* 'support-specific-type-encoding' ofhttps://github.com/joaompneves/pythonnet:  Update CHANGELOG.md  Update CHANGELOG.md  Update CHANGELOG.md
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@lostmsulostmsuAwaiting requested review from lostmsu

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@joaompneves@lostmsu

[8]ページ先頭

©2009-2025 Movatter.jp