Skip to content

[IIncrementalGenerator] Multiple files same symbol #71575

Discussion options

You must be logged in to vote

You'll need your incremental generator pipeline to .Collect all the elements and process them in aggregate to know what to merge and what to filter or throw out.

Note:

I'm trying to create an incremental generator that generates a code when the symbol has an attribute

You should use .ForAttributeWithMetadataName for this purpose. It's normally around 100x faster and uses around 100x memory to accomplish the same task. As a bonus, it is symbol (not syntax) based. So you'd only get this symbol a single time, even though it has multiple parts spread across multiple files.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by CyrusNajmabadi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants