Generate for library #94
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
I've tried to use
source_gen_test
but found some limitations because my generator produces multiple outputs.I have first modified (slightly)
generateForElement
to accept an optional customBuildStep
(the mock implementation caused crashes in my case). It should not be a breaking change, and it allowed me to test the main ourput using annotations fromsource_gen_test
.However, it didn't help for additional outputs. So I've added a new function
generateForLibrary
which can be used to generate code for a full library and return the build results to the caller, so further checks can be done. Right now, checks must be implemented in the test code.I suppose adding more test annotations in
source_gen_test
could make the experience forgenerateForLibrary
as streamlined as it is forgenerateForElement
+@shouldGenerate*
. But I haven't explored this for the time being. I'm happy enough with checking the generated code programmatically. Actually I think I'd be more interested in assessing the resulting object model or AST, making sure expected classes and methods are there while allowing for some differences due to implementation detail changes as the generator evolves.Are you interested in accepting this pull request?