kmongo
kmongo copied to clipboard
kotlinx.serialization: remove the need of reflection completely
Starting from 1.4.0, @SerialName
is no longer usable with reflection at runtime. The workaround provided fro now by KMongo is to use @MongoId
& @MongoProperty
to detect custom @SerialName
at runtime. It would be better to use an annotation processor that detects @SerialName
and build a repository of ids and custom property names.
Hi,
maintainer of kotlinx.serialization here. We've changed annotation retention to binary because we were not expecting that anyone would read them via reflection (the kotlinx.serialization itself reads them via compiler plugin). We'll see if we can change retention back. I also wonder, what other annotations do you read by reflection? E.g. @Transient
, @Required
now also have binary retention. Can this cause problems?
No, the issue is only with @SerialName,
because KMongo needs to check the property name in order to build dedicated path for mongo queries (and also apply custom behaviour for _id
fields). I see that you fixed the issue - and it's great. I let open this issue because avoiding completely reflection would be better :)