-
Notifications
You must be signed in to change notification settings - Fork 666
feat: adding the Serialize classes page #3097
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
feat: adding the Serialize classes page #3097
Conversation
sandwwraith
left a 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.
.
| @@ -0,0 +1,505 @@ | |||
| [//]: # (title: Serialize classes) | |||
|
|
|||
| The [`@Serializable`](https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization/-serializable/) annotation in Kotlin enables the serialization of all properties in classes defined by the primary constructor. | |||
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.
nice, good point - changed it to properties with backing fields here as well 👍
| @@ -0,0 +1,505 @@ | |||
| [//]: # (title: Serialize classes) | |||
|
|
|||
| The [`@Serializable`](https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization/-serializable/) annotation in Kotlin enables the serialization of all properties in classes defined by the primary constructor. | |||
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.
nice, good point - changed it to properties with backing fields here as well 👍
sandwwraith
left a 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.
I do not know whether we'll finish whole review before mid-December (I expect next release of serialization there), but we can leave opt-in note for now and delete it later.
Besides that, please fix "Defines..." wording and my other comment and we're good to go
sarahhaggarty
left a 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.
Looks great! I have some suggestions for you to consider and a couple clarification questions :)
| ``` | ||
| {kotlin-runnable="true" id="serialize-annotation-example"} | ||
|
|
||
| ### Serialization of class references |
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.
What do you think about "Serialize class references" as a header? So that the header style matches the others on the page?
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.
This header (and the ones below) provide specifics as to how specific kinds of elements (attributes) are handled, but this is not an active user thing. As such the verb "serialize" is misleading.
sarahhaggarty
left a 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's looking great! Just two more suggestions to add links to our other content for backing fields and secondary constructors. Otherwise, LGTM! 🚀
| @@ -0,0 +1,519 @@ | |||
| [//]: # (title: Serialize classes) | |||
|
|
|||
| The [`@Serializable`](https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization/-serializable/) annotation enables the default serialization of all class properties with backing fields. | |||
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.
Can you add a link to our content on backing fields? https://kotlinlang.org/docs/properties.html#backing-fields
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.
oh it's added it to the second mention 😅 — moved it to first mention! 👍
|
|
||
| A class annotated with `@Serializable` must declare all parameters in its primary constructor as properties. | ||
|
|
||
| If you need to perform additional initialization logic before assigning values to properties, use a secondary constructor. |
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.
Let's link to our content on secondary constructors:
https://kotlinlang.org/docs/classes.html#secondary-constructors
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.
nice good idea — added it 👍
This is the fourth part of the Kotlin Serialization rewrite task.
Related YouTract ticket is here: KT-81889 [Docs] Create a Serialize classes page for kotlinx.serialization