Skip to content

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
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.66%. Comparing base (1fb2e63) to head (407e6df).
⚠️ Report is 940 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1122   +/-   ##
=======================================
  Coverage   86.66%   86.66%           
=======================================
  Files           1        1           
  Lines         300      300           
=======================================
  Hits          260      260           
  Misses         40       40           
Flag Coverage Δ
setup_linux 65.33% <ø> (ø)
setup_windows 72.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants