I am writing software that produces C# code. Mostly I am using StringTemplate and StringBuilder.
Is there any way to use T4 templates direct from my code?
I am writing software that produces C# code. Mostly I am using StringTemplate and StringBuilder.
Is there any way to use T4 templates direct from my code?
Take a look at the MSDN article Creating Custom Text Template Directive Processors which covers what you're after if I understand you correctly.
Oleg Sych describes how to do this here: Understanding T4: Preprocessed Text Templates. Note that it looks like you'll need Visual Studio 2010 to generate a preprocessed Text Template, but you'll be able to host the preprocessed Text Template wherever you like - including within your WinForms application.