Skip to content

SourceGenerator SourceText caching question #49921

Answered by sharwell
MarkPflug asked this question in Q&A
Discussion options

You must be logged in to vote

I'm trying to determine if SourceGenerators are a good fit for this use-case or not.

This is exactly the approach used by source generators in both dotnet/roslyn and DotNetAnalyzers/StyleCopAnalyzers. It's not the only good use case, but it's one where we would expect a good experience.

I was under the impression that there is caching and re-use of the syntax tree if the sourcetext hasn't changed. However, the source generator will still be called frequently, so I was thinking it would make sense to cache the output of the template transformation as well, since it only needs to be re-processed if the source template file has change.

These are the two primary optimizations under curren…

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@MarkPflug
Comment options

Comment options

You must be logged in to vote
1 reply
@MarkPflug
Comment options

Answer selected by MarkPflug
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@333fred
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants