-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add better constructor support for deserialization #32
Merged
SamboyCoding
merged 1 commit into
SamboyCoding:master
from
tcortega:feat/constructor-initialization
Jul 16, 2023
Merged
Add better constructor support for deserialization #32
SamboyCoding
merged 1 commit into
SamboyCoding:master
from
tcortega:feat/constructor-initialization
Jul 16, 2023
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
tcortega
force-pushed
the
feat/constructor-initialization
branch
from
July 10, 2023 05:19
22a4cce
to
74ec918
Compare
tcortega
added a commit
to tcortega/Tomlet
that referenced
this pull request
Jul 14, 2023
…cks 729f57 Closes SamboyCoding#30 Closes SamboyCoding#32
SamboyCoding
requested changes
Jul 16, 2023
The behaviour in the mechanism is based on the behaviour observed on the System.Text.Json library, when attempting to deserialize JSON strings. Introduced a mechanism for dynamically identifying and invoking the most suitable constructor for a given type, making it able to call any constructor with N parameters. This specially useful when dealing with records. Because most people declare records as following: record MyRecord(string MyString, ...) If there are matching keys between the TOML string and the constructor's parameters, it initializes the properties from the parameters. Introduced a TomlSerializerOptions class with an OverrideConstructorValues option.
tcortega
force-pushed
the
feat/constructor-initialization
branch
from
July 16, 2023 16:57
74ec918
to
619ebc0
Compare
When I moved the GenericExtensions as you said, to the Extensions folder, there seemed to be an issue with using the Extension methods in the
Therefore it is now calling the method in the static class directly. |
SamboyCoding
approved these changes
Jul 16, 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.
The behaviour in the mechanism is based on the behaviour observed on the System.Text.Json library, when attempting to deserialize JSON strings.
N
parameters. This specially useful when dealing with records. Because most people declare records as following:record MyRecord(string MyString, ...)
TomlSerializerOptions
class with anOverrideConstructorValues
option.if there is anything wrong with it, let me know or feel free to change it yourself.