From ca40a292cfaeaa3bcd0ff4d1c9ccf1c7fe5e1b66 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 18 Sep 2020 23:30:40 +0800 Subject: [PATCH] Add serializersModule --- .../mamoe/mirai/console/data/AbstractPluginData.kt | 7 ++++++- .../kotlin/net/mamoe/mirai/console/data/PluginData.kt | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt index 72ca966b2..90b22bd06 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AbstractPluginData.kt @@ -7,11 +7,13 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_SUPER_CLASS", "NOTHING_TO_INLINE") +@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_SUPER_CLASS", "NOTHING_TO_INLINE", "unused") package net.mamoe.mirai.console.data import kotlinx.serialization.KSerializer +import kotlinx.serialization.modules.EmptySerializersModule +import kotlinx.serialization.modules.SerializersModule import net.mamoe.mirai.console.internal.data.PluginDataImpl import net.mamoe.mirai.console.internal.data.getAnnotationListForValueSerialization import net.mamoe.mirai.console.internal.data.valueName @@ -72,6 +74,9 @@ public abstract class AbstractPluginData : PluginData, PluginDataImpl() { public final override val updaterSerializer: KSerializer get() = super.updaterSerializer + @ConsoleExperimentalApi + public override val serializersModule: SerializersModule = EmptySerializersModule + /** * 当所属于这个 [PluginData] 的 [Value] 的 [值][Value.value] 被修改时被调用. */ diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt index 119b9f2e3..c8c01736d 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/PluginData.kt @@ -18,6 +18,8 @@ package net.mamoe.mirai.console.data import kotlinx.serialization.KSerializer +import kotlinx.serialization.modules.SerializersModule +import kotlinx.serialization.modules.serializersModuleOf import net.mamoe.mirai.console.compiler.common.ResolveContext import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.RESTRICTED_NO_ARG_CONSTRUCTOR import net.mamoe.mirai.console.data.java.JAutoSavePluginData @@ -124,6 +126,15 @@ public interface PluginData { @ConsoleExperimentalApi public fun onValueChanged(value: Value<*>) + /** + * 用于支持多态序列化. + * + * @see SerializersModule + * @see serializersModuleOf + */ + @ConsoleExperimentalApi + public val serializersModule: SerializersModule + /** * 当这个 [PluginData] 被放入一个 [PluginDataStorage] 时调用 */