Open fsvehla opened 3 years ago
It would be great to have some handy approach for derivation configuration without annotations in Scala 3.
As an example, jsoniter-scala-macros for Scala 2 uses a configuration parameter for the make
macro, which is passed to the macro implementation as an expression and evaluated in the compile-time using Eval.eval
. That allowed to derive codecs with different customization without adding of annotations.
I’ll look into this, @plokhotnyuk, thanks for the pointer :)
@fsvehla The problem only that Scala 3 doesn't have Eval.eval
anymore...
Work on Decoder
looks good, with the snag that I have yet to figure out why all sum type members need to define a Decoder
.
object examplesum {
sealed abstract class Parent
object Parent {
implicit val decoder: JsonDecoder[Parent] = DeriveJsonDecoder.gen
}
case class Child1() extends Parent
object Child1 {
// not necessary with Magnolia
implicit val decoder: JsonDecoder[Child1] = DeriveJsonDecoder.gen
}
case class Child2() extends Parent
object Child2 {
// not necessary with Magnolia
implicit val decoder: JsonDecoder[Child2] = DeriveJsonDecoder.gen
}
}
Magnolia is moving quite slowly, and I think that I can implement all of it’s functionality using Scala 3’s auto derivation + a few simple macros for case class annotations.