FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add C# Dictionary to Python Dict conversion by thesn10 · Pull Request #972 · pythonnet/pythonnet · GitHub

Repository navigation

Add C# Dictionary to Python Dict conversion - #972

Closed
thesn10 wants to merge 3 commits into
pythonnet:masterfrom
thesn10:master
Closed

thesn10 wants to merge 3 commits into
pythonnet:masterfrom
thesn10:master

Conversation

thesn10 commented Oct 18, 2019

Copy link
Copy Markdown
Contributor

What does this implement/fix? Explain your changes.

You can now convert a C# IDictionary to a Python Dict by calling ToPython()

Dictionary<string, string> dict = new Dictionary<string, string>();
dict.Add("hello", "world");

dynamic d = dict.ToPython();
string value = d.get("hello", "");

Does this close any currently open issues?

No, but it is progress for #623

Any other comments?

Do i really have to include a test for this? I mean, the TestConverter.cs file doesnt have any tests for other similar types like IList at all.

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

codecov-io commented Oct 18, 2019 •
edited
Loading

Copy link
Copy Markdown

Codecov Report

Merging #972 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #972   +/-   ##
=======================================
  Coverage   86.71%   86.71%           
=======================================
  Files           1        1           
  Lines         301      301           
=======================================
  Hits          261      261           
  Misses         40       40
Flag Coverage Δ
#setup_linux 65.44% <ø> (ø) ⬆️
#setup_windows 71.42% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4a9457f...6b43096. Read the comment docs.

filmor commented Oct 18, 2019

Copy link
Copy Markdown
Member

Thanks a lot for this. However, as noted in #963, I'd really like to get away from the implicit conversions and instead allow the wrapped C# object to act like a Python dict without actually performing the conversion (unless explicitly requested).

thesn10 commented Oct 19, 2019

Copy link
Copy Markdown
Contributor Author

Oh thats nice :) Will it take long until the implicit conversions get replaced? Because maybe this PR could still be a temporary solution to allow the use of IDictionary as a python dict.

In #963 you only mention IEnumerable and ICollection. Will there be a solution for IDictionary too?

thesn10 closed this Mar 27, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL