EDIT: Looks like there's an open issue here: <http...
# serialization
EDIT: Looks like there's an open issue here: https://github.com/Kotlin/kotlinx.serialization/issues/2132 Is there a clean way to approach this without a surrogate class?
Copy code
class DormaKabaKey(private val file: NeonFile) : Key<NeonFile>, NeonFile by file {

    private val fileId: ByteArray? = file.fileId
    private val fileDefinitionName: String? = file.fileDefinitionName

    override fun getFileId() = fileId
    override fun hasFileId() = fileId !== null

    override fun getFileDefinitionName() = fileDefinitionName
    override fun hasFileDefinitionName() = fileDefinitionName !== null
For context, I'm using a proprietary library with NO caching support which is why I'm serializing their door lock credential type, and I have omitted many fields The better way to put it, I don't care about NeonFile or the impl, only my class and its values where it'll be then be reconstructed when being deserialized.
Stack trace:
Copy code
kotlinx.serialization.SerializationException: Class 'b' is not registered for polymorphic serialization in the scope of 'NeonFile'.
                                                                                                    Mark the base class as 'sealed' or register the serializer explicitly.
                                                                                                    	at kotlinx.serialization.internal.AbstractPolymorphicSerializerKt.throwSubtypeNotRegistered(AbstractPolymorphicSerializer.kt:102)
                                                                                                    	at kotlinx.serialization.internal.AbstractPolymorphicSerializerKt.throwSubtypeNotRegistered(AbstractPolymorphicSerializer.kt:113)
                                                                                                    	at kotlinx.serialization.PolymorphicSerializerKt.findPolymorphicSerializer(PolymorphicSerializer.kt:109)
                                                                                                    	at kotlinx.serialization.internal.AbstractPolymorphicSerializer.serialize(AbstractPolymorphicSerializer.kt:32)
                                                                                                    	at kotlinx.serialization.protobuf.internal.ProtobufEncoder.encodeSerializableValue(ProtobufEncoding.kt:138)
                                                                                                    	at kotlinx.serialization.protobuf.internal.ProtobufTaggedEncoder.encodeSerializableElement(ProtobufTaggedEncoder.kt:135)
                                                                                                    	at com.stratisiot.stratissdk.keyring.key.DormaKabaKey.write$Self(DormaKabaKey.kt:8)
                                                                                                    	at com.stratisiot.stratissdk.keyring.key.DormaKabaKey$$serializer.serialize(DormaKabaKey.kt:8)
                                                                                                    	at com.stratisiot.stratissdk.keyring.key.DormaKabaKey$$serializer.serialize(DormaKabaKey.kt:8)
                                                                                                    	at kotlinx.serialization.protobuf.internal.ProtobufEncoder.encodeSerializableValue(ProtobufEncoding.kt:138)
                                                                                                    	at kotlinx.serialization.protobuf.ProtoBuf.encodeToByteArray(ProtoBuf.kt:130)
The nice thing about using delegation like this is that I do not need to reference the file property at all, it's still a LEGIC Neon File ­čÖé
At the very least it requires
to be serializable/have a serializer (which it doesn't appear to be based upon your posted errors).
NeonFile itself is an interface but the delegation provides a proprietary implementation, yes
You will have to explicitly mark the
property as
with the type of the actual serializer to use (the proprietary one should work correctly due to erasure, but you could write your own little wrapper).
Or transient, could work? fails compile check, I'll try this suggestion
looks like I'll need to make a wrapper