Replies: 3 comments 1 reply
-
Feel free to PR! This sounds like something that should be feature flagged. For users that opt in, the kotlinx.serialization library itself should be a compile dependency of their projects; it doesn't need to be an |
Beta Was this translation helpful? Give feedback.
-
I think we can now start following versions more closely, with the drop of JDK 11 support for the upcoming 0.26. Extra serialisation support is certainly welcome. |
Beta Was this translation helpful? Give feedback.
-
In my first approach in #196, I got it working, in the sense that
Given the Pkl snippet: open class Something {
name: String? = null
}
class SomethingElse extends Something {
// ...
} @Serializable
open class Something(
open val name: String
) : java.io.Serializable {
// ...
}
// ...
@Serializable
class SomethingElse(
name: String,
val version: String,
) : Something(name), java.io.Serializable {
// ...
} The above yields:
Moving the property to an override doesn't work either:
I think, then, that in this example, @Serializable
sealed interface Something {
val name: String
fun copy(name: String): Toolchain
}
@Serializable
data class SomethingElse(
override val name: String
): Something {
override fun copy() = /* ... */
} I'll keep playing with it and see if I can nail down the minimal suite of changes to support this. There are a few things we could do:
|
Beta Was this translation helpful? Give feedback.
-
Hey there Pkl authors,
I was browsing the Pkl codebase and noticed there is no support just yet for KotlinX serialization in the code generator. The library is present, but isn't supported in the code generator yet or passed on as an API dependency.
One small wrinkle is that it looks like the currently declared version of KotlinX Serialization is incompatible with the project's version of Kotlin. To remedy this, there are a few options:
1.8.x
or later1.8.x
or later, keep embedded Kotlin pinnedOther than this wrinkle, adding KotlinX Serialization might not be such a huge change. The code generator could add the
@Serializable
annotation to trigger code-gen; the runtime dependency could probably be omitted from theapi
or made optional, so long as docs listed instructions for users to install their own KotlinX dependency.Would you guys be open to a PR to add such functionality?
Beta Was this translation helpful? Give feedback.
All reactions