Skip to content
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

Expand @SerialInfo doc with information on targets #1926

Merged
merged 2 commits into from May 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/commonMain/src/kotlinx/serialization/Annotations.kt
Expand Up @@ -181,7 +181,12 @@ public annotation class EncodeDefault(val mode: Mode = Mode.ALWAYS) {
/**
* Meta-annotation that commands the compiler plugin to handle the annotation as serialization-specific.
* Serialization-specific annotations are preserved in the [SerialDescriptor] and can be retrieved
* during serialization process with [SerialDescriptor.getElementAnnotations].
* during serialization process with [SerialDescriptor.getElementAnnotations] for properties annotations
* and [SerialDescriptor.annotations] for class annotations.
*
* It is recommended to explicitly specify target for serial info annotations, whether it is [AnnotationTarget.PROPERTY], [AnnotationTarget.CLASS], or both.
sandwwraith marked this conversation as resolved.
Show resolved Hide resolved
* Keep in mind that Kotlin compiler prioritizes [function parameter target][AnnotationTarget.VALUE_PARAMETER] over [property target][AnnotationTarget.PROPERTY],
* so serial info annotations used on constructor-parameters-as-properties without explicit declaration-site or use-site target are not preserved.
*/
@Target(AnnotationTarget.ANNOTATION_CLASS)
@Retention(AnnotationRetention.BINARY)
Expand Down