crashtua
crashtua

Reputation: 491

Is it possible to generate source based on syntax tree generated by another generator?

For example, we have Pure.DI library that generates fast DI compositions. Is it possible to create generator that creates input for Pure.DI generator(based on some attributes or another kind of metainformation) and then make sure that Pure.DI generates its internal code based on output of our generator?

Upvotes: 1

Views: 327

Answers (1)

Yevhen Cherkes
Yevhen Cherkes

Reputation: 851

Unfortunately it's impossible for roslyn source generators.

Each generator will see the same input compilation, with no access to files created by other source generators.

See the documentation.

But I believe you can achieve that by running custom exe, batch, or even T4-based generator in pre-build action of msbuild or csproj file.

Upvotes: 1

Related Questions