-
Notifications
You must be signed in to change notification settings - Fork 636
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
Add factory function to wrap a serial descriptor with a custom name #1547
Conversation
core/commonMain/src/kotlinx/serialization/descriptors/SerialDescriptors.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! Can you please also add to cbor tests your use-case with a custom serializer over byte array?
core/commonTest/src/kotlinx/serialization/WrappedSerialDescriptorTest.kt
Outdated
Show resolved
Hide resolved
Unfortunately, I ran into a problem when I tried to add tests for custom CBOR byte strings. When the CBOR encoder/decoder checks for Here is the code for the function that CBOR uses to check for private fun SerialDescriptor.isByteString(index: Int): Boolean {
val elementDescriptor = getElementDescriptor(index)
val byteArrayDescriptor = ByteArraySerializer().descriptor
return (elementDescriptor == byteArrayDescriptor || elementDescriptor == byteArrayDescriptor.nullable) &&
getElementAnnotations(index).find { it is ByteString } != null
} The only solution I see is to remove the check for Do you think removing the check for |
I think it's would be safe to do so, if it is sufficient to do that so custom serializer works. Probably custom serializers just didn't come into mind when this piece of code was written |
I have fixed |
core/commonMain/src/kotlinx/serialization/descriptors/SerialDescriptors.kt
Show resolved
Hide resolved
core/commonMain/src/kotlinx/serialization/descriptors/SerialDescriptors.kt
Outdated
Show resolved
Hide resolved
Many thanks! It was a pleasure working with you |
See #1516 for context.