I want to use source generators more in my project. Something that I need to often do, is generate code that is then utilised by another generator.
For example.
I have written a generator that produces a dart file from a swagger json schema. That dart file is annotated with @JsonSerializable - so it should then trigger a serializer to be generated.
In this simple case it more of less works - however I think that's mostly down to the luck of the draw.
There are more complex scenarios, such as ones that utilise the MobX generator - these appear extremely flakey and often break when things are not generated in the correct order. Sometimes I need to just "touch" a specific file in a particular way to either break or fix the build runner.
Has this scenario been considered in the design of the source_gen subsystem, and how do I ensure this is working correctly?
Thanks,
I suppose you need to ensure that your generators are executed in the correct order because the orders in which generators run can sometimes affect the outcome.
You can use the
build.yamlfile to specify the order in which generators should run.Here is a real-world sample: