I have a c# project which includes a Text Template. I would like this template to generate some SQL based on reflecting against the C# classes in the project.
How does one access the current project’s contents using T4? Is it possible, and if so, is Reflection available, or is it access to just the raw source that must then be parsed?
Thanks in advance!
One way is to use the EnvDTE COM component. Googling T4 and EnvDTE should bring back plenty of examples.
Reflection is definitely available from T4. It works mostly as you would expect.
Oleg Sych has a number of great blog entries regarding common T4 usage scenarios, but there are plenty of other resources for T4 out there as well.