Conversation
* Remove the `@kotlinx.serialization.Serializable` annotation from `TimeZone` and `FixedOffsetTimeZone`. * Deprecate `TimeZoneSerializer` and `FixedOffsetTimeZoneSerializer` with a warning. * Introduce and deprecate the `.serializer()` functions in their companion objects with a warning. Previously, this function used to be generated by the `kotlinx.serialization` compiler plugin. Fixes #576
| @@ -1,12 +1,11 @@ | |||
| /* | |||
| * Copyright 2019-2021 JetBrains s.r.o. | |||
| * Copyright 2025 JetBrains s.r.o. | |||
There was a problem hiding this comment.
IIRC, we can leave only the start date, not the end date
There was a problem hiding this comment.
We can remove the copyright notices completely: Kotlin/kotlinx.coroutines#4016
| * JSON example: `"Europe/Berlin"` | ||
| */ | ||
| @Deprecated( | ||
| "Serializing TimeZone is discouraged. Please serialize the id String instead.", |
There was a problem hiding this comment.
id String sounds weird. Maybe you want id: String? Or since this is more of a text message, string id sounds better IMO
| * @sample kotlinx.datetime.test.samples.TimeZoneSamples.usage | ||
| */ | ||
| @Serializable(with = TimeZoneSerializer::class) | ||
| public expect open class TimeZone { |
There was a problem hiding this comment.
Note that the moment you remove @Serializable(with=...) annotation from type, it is shown as red with SERIALIZER_NOT_FOUND where it was used in any @Serializable user class. Sadly, we do not have any kind of deprecation migration for that; so I suggest raising all @Deprecated here to ERROR just to speedup this process
There was a problem hiding this comment.
The idea is to keep it WARNING for now so that people can work around the SERIALIZER_NOT_FOUND issue by adding their own annotation to the TimeZone field. Then, after a migratory period, when we expect such annotations to be removed as well, the deprecation can be promoted to ERROR.
Does this approach make sense?
| @Deprecated("Use offset.totalSeconds", ReplaceWith("offset.totalSeconds")) | ||
| public val totalSeconds: Int | ||
|
|
||
| /** @suppress */ |
There was a problem hiding this comment.
The generation of the KDoc for this object.
@kotlinx.serialization.Serializableannotation fromTimeZoneandFixedOffsetTimeZone.TimeZoneSerializerandFixedOffsetTimeZoneSerializerwith a warning..serializer()functions in their companion objects with a warning. Previously, this function used to be generated by thekotlinx.serializationcompiler plugin.Fixes #576