source_gen
source_gen copied to clipboard
Coverage ignore option
Hi,
is it possible to add an option to combining_builder which leads to the line //coverage:ignore-file beeing added on top of generated files. Or is there already an existing solution?
Something like:
targets:
$default:
builders:
source_gen:combining_builder:
options:
coverage-ignore-file: true
It could be added (would work similar to ignore_for_file).
Note though that this would take effect for all source_gen builder outputs that are combined into that file, which might be fine, but is worth keeping in mind.
I would probably try and lean towards something a bit more general though than a coverage-specific thing. Not sure why ingore_for_file was implemented that way as a general approach would also have solved this use case :).
Yep i agree a general approach would be the preferable solution.
I spoke a bit with @kevmoo and it sounds like we agree this is a sensible feature to have - but I don't think either of us have the time to implement it at this time. We would accept a PR though, either with a specific option to ignore coverage (maybe ignore_coverage: true?) or a general preamble option which accepts any text and inserts it at the top of the file. If we did the more general approach we would want to ensure the text ends with a newline.
See https://github.com/dart-lang/source_gen/pull/636#issuecomment-1384683749
er, preamble