瀏覽代碼

JSON encode defaults

Him188 5 年之前
父節點
當前提交
b3b34c19d1

+ 5 - 2
backend/mirai-console/src/data/AutoSavePluginData.kt

@@ -39,9 +39,12 @@ public open class AutoSavePluginData private constructor(
     public final override val saveName: String
         get() = _saveName
 
-    private var _saveName: String = saveName
+    @Suppress("JoinDeclarationAndAssignment") // bug
+    private lateinit var _saveName: String
 
-    public constructor(saveName: String) : this(null)
+    public constructor(saveName: String) : this(null) {
+        _saveName = saveName
+    }
 
     @ConsoleExperimentalApi
     override fun onInit(owner: PluginDataHolder, storage: PluginDataStorage) {

+ 1 - 0
backend/mirai-console/src/internal/data/MultiFilePluginDataStorageImpl.kt

@@ -65,6 +65,7 @@ internal open class MultiFilePluginDataStorageImpl(
         ignoreUnknownKeys = true
         isLenient = true
         allowStructuredMapKeys = true
+        encodeDefaults = true
     }
 
     private val yaml = Yaml.default

+ 5 - 2
backend/mirai-console/test/data/SettingTest.kt

@@ -24,8 +24,11 @@ internal class PluginDataTest {
     }
 
     @Suppress("unused")
-    private val jsonPrettyPrint = Json { prettyPrint = true }
-    private val json = Json {}
+    private val jsonPrettyPrint = Json {
+        prettyPrint = true
+        encodeDefaults = true
+    }
+    private val json = Json { encodeDefaults = true }
 
     @Test
     fun testStringify() {

+ 1 - 1
tools/gradle-plugin/src/VersionConstants.kt

@@ -10,6 +10,6 @@
 package net.mamoe.mirai.console.gradle
 
 internal object VersionConstants {
-    const val CONSOLE_VERSION = "2.0-M1" // value is written here automatically during build
+    const val CONSOLE_VERSION = "2.0-M1-dev-1" // value is written here automatically during build
     const val CORE_VERSION = "2.0-M1-dev-3" // value is written here automatically during build
 }