SourceGenerator multiple steps (passing data from one to another)
Is there some way, possibly even documented way, to get let's say an attribute name in one SyntaxProvider Collection and do something with that in another one.
As of now I haven't found a way to make this work, as manually calling Collect and Select outside of RegisterSourceOutput results in the local variables being used as temp storage to transport these values between steps to have these values but only as long as they are inside the lambda scope of the Select method, the moment it's outside any change to local variables is lost.
Even attempts such as using static fields will not provide a working solution, nor playing around with passing the IncrementalValueProvider around to each and every step doesn't seem to be a possible solution.
Furthermore there doesn't seem to any documented examples of this when looking at the dotnet provided examples at: https://github.com/dotnet/roslyn-sdk/tree/main/samples/CSharp/SourceGenerators/SourceGeneratorSamples
e.g code along the lines of.:
If reasoning may be required:
I require to retrieve all attributes that inherit from a generic attribute in order to properly seperate if necessary the later on fetched classes in to their respective groups.
Furthermore these provided attributes contain necessary metadata, which are required for the generation of the necessary code.
As of now I haven't found a way to make this work, as manually calling Collect and Select outside of RegisterSourceOutput results in the local variables being used as temp storage to transport these values between steps to have these values but only as long as they are inside the lambda scope of the Select method, the moment it's outside any change to local variables is lost.
Even attempts such as using static fields will not provide a working solution, nor playing around with passing the IncrementalValueProvider around to each and every step doesn't seem to be a possible solution.
Furthermore there doesn't seem to any documented examples of this when looking at the dotnet provided examples at: https://github.com/dotnet/roslyn-sdk/tree/main/samples/CSharp/SourceGenerators/SourceGeneratorSamples
e.g code along the lines of.:
If reasoning may be required:
I require to retrieve all attributes that inherit from a generic attribute in order to properly seperate if necessary the later on fetched classes in to their respective groups.
Furthermore these provided attributes contain necessary metadata, which are required for the generation of the necessary code.
GitHub
Roslyn-SDK templates and Syntax Visualizer. Contribute to dotnet/roslyn-sdk development by creating an account on GitHub.