From bb7d47a33b2b7c3be5af2fc30b5092793d5b799c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 29 May 2021 15:46:13 +0600 Subject: [PATCH] fix build --- .../dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt | 10 +++++----- .../dev/inmo/tgbotapi/types/ChatIdentifierTests.kt | 8 ++++---- .../kotlin/dev/inmo/tgbotapi/types/ParseModeTests.kt | 1 + .../dev/inmo/tgbotapi/types/TelegramDateTests.kt | 1 + .../kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt | 8 ++++---- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt index cf2222ddd2..65a70a03da 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ParseMode/ParseMode.kt @@ -9,25 +9,25 @@ import kotlinx.serialization.encoding.Encoder internal const val parseModeField = "parse_mode" -@Serializable(ParseModeSerializerObject::class) +@Serializable(ParseModeSerializer::class) sealed interface ParseMode { val parseModeName: String } -@Serializable(ParseModeSerializerObject::class) +@Serializable(ParseModeSerializer::class) object MarkdownParseMode : ParseMode { @Serializable @SerialName(parseModeField) override val parseModeName: String = "Markdown" } -@Serializable(ParseModeSerializerObject::class) +@Serializable(ParseModeSerializer::class) object MarkdownV2ParseMode : ParseMode { @Serializable @SerialName(parseModeField) override val parseModeName: String = "MarkdownV2" } -@Serializable(ParseModeSerializerObject::class) +@Serializable(ParseModeSerializer::class) object HTMLParseMode : ParseMode { @Serializable @SerialName(parseModeField) @@ -47,7 +47,7 @@ typealias HTML = HTMLParseMode var defaultParseMode: ParseMode = HTML @RiskFeature -object ParseModeSerializerObject : KSerializer { +object ParseModeSerializer : KSerializer { override val descriptor: SerialDescriptor = String.serializer().descriptor override fun deserialize(decoder: Decoder): ParseMode { return when (decoder.decodeString()) { diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ChatIdentifierTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ChatIdentifierTests.kt index 226357c4b2..a90efac2c1 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ChatIdentifierTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ChatIdentifierTests.kt @@ -40,13 +40,13 @@ class ChatIdentifierTests { } } + @Serializable + data class Example( + val identifier: ChatIdentifier + ) @Test fun `Deserializing_from_String_must_work_correctly`() { - @Serializable - data class Example( - val identifier: ChatIdentifier - ) Example(chatIdentifierChatId.toChatId()).let { withChatId -> val stringified = TestsJsonFormat.encodeToString(Example.serializer(), withChatId) diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ParseModeTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ParseModeTests.kt index 981a7f6abc..ffe13a75ae 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ParseModeTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ParseModeTests.kt @@ -9,6 +9,7 @@ import kotlin.test.assertEquals class ParseModeTests { @Serializable data class Example( + @Serializable(ParseModeSerializer::class) val mode: ParseMode ) diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TelegramDateTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TelegramDateTests.kt index 7ac90e6b71..a79e0aba6e 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TelegramDateTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TelegramDateTests.kt @@ -13,6 +13,7 @@ private val dateTime = DateTime(dateTimeMillis) class TelegramDateTests { @Serializable data class Example( + @Serializable(TelegramDateSerializer::class) val dateTime: TelegramDate ) @Test diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt index d544f21c70..12596f0922 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt @@ -1,9 +1,9 @@ package dev.inmo.tgbotapi.types -import dev.inmo.tgbotapi.CommonAbstracts.makeString import dev.inmo.tgbotapi.TestsJsonFormat import dev.inmo.tgbotapi.extensions.utils.formatting.* -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource +import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourceSerializer +import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import kotlinx.serialization.builtins.ListSerializer import kotlin.test.Test import kotlin.test.assertEquals @@ -26,9 +26,9 @@ class TextSourcesTests { regular(" ") pre("text", "kotlin") } - val serialized = TestsJsonFormat.encodeToString(ListSerializer(TextSource.serializer()), testList) + val serialized = TestsJsonFormat.encodeToString(ListSerializer(TextSourceSerializer), testList) val deserialized = TestsJsonFormat.decodeFromString( - ListSerializer(TextSource.serializer()), + ListSerializer(TextSourceSerializer), serialized ) assertEquals(testList, deserialized)