diff --git a/src/rider/main/kotlin/com/jetbrains/rider/plugins/efcore/features/connections/impl/AppSettingsConnectionProvider.kt b/src/rider/main/kotlin/com/jetbrains/rider/plugins/efcore/features/connections/impl/AppSettingsConnectionProvider.kt index 44824e7..227b0fc 100644 --- a/src/rider/main/kotlin/com/jetbrains/rider/plugins/efcore/features/connections/impl/AppSettingsConnectionProvider.kt +++ b/src/rider/main/kotlin/com/jetbrains/rider/plugins/efcore/features/connections/impl/AppSettingsConnectionProvider.kt @@ -23,7 +23,7 @@ class AppSettingsConnectionProvider(private val intellijProject: Project) : DbCo override fun getAvailableConnections(project: RdProjectDescriptor) = buildList { - val directory = (project.location as RdCustomLocation?)?.customLocation?.let(::Path)?.parent ?: return@buildList + val directory = (project.location as? RdCustomLocation)?.customLocation?.let(::Path)?.parent ?: return@buildList @NonNls val connectionStrings = directory.listDirectoryEntries("appsettings*.json") .filter { it.isRegularFile() } diff --git a/src/rider/main/kotlin/com/jetbrains/rider/plugins/efcore/features/connections/impl/JsonConnectionStringsManager.kt b/src/rider/main/kotlin/com/jetbrains/rider/plugins/efcore/features/connections/impl/JsonConnectionStringsManager.kt index cd608cb..5b8c5e3 100644 --- a/src/rider/main/kotlin/com/jetbrains/rider/plugins/efcore/features/connections/impl/JsonConnectionStringsManager.kt +++ b/src/rider/main/kotlin/com/jetbrains/rider/plugins/efcore/features/connections/impl/JsonConnectionStringsManager.kt @@ -32,9 +32,9 @@ class JsonConnectionStringsManager(intellijProject: Project) { * } */ private fun getConnectionsFromObject(fileName: String, jsonFile: JsonNode): List = buildList { - val obj = jsonFile.get("ConnectionStrings") as ObjectNode? ?: return emptyList() + val obj = jsonFile.get("ConnectionStrings") as? ObjectNode ?: return emptyList() obj.fieldNames().forEach { connName -> - val connString = (obj[connName] as TextNode?)?.textValue() + val connString = (obj[connName] as? TextNode)?.textValue() if (connString != null) add(DbConnectionInfo(connName, connString, fileName, null)) } @@ -53,7 +53,7 @@ class JsonConnectionStringsManager(intellijProject: Project) { null -> return@forEach else -> { val name = match.groups["name"]?.value ?: return@forEach - val connection = (jsonFile[settingsField] as TextNode?)?.textValue() ?: return@forEach + val connection = (jsonFile[settingsField] as? TextNode)?.textValue() ?: return@forEach add(DbConnectionInfo(name, connection, fileName, null)) } } diff --git a/src/rider/main/kotlin/com/jetbrains/rider/plugins/efcore/features/shared/services/JsonSerializer.kt b/src/rider/main/kotlin/com/jetbrains/rider/plugins/efcore/features/shared/services/JsonSerializer.kt index 8fccb57..02f9810 100644 --- a/src/rider/main/kotlin/com/jetbrains/rider/plugins/efcore/features/shared/services/JsonSerializer.kt +++ b/src/rider/main/kotlin/com/jetbrains/rider/plugins/efcore/features/shared/services/JsonSerializer.kt @@ -2,6 +2,7 @@ package com.jetbrains.rider.plugins.efcore.features.shared.services import com.fasterxml.jackson.core.JacksonException import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.core.json.JsonReadFeature import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.intellij.openapi.components.Service @@ -17,6 +18,7 @@ class JsonSerializer { jacksonObjectMapper() .enable(JsonParser.Feature.ALLOW_COMMENTS) .enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES) + .enable(JsonReadFeature.ALLOW_TRAILING_COMMA.mappedFeature()) fun getInstance() = service() }