Skip to content

Commit cb6bcbb

Browse files
committed
Add @MustBeDocumented to certain annotations
Only annotations that affect code generation/add declarations on class-level were selected Other annotations that affect mainly properties (SerialName,Required,Transient) are left for further consideration. File-level annotations like `@UseSerializers` likely shouldn't be documented. See #2056
1 parent 182c53e commit cb6bcbb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

core/commonMain/src/kotlinx/serialization/Annotations.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import kotlin.reflect.*
6767
* @see UseSerializers
6868
* @see Serializer
6969
*/
70+
@MustBeDocumented
7071
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS, AnnotationTarget.TYPE)
7172
//@Retention(AnnotationRetention.RUNTIME) // Runtime is the default retention, also see KT-41082
7273
public annotation class Serializable(
@@ -97,6 +98,7 @@ public annotation class Serializable(
9798
* @see UseSerializers
9899
* @see Serializer
99100
*/
101+
@MustBeDocumented
100102
@Target(AnnotationTarget.ANNOTATION_CLASS)
101103
//@Retention(AnnotationRetention.RUNTIME) // Runtime is the default retention, also see KT-41082
102104
@ExperimentalSerializationApi
@@ -111,6 +113,7 @@ public annotation class MetaSerializable
111113
* Changes may include additional constraints on classes and objects marked with this annotation,
112114
* behavioural changes and even serialized shape of the class.
113115
*/
116+
@MustBeDocumented
114117
@Target(AnnotationTarget.CLASS)
115118
@Retention(AnnotationRetention.BINARY)
116119
@ExperimentalSerializationApi
@@ -217,6 +220,7 @@ public annotation class EncodeDefault(val mode: Mode = Mode.ALWAYS) {
217220
* Keep in mind that Kotlin compiler prioritizes [function parameter target][AnnotationTarget.VALUE_PARAMETER] over [property target][AnnotationTarget.PROPERTY],
218221
* so serial info annotations used on constructor-parameters-as-properties without explicit declaration-site or use-site target are not preserved.
219222
*/
223+
@MustBeDocumented
220224
@Target(AnnotationTarget.ANNOTATION_CLASS)
221225
@Retention(AnnotationRetention.BINARY)
222226
@ExperimentalSerializationApi
@@ -254,6 +258,7 @@ public annotation class SerialInfo
254258
* fun foo(): Int = Derived.serializer().descriptor.annotations.filterIsInstance<A>().single().value
255259
* ```
256260
*/
261+
@MustBeDocumented
257262
@Target(AnnotationTarget.ANNOTATION_CLASS)
258263
@Retention(AnnotationRetention.BINARY)
259264
@ExperimentalSerializationApi

0 commit comments

Comments
 (0)