- Notifications
You must be signed in to change notification settings - Fork752
Codec groups: EncoderGroup and DecoderGroup#1085
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
codecov-io commentedMar 10, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report
@@ Coverage Diff @@## master #1085 +/- ##==========================================+ Coverage 86.75% 87.05% +0.30%========================================== Files 1 1 Lines 302 340 +38 ==========================================+ Hits 262 296 +34- Misses 40 44 +4
Continue to review full report at Codecov.
|
These classes would help to manage codec layers. For example, a library could register its own codecs, but also allow anyone to inject their codecs before library's own:public static EncoderGroup BeforeLibraryEncoders { get; } = new EncoderGroup();void LibraryRegisterCodecs(){ PyObjectConversions.RegisterEncoder(BeforeLibraryEncoders); PyObjectConversions.RegisterEncoder(LibraryEncoder.Instance);}Then in a program using that library:Library.BeforeLibraryEncoders.Encoders.Add(preencoder);
using System.Linq; | ||
using NUnit.Framework; | ||
using Python.Runtime; | ||
using Python.Runtime.Codecs; |
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.
While I don't have a particular problem with this, why are you using this style? It's not in use in the established codebase and I have never seen it outside either.
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.
Imagine we use aSystem.Uri
a lot. At some point in the future we decide to take a dependency (or introduce our own) on something, that hasPython.Uri
class, which we might not need ourselves, but it is public.
With
usingSystem;namespacePython.Runtime{classSomeClass{UriuriField;}}
theuriField
will silently change its type fromSystem.Uri
toPython.Uri
.
If theusing System;
is insidenamespace Python.Runtime
, that won't happen.
src/embed_tests/Codecs.cs Outdated
public PyObject TryEncode(object value) => this.GetRawPythonProxy(); | ||
} | ||
class FakeDecoder<TTarget> : IPyObjectDecoder |
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.
Maybe give this a few lines of documentation to make it easier to follow the tests.
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.
@filmor renamed classes to make their behavior more clear, and added xmldoc.
* Added Codecs: EncoderGroup and DecoderGroupThese classes would help to manage codec layers. For example, a library could register its own codecs, but also allow anyone to inject their codecs before library's own:public static EncoderGroup BeforeLibraryEncoders { get; } = new EncoderGroup();void LibraryRegisterCodecs(){ PyObjectConversions.RegisterEncoder(BeforeLibraryEncoders); PyObjectConversions.RegisterEncoder(LibraryEncoder.Instance);}Then in a program using that library:Library.BeforeLibraryEncoders.Encoders.Add(preencoder);
Uh oh!
There was an error while loading.Please reload this page.
What does this implement/fix? Explain your changes.
These classes would help to manage codec layers. For example, a library could register its own codecs, but also allow anyone to inject their codecs before library's own:
Then in a program using that library:
Does this close any currently open issues?
No
Checklist
Check all those that are applicable and complete.