Extend T4 code generator to create multiple files from one model with one template.
Custom code generation becomes more and more important. For example network messages can be described using .xls file (each message field is one Excel cell).
At the moment T4 cannot be used to gen multiple files from one model with one template.
In case of networking multiple files must be generated: a class file per message, a switch method for dispatching messages, a parser, an asynch handler of messages and timeouts, ...
Thanks for taking the time to share this suggestion. This item has been around for a couple of versions of Visual Studio and we haven’t acted on it. Looking at the VS “15” plans, we’re not going to take action on this item, so we’re going to close it. If the suggestion is still relevant, please either take a look to see if there’s another suggestion that’s similar that you can vote on, or open a new suggestion.
- The Visual Studio Team
Doug Allen commented
This feature already exists. Look at the t4 templates that are created by Entity Framework 4. They generate one file per entity
I am using the tangible T4 Editor that comes with a reusable sample of how to create multiple output files. Maybe you want to check this out.
This is a feature I needed in T4 in the past. Definitely gets my vote +1
Michael Paterson commented
I would TOTALLY vote for this if I had any left. In addition I would throw in the option to prevent the default file generation. Ie. if you have MyTestFile.tt that actually generated 4 other files and nothing in MyTestFile.cs, it would be nice to be able to turn off the generation of MyTestFile.cs.