-
Notifications
You must be signed in to change notification settings - Fork 10
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
✨🔥 Implement new converter API #191
Merged
Merged
Conversation
This file contains 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
Good feedback from trying in some projects (Pokémon Conquest and Ekona):
|
pleonex
added a commit
to SceneGate/Lemon
that referenced
this pull request
Aug 21, 2023
pleonex
added a commit
to pleonex/LayTea
that referenced
this pull request
Aug 21, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR proposes a new API to use converters on
IFormat
variables and via theNode
class. It tries to address the issues collected from users where the current API can be very verbose or confusing.The new API is:
Examples at the bottom
Main changes:
IFormat
allowing fluent-like chain conversions:myFormat.ConvertWith(new Converter1()).ConvertWith(new Converter2())
po.ConvertWith(new Po2Binary(args))
IInitializer<T>
. Use instead the constructor to pass parameters or initialize the converter.ConvertFormat.To()
andNode.TransformTo()
are removed.This new design does not require having dependencies in the core library (Yarhl) with an assembly scanning tech or DI (like MEF)
Cons
IDisposable
saying we didn't dispose the object. I added the argument in the extension method but the analyzer won't detect it.using var
and pass the objectsConvertWith(new Po2Binary(arg1))
vsConvertWith<Po2Binary>(arg1)
which is cooler) but we couldn't find a way to make it work and being type-safe.IConverter<,>
, then the generics in the extension methodConvertWith
cannot be omitted.Options considered
po.ConvertWith<Po2Binary, Args>(args).To<BinaryFormat>()
vspo.ConvertWith(new Po2Binary(args))
Requirements analyzed
ConvertTo
)IFormat
can be chained for multiple conversionsNode
can be converted without affecting the node easilyIConverter<,>
)TODO
ConsiderNode.TransformWith<TConv>(args)
Fix / Replace MEF (plugin discovery)Future PR. PoC in SceneGateExample
Performance results
TransformWith<TSrc, TDst>(IConverter<TSrc, TDst> converter)
vsTransformWith(IConverter converter)
(usesdynamic
):For now most of the old API is not removed but marked them as obsolete. It allows to do a smooth migration part by part.
Please feel free to provide feedback and try in your projects.
I have temporary modify the build pipeline so there is a NuGet version for this branch available in the preview feed.
Version:
4.0.0-PullRequest0191.191
(the last digit may increase)I'll leave this PR open some time while we test it in our projects, so we can validate it.
Internal validation:
This closes #124