tangible T4 Directives
The tangible T4 Editor extends the set of existing T4 Directives that can be used inside T4 Text Template files. This list gives an overview on additional directives that can be used when working with the tangible T4 Editor.
The documentation of the basic T4 Text Template Directives is availabl in this MSDN Article.
Directive: assemblyForIntelliSenseOnly
Purpose
Loads an assembly only for IntelliSense availability and not transformation execution.
Background
For using functionality of external assemblies inside T4 templates, those assemblies can be referenced from that template using the <#@ assembly #> directive (T4 Assembly Directive). Referencing an assembly enables IntelliSense and AutoCompletion for this assembly by the tangible T4 Editor.
Now when working with reusable templates that are included in other templates and both templates reference the same assembly, the templates cannot be transformed any more.
That’s why the <@# assemblyForIntelliSenseOnly #> directive was introduced. Replacing an assembly reference with this directive still enables IntelliSense and AutoCompletion but does not fail the transforming process.
Sample
This sample consists of two T4 template files: a .tt-File and a reusable template (.ttinclude). Both reference the assembly EnvDTE.dll for accessing the VisualStudio Automation Interface. But the .tt-File uses the <#@ assemblyForIntelliSenseOnly #> directive in order to use IntelliSense.
VisualStudioAutomation.tt
<#@ template hostspecific="true" language="C#" debug="true" #>
<#@ assemblyForIntellisenseOnly processor="tangibleT4Editor" name="EnvDTE" #>
<#@ include file="Reusable.ttinclude" #>
<#
var hostServiceProvider = this.Host as IServiceProvider;
var visualStudio = hostServiceProvider.GetService(typeof(EnvDTE.DTE));
#>
Reusable.ttinclude
<#@ intelliSenseLanguage processor="tangibleT4Editor" language="C#" #>
<#@ assembly name="EnvDTE" #>