We have a number of templates written using T4 and the tangible multiple file generation library.
One example of this is as follows: -
A number of Entity objects in a C# library inheriting from a "BaseEntity" and attributed with a "RequiresAudit" attribute.
These entities are located and analysed in a T4 template by the afore mentioned inheritance of "BaseEntity" and attribution of "RequiresAudit".
Once analysed the T4 produces 3 trigger files of SQL that are applied in a legacy tool by the DB team and a documentation file in a JSON format.
So we require that the T4 produce a number of artefacts from the template run - 3 "Entity.SQL" files and a "docs.json" file.
All of our new code on the .NET side will be moved to .NET 5, this is the only big-bang our managers are prepared to undertake at this stage.
Question...
How can we make use of a Roslyn Analyser or Generator to do exactly the same job ? We must have the generated files in our project available. How do we achieve this ? Can anyone give a good example ? Can Roslyn include the files in the project as an embedded resource, if so how ?
We really want to learn Roslyn, but we're also scared we could be wasting effort.
T4 support seems to be lacking on the VS2019 preview (when using .net 5 anyway) and I'm also concerned the movement in tech appears to be gravitating towards the Roslyn world anyway and that T4 may be nearing an end of life.
All of the documents I've read about Roslyn Code Generators don't appear to leave behind any files and simply compile a set of features into the assembly without any trace of the code source files. I just can't seem to find an obvious way to go from T4 to Roslyn in the same way that t4 works.
I don't need the "why are you doing it like this ?" comments. We can't change much. Just a nice friendly way (example) to solve the problem without re-writing the various touch-points we have in our legacy system.