Repository navigation
feat: Add copyWith methods on all generated protocol files. - #1358
Merged
Merged
Conversation
Co-authored-by: Andrey Ivanov <[email protected]>
Isakdl
force-pushed
the
748-copyWith
branch
from
September 12, 2023 16:32
ad183a8 to
4fba741
Compare
vlidholt
approved these changes
Sep 13, 2023
vlidholt
left a comment
Collaborator
There was a problem hiding this comment.
LGTM with comments fixed/checked. Very cool work!
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Changes
Adds a
copyWithmethod on all generated classes. The method has support for differentiating between null and undefined input. This means that you are able to set a nullable field to null again via thecopyWithmethod.The method also makes a deep copy of all objects and variables included in the class. This also means that any custom classes that is used together with this method also must implement their own
copyWithmethod. If the method does not exist an exception is thrown.Example:
closes: #748
This PR is based on: #976 and the work done by @pro100andrey (thank you!)
Limitation
This PR only implements the
copyWithmethod but does not include any immutability or equality overrides etc. These features should be implemented in a separate PR dealing with immutability.Review
Most of the code changes are generated code and tests, the key additions are inside the code generator as well as inside the serialisation package.
Pre-launch Checklist
///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.