What's the proper way to build source generator?
Problem
I've just started my source generator with minimal example.
When I made change to
C.Text
, and run dotnet build
or dotnet clean && dotnet build
for generator project, the change doesn't apply to the console app references this generator(sometimes it may work)
Console project
## Generator project
2 Replies
If you're asking about the proper way to build source generators, then the proper way is to write unit tests for the generator.
It's generally a pain to debug and test generators by running them from the command-line, and tests are a much more reliable method of testing them.
On another note, this generator is quite obviously a work-in-progress, but you should never do
context.CompilationProvider.Combine(...);
as passing Compilation
s through your incremental pipeline completely breaks incrementality.I simply followed the introduction from dotnet channel on youtube, I can't find documentation of
IIncrementalGenerator
with unit testing, they're almost all about ISourceGenerator
. Currently I don't really understand what incrementality
is, is a there any recommended doc or video to follow?