-
Notifications
You must be signed in to change notification settings - Fork 164
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
Adding Serialization fixes #448
Merged
nbransby
merged 25 commits into
GitLiveApp:master
from
splendo:feature/serialization-fixes
Mar 29, 2024
Merged
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
816bd62
Adding Serialization fixes
Daeda88 e126519
Merge remote-tracking branch 'GitLiveApp/master' into feature/seriali…
Daeda88 69e4516
Ensure API stability
Daeda88 582532d
Merge remote-tracking branch 'GitLiveApp/master' into feature/seriali…
Daeda88 fae5299
Track for JS
Daeda88 0d252b5
Merge remote-tracking branch 'GitLiveApp/master' into feature/seriali…
Daeda88 a4a7150
Use named arguments for settings
Daeda88 0c6e22c
Merge remote-tracking branch 'GitLiveApp/master' into feature/seriali…
Daeda88 8305507
Use builders instead
Daeda88 045e127
Merge remote-tracking branch 'GitLiveApp/master' into feature/seriali…
Daeda88 3c9f7ff
Merge remote-tracking branch 'GitLiveApp/master' into feature/seriali…
Daeda88 4ad4d13
Remove Async classes + add inline for builder funs
Daeda88 46d7c17
Fixed Database runTransaction
Daeda88 bf709a3
Fixed Android crash, updated tests + cleanup
Daeda88 3021502
Update Readme
Daeda88 59b4522
Some renames + readme update
Daeda88 7a2ae5d
Add value class fix
Daeda88 2fb7f58
Made helper methods internal
Daeda88 0ca5675
Slight optimization of Value class tests
Daeda88 1995071
Small test improvement
Daeda88 87d4ae2
Decode polymorphic using elementName rather than index
Daeda88 71bcce4
Also test nested data class encoding
Daeda88 26d7ea9
Merge remote-tracking branch 'GitLiveApp/master' into feature/seriali…
Daeda88 f75b240
Use Wrappers rather than Abstract classes
Daeda88 f8eb4fd
Use wrappes + extension methods instead of abstract class
Daeda88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
33 changes: 33 additions & 0 deletions
33
firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/EncodeDecodeSettings.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package dev.gitlive.firebase | ||
|
||
import kotlinx.serialization.modules.EmptySerializersModule | ||
import kotlinx.serialization.modules.SerializersModule | ||
|
||
/** | ||
* Settings used to configure encoding/decoding | ||
*/ | ||
sealed class EncodeDecodeSettings { | ||
|
||
/** | ||
* The [SerializersModule] to use for serialization. This allows for polymorphic serialization on runtime | ||
*/ | ||
abstract val serializersModule: SerializersModule | ||
} | ||
|
||
/** | ||
* [EncodeDecodeSettings] used when encoding an object | ||
* @property shouldEncodeElementDefault if `true` this will explicitly encode elements even if they are their default value | ||
* @param serializersModule the [SerializersModule] to use for serialization. This allows for polymorphic serialization on runtime | ||
*/ | ||
data class EncodeSettings( | ||
val shouldEncodeElementDefault: Boolean = true, | ||
override val serializersModule: SerializersModule = EmptySerializersModule(), | ||
) : EncodeDecodeSettings() | ||
|
||
/** | ||
* [EncodeDecodeSettings] used when decoding an object | ||
* @param serializersModule the [SerializersModule] to use for deserialization. This allows for polymorphic serialization on runtime | ||
*/ | ||
data class DecodeSettings( | ||
override val serializersModule: SerializersModule = EmptySerializersModule(), | ||
) : EncodeDecodeSettings() | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
cant these be internal now?
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.
Some issues with some inline funs.
But actually, I'd like to propose that instead of named arguments we try a builder approach. E.g.:
set(value) { shouldEncodeDefaults = false }
Reason im suggesting it is because its annoying as hell right now to add new settings, since you have dozens of methods that need them specified. A builder makes it a one line addition