TextTransformation TextTransformation TextTransformation TextTransformation Class


Base class for generated text transformations

public ref class TextTransformation abstract : IDisposable
public abstract class TextTransformation : IDisposable
type TextTransformation = class
    interface IDisposable
Public MustInherit Class TextTransformation
Implements IDisposable


Any class specified in an inherits directive must match this class in a duck-typing style.

Note that this class therefore specifies an implicit contract with the transformation object.

The object doesn't have to derive from any specific type or interface, but it must have

a) A void Initialize() method.

b) A string TransformText() method

c) An Errors property that's duck-compatible with CompilerErrorCollection

d) A GeneratonEnvironment property that's duck-compatible with StringBuilder.

e) A void Write(string) method

Using any further features of T4 such as expression blocks will require the class to have further methods, such as ToStringHelper, but

those will produce regular compiler errors at transform time that the base class author can address.

These few methods together form a subset of the TextTransformation default base class' API.

If you change this pseudo-contract to add more requirements, you should consider this a breaking change.

It's OK, however, to change the contract to have fewer requirements.


TextTransformation() TextTransformation() TextTransformation() TextTransformation()


CurrentIndent CurrentIndent CurrentIndent CurrentIndent

Gets the current indent we use when adding lines to the output

Errors Errors Errors Errors

The error collection for the generation process

GenerationEnvironment GenerationEnvironment GenerationEnvironment GenerationEnvironment

The string builder that generation-time code is using to assemble generated output

Session Session Session Session

Current transformation session


ClearIndent() ClearIndent() ClearIndent() ClearIndent()

Remove any indentation

Dispose() Dispose() Dispose() Dispose()

Disposes the state of this object.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Dispose implementation.

Error(String) Error(String) Error(String) Error(String)

Raise an error

Finalize() Finalize() Finalize() Finalize()


Initialize() Initialize() Initialize() Initialize()

Initialize the templating class

PopIndent() PopIndent() PopIndent() PopIndent()

Remove the last indent that was added with PushIndent

PushIndent(String) PushIndent(String) PushIndent(String) PushIndent(String)

Increase the indent

TransformText() TransformText() TransformText() TransformText()

Generate the output text of the transformation

Warning(String) Warning(String) Warning(String) Warning(String)

Raise a warning

Write(String) Write(String) Write(String) Write(String)

Write text directly into the generated output

Write(String, Object[]) Write(String, Object[]) Write(String, Object[]) Write(String, Object[])

Write formatted text directly into the generated output

WriteLine(String) WriteLine(String) WriteLine(String) WriteLine(String)

Write text directly into the generated output

WriteLine(String, Object[]) WriteLine(String, Object[]) WriteLine(String, Object[]) WriteLine(String, Object[])

Write formatted text directly into the generated output

Applies to