avro-kotlin / avro4k

Avro format support for Kotlin
Apache License 2.0
188 stars 36 forks source link

Full reflection-less encoding and schema generation #199

Open Chuckame opened 2 months ago

Chuckame commented 2 months ago

Currently, in v2, we set a class using AvroSchema and AvroLogicalType annotations to be able to customize the final schemas and add logical types, but this requires kotlin reflection to allow creating the instance of the given class. In v1, we unwrap the nullable SerialDescriptors to get back the AvroDescriptor to access the custom methods for generating the schemas.

A PR has been done to be able of unwrapping a nullable descriptor, that now allows us to retrieve the original descriptor, so we can get rid of reflection for logical types and custom schemas, and it allows us to create brand new methods and interfaces on a standard SerialDescriptor.

This has been done here: https://github.com/Kotlin/kotlinx.serialization/commit/c7bcaf1cb92685ffb6c2d46c9e22d0b7e6e20811

When kotlin-serialization is released, avro4k v2 will be allowed to be released