Skip to content

RawProxyEncoder #1122

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

Merged
merged 4 commits into from
Apr 29, 2020
Merged

RawProxyEncoder #1122

merged 4 commits into from
Apr 29, 2020

Conversation

lostmsu
Copy link
Member

@lostmsu lostmsu commented Apr 23, 2020

Now Python host can force raw encoding for autoconverted .NET types.

What does this implement/fix? Explain your changes.

This class allows Python to override some automatic conversions done by Python.NET, which was otherwise impossible.

To do that, Python code can define a class derived from RawProxyEncoder, and override CanEncode to return True for the desired types. Create an instance of this class, and register it with Python.Runtime.PyObjectConversions.RegisterEncoder(instance) (see new test for example)

Does this close any currently open issues?

Enables workaround for #514

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
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

Now Python host can force raw encoding for autoconverted .NET types.
Enables workaround for pythonnet#514
@lostmsu lostmsu force-pushed the PR/RawProxyEncoderBase branch from a0fed9a to 213afb6 Compare April 23, 2020 18:34
@lostmsu lostmsu added this to the 2.5.0 milestone Apr 23, 2020
@lostmsu lostmsu requested a review from filmor April 27, 2020 21:01
@filmor filmor merged commit f707698 into pythonnet:master Apr 29, 2020
@lostmsu lostmsu deleted the PR/RawProxyEncoderBase branch April 29, 2020 17:58
AlexCatarino pushed a commit to QuantConnect/pythonnet that referenced this pull request Jun 29, 2020
Now Python host can force raw encoding for autoconverted .NET types.
Enables workaround for pythonnet#514
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.

2 participants