Extends Text Templates with syntax colorization, tooltips, error reporting, outlining, generation of multiple output files with source control integration, support for template parameters in Solution Explorer properties and more.
The T4Toolbox complete what Microsoft has done with T4 Templates. I will give the T4Toolbox five stars when support for Preprocessed Templates are added.
We created a library of preprocessed templates that is compiled into a dll that we call at design time from a standard T4 script. We do this because standard T4 Templates have limitations that preprocessed templates do not.
Hopefully, Oleg will add preprocessed template support to his T4Toolkit soon. Then I will bump the rating to five stars.
T4 as provided is an incomplete code generation solution. The t4 toolbox raises it to a level of production usage that makes using t4 in many situations a pleasure. Oleg delved into all its nooks and crannies to make a complete and continually evolving solution for many t4 code generation problems.
I recently created the connect feedback item: https://connect.microsoft.com/VisualStudio/feedback/details/789769/xaml-designer-crashes-error-reading-from-the-pipe as I thought my Visual Studio crashed because of a XAML designer error. But it seems the Visual Studio crash is in some way related to the T4ToolBox extension, as I get the following exception just before VS2012 crashes:
System.Runtime.InteropServices.COMException was unhandled
Message=The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))
at EnvDTE.IExtenderSite.NotifyDelete(Int32 Cookie)
Hope this helps you to diagnose the problem.
Here are some of the ideas I'm considering:
- Test adapter to allow running T4 unit tests in Visual Studio Test Explorer
- Support for SQL DB projects
- Language service to provide color syntax highlighting and IntelliSense for editing .tt files in Visual Studio
- An IWizard to allow using .tt files in Visual Studio project item templates
- Support MSBuild
Which ones are more important to you? What else would you like to see in T4 Toolbox?
The test adapter and the support for MSBuild would be very welcome in enterprise projects.
Color syntax highlighting is already provided by a number of tools so that would be very low on my list.
Thanks for the update!
I'm having some trouble getting my current templates updated to run in the new release. Would you be able to provide some guidance documentation to help us get back up to speed. I know you listed a lot of good details on your blog, but specifically a complete example of how to get access to the DTE to access the removed properties like "Project" would be great.
I added an assembly directive for DTE, but I'm not sure if it's the right version or if there is something else I'm missing.
I was able to get this working. Here's an example of accessing the DTE.
<#@ template language="C#" debug="True" #>
<#@ output extension="cs" #>
<#@ assembly name="EnvDTE" #>
<#@ include file="T4Toolbox.tt" #>
var dte = (EnvDTE.DTE)TransformationContext.Current.GetService(typeof(EnvDTE.DTE));
var project = (EnvDTE.Project)((object)dte.ActiveSolutionProjects);
var projectPath = project.FullName;
I'm sorry this caused trouble. I updated my post at http://www.olegsych.com/2012/12/t4-toolbox-for-visual-studio-2012 to show an example of how to get all of the missing properties. It is slightly different than what you posted here. Hope this helps. Let me know if you run into any other conversion problems.
Thanks! Excellent example. Very helpful.
All this time I thought you were too busy with other things to update your T4 Toolbox for vs2012. Actually it looks like you've been very busy working on the T4 Toolbox. A complete rewrite! That's great. I like the direction you are taking the project. I personally never used any of the things that had to be removed so I have no issue there.
Looking at your roadmap, SQLDB project support would be at the top of my list. As much as I'd love to get support of colorized syntax and IntelliSense directly from the T4 Toolbox, as Jonkers stated above, we do already have that from other tools.
I have installed the T4 Toolbox on two different machines (VS2012), now, and neither one of them are showing the T4 Toolbox templates in the Add New Item dialog.
Is there some installation step I'm missing beyond installing from Extension Manager and restarting Visual Studio?
No, that should be all that's needed. Have you had any recent Visual Studio crashes or problems with other extensions?
Try deleting %LocalAppData%\Microsoft\VisualStudio\11.0\ComponentModelCache and restarting Visual Studio.
I had a class that descended from Template and it used TransformationContext to access the Host property. This worked with VS 2010. I'm now using the T4 Toolbox beta in VS 2012 and when I have a line like:
string fullname = TransformationContext.Host.ResolvePath(aFileName);
I get the error:
Compiling transformation: An object reference is required for the non-static field, method, or property 'T4Toolbox.TransformationContext.Host.get'
I was able to get around this by adding a ITextTemplatingEngineHost Host property to my class and setting the property after creating an instance of the class.
Is this by design or will it be fixed?
TransformationContext now implements the Singleton pattern consistently with other classes in the .NET framework. In particular, instead of exposing several static properties, it now provides just one - Current. All properties that were static before are now instance properties and can be accessed like so: