Engine.PreprocessTemplate Method (String, ITextTemplatingEngineHost, String, String, String, String[])


Generates code from a template that, when it is compiled and run, will produce the template output.

Namespace:   Microsoft.VisualStudio.TextTemplating
Assembly:  Microsoft.VisualStudio.TextTemplating.12.0 (in Microsoft.VisualStudio.TextTemplating.12.0.dll)

public string PreprocessTemplate(
	string content,
	ITextTemplatingEngineHost host,
	string className,
	string classNamespace,
	out string language,
	out string[] references


Type: System.String

The content of the template.

Type: Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost

A template host, which should implement ITextTemplatingEngineHost.

Type: System.String

The name of the class that you want the template code to have.

Type: System.String

The namespace in which you want the template code to be generated.

Type: System.String

The language of the generated code.

Type: System.String[]

Assemblies specified by the template or the host.

Return Value

Type: System.String

A string that can be compiled.

For more information, see Run-Time Text Generation with T4 Text Templates and Processing Text Templates by using a Custom Host.


If you are writing a package or extension that will run within Visual Studio, consider using the text templating service instead of writing your own host. For more information, see Invoking Text Transformation in a VS Extension.

Return to top