-
Notifications
You must be signed in to change notification settings - Fork 623
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
Added documentation for @KeepGeneratedSerializer feature #2669
Conversation
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.
I think it is worth adding an example with JsonTransformingSerializer(MyObj.generatedSerializer())
as well (see #1310) — likely to json.md#json-transformations
section that will explain how to make a JsonTransformingSerializer a default one while delegating to generated serializer at the same time.
Also, knitCheck
task fails.
Waiting for |
- added section ro JSON docs - fixed knit
Co-authored-by: Leonid Startsev <[email protected]>
Should we add tests to runtime for this feature? |
I think it would be safer to add #2758 |
* | ||
* Used only with the [Serializable] annotation. | ||
* Annotation is not allowed on classes involved in polymorphic serialization: | ||
* interfaces, sealed classes, abstract classes, classes marked by [Polymorphic]. |
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.
I don't understand this sentence: @KeepGeneratedSerializer
is not allowed with any inheritance, but your sample code uses a class with inherits from an interface. (see other comment)
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.
It means that you cannot specify the @KeepGeneratedSerializer
annotation on the interfaces, sealed/abstract classes, but it's ok to add this annotation add to the heirs
@KeepGeneratedSerializer | ||
@Serializable(with = BasicProjectSerializer::class) | ||
@SerialName("basic") | ||
data class BasicProject(override val name: String): Project() |
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.
Also, do you test your sample automatically? If not, can you add this code to your tests in #2758?
Background: I use Kotlin 2.0.20-RC with kx-serial 1.7.1, and I get this error:
java.lang.NullPointerException
at kotlinx.serialization.SealedClassSerializer$special$$inlined$groupingBy$1.keyOf(_Collections.kt:1547)
I will also create an issue with a small reproducer.
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.
Also, do you test your sample automatically?
yes
I will also create an issue with a small reproducer.
Thanks!
Resolves #2660