Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump org.jetbrains.kotlinx:kotlinx-serialization-json from 1.7.3 to 1.8.0 #1299

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ kotlin = "2.1.0"
kotlinCoroutines="1.9.0"
ktor="3.0.3"
kotlinHtml="0.8.0"
kotlinSerialization="1.7.3"
kotlinSerialization="1.8.0"
ignite="2.16.0"
apacheCxf="3.6.5"
node="22.12.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import com.badoo.reaktive.observable.zip
import com.badoo.reaktive.single.asObservable
import com.badoo.reaktive.single.map
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.InternalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.descriptors.SerialKind
import kotlinx.serialization.descriptors.StructureKind
import kotlinx.serialization.descriptors.buildSerialDescriptor
import kotlinx.serialization.encoding.CompositeDecoder
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
Expand Down Expand Up @@ -206,7 +207,13 @@ class ZipOutputSerializer<CommonT, Out : IZipOutput<CommonT>>(
override val descriptor: SerialDescriptor = if (elementSerializers.size == 1) {
elementSerializers.single().descriptor
} else {
ZipNOutputDesc(elementSerializers.map { it.descriptor }.toTypedArray())
val typeParameters = elementSerializers.map { it.descriptor }.toTypedArray()
@OptIn(InternalSerializationApi::class)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reported, that we need to use this internal API for our use-case at Kotlin/kotlinx.serialization#2899

buildSerialDescriptor("modelix.zipN", StructureKind.LIST, *typeParameters) {
elementSerializers.forEachIndexed { index, elementSerializer ->
element(index.toString(), elementSerializer.descriptor)
}
}
}

override fun serialize(encoder: Encoder, value: ZipStepOutput<Out, CommonT>) {
Expand All @@ -222,39 +229,6 @@ class ZipOutputSerializer<CommonT, Out : IZipOutput<CommonT>>(
}
}

internal class ZipNOutputDesc(val elementDesc: Array<SerialDescriptor>) : SerialDescriptor {
@ExperimentalSerializationApi
override val elementsCount: Int
get() = elementDesc.size

@ExperimentalSerializationApi
override val kind: SerialKind
get() = StructureKind.LIST

@ExperimentalSerializationApi
override val serialName: String
get() = "modelix.zipN"

@ExperimentalSerializationApi
override fun getElementAnnotations(index: Int): List<Annotation> = emptyList()

@ExperimentalSerializationApi
override fun getElementDescriptor(index: Int): SerialDescriptor = elementDesc[index]

@ExperimentalSerializationApi
override fun getElementIndex(name: String): Int {
return name.toIntOrNull() ?: throw IllegalArgumentException("$name is not a valid list index")
}

@ExperimentalSerializationApi
override fun getElementName(index: Int): String {
return index.toString()
}

@ExperimentalSerializationApi
override fun isElementOptional(index: Int): Boolean = false
}

data class ZipStepOutput<E : IZipOutput<Common>, Common>(val values: List<IStepOutput<Common>>) : IStepOutput<E> {
override val value: E
get() = ZipNOutput(values.map { it.value }) as E
Expand Down
Loading