Open bartekpacia opened 2 years ago
Maybe the copy withs should be generated in a separate file as extension methods (which then will be re-exported by the contracts)? It will be annoying that contracts will have to be imported to be able to use copy with, but in return it will keep the original contracts file clean.
What do you think?
IMHO it's okay :)
I would like to implement a more modular approach where anyone could provide custom annotations to generated classes. Then, one could annotated DTOs with @CopyWith()
if they please. However this has a few issues:
@JsonSerializable()
needs a fromJson
constructor and a toJson
method)@CopyWith()
will crash if annotated on an incorrect class). The means we would need some user-provided resolving unit, ie more than a config fileI hope that point 1 will get solved once promised metaprogramming lands in dart
Thanks for explaining 👍
It'd be useful if
DTO
s (or all classes, so commands and queries as well? I really don't know) already came withcopyWith()
generated.There could be some flag in
contracts_generator.yaml
to enablecopyWith()
generation (to reduce size of the generated code and time of generation when the project doesn't need this feature).