How to: Import Namespaces in Text Templates
You can add an importdirective to text templates. This enables you to specify the namespaces that you want to use in those text templates. For more information, see Directive Syntax (Domain-Specific Languages).
You can add a namespace to a text template to avoid having to use fully-qualified names in the code in your text template.
To import a namespace
In Solution Explorer, right-click the text template file that you want to edit, and then click Open.
The template opens in the editor.
Specify a namespace using the import directive, as shown in the following example:
<#@ import namespace = "System.Collections.Generic" #>
Example
The following example shows you how to use the import directive.
<#@ import namespace = "System.Collections.Generic" #>
<#
List<string> names=new List<string>();
#>
<#@ import namespace = "System.Collections.Generic" #>
<#
Dim names As List(Of String) = New List(Of String)
#>
To debug text templates, you must set the debug parameter of the template directive. For more information, see How to: Debug Text Templates.
Security
For more information, see Security of Text Templates.