roslyn-sdk icon indicating copy to clipboard operation
roslyn-sdk copied to clipboard

Companion file output for code generators

Open xstos opened this issue 3 years ago • 0 comments

this is similar to https://github.com/dotnet/roslyn-sdk/issues/867

I tested out source generators this weekend. I wanted to gather type names as projects build for IOC dynamic loading purposes.

Two questions:

  • Is there a way to see where the target assembly is going (i.e. bin/artifacts folder)?
  • Can I produce companion files to the assembly containing indexed information next to the outputted assembly that I collect as the generator is running?

I hacked in a silly way to achieve what I wanted, but it's pretty sketch.

I find the assemblyinfo.cs folder path, crawl up the folder structure until by git repo, then locate my output folder that way.

https://github.com/xstos/apps/blob/master/playground/csharp/IndexerSourceGenerator/IndexerSourceGenerator/Indexer.cs

PS I was sad when I saw the AST is read only. My first thought was to create a babel-like plugin architecture for code rewriting. Although I'm still going to try cloning the compilation somehow and using roslyn to produce an augmented (rewritten assembly) babel.js-style.

Thanks,

Chris

xstos avatar Jun 28 '21 14:06 xstos