Open Wasabi375 opened 4 years ago
I don't really understand why we want a new annotation for this. Seems more straightforward to just mirror the experimental annotation out onto the generated code.
Yeah, you are totally right. Don't know why thought a separate annotation was necessary.
I want to use moshi to generate adapters for properties that use a custom
@Experimental
annotation. Currently this doesn't work because thetoJson
function generated by moshi won't compile as it's missing theOptIn(Experimental::class)
annotation.My suggestion is that moshi could add a
CodegenOptIn
annotation that adds the requiredOptIn
to thetoJson
andfromJson
functions.Also if you like the idea I can look into implementing this if you want. Let me know.
What are the situations where @Experimental annotation needs to be added in the code generated by using @JsonClass? since moshi doesn't support inline class yet
@tomridder some projects use @RequiresOptIn
for some of their code [0], and when annotated classes are part of an API, then one may need to have the JsonAdapter
annotated too.
PR's welcome on this one 👍
I want to use moshi to generate adapters for properties that use a custom
@Experimental
annotation. Currently this doesn't work because thetoJson
function generated by moshi won't compile as it's missing theOptIn(Experimental::class)
annotation.My suggestion is that moshi could add a
CodegenOptIn
annotation that adds the requiredOptIn
to thetoJson
andfromJson
functions.Also if you like the idea I can look into implementing this if you want. Let me know.