Original author(s) | Novell, Xamarin, Microsoft |
---|---|
Initial release | 2005; 19 years ago (2005) |
Stable release | v2.0.5 / June 13, 2019; 5 years ago (2019-06-13)[1] |
Repository | github |
Written in | C# |
Operating system | Linux, Windows |
Platform | .NET Framework, .NET Core, Mono |
Type | Software framework |
License | MIT License |
Website | Code Generation and T4 Text Templates |
Text Template Transformation Toolkit (usually referred to as "T4") is a free and open-source template-based text generation framework. T4 source files are usually denoted by the file extension ".tt".
T4 is used by developers as part of an application or tool framework to automate the creation of text files with a variety of parameters. These text files can ultimately be any text format, such as code (for example C#), XML, HTMLorXAML.
T4 uses a custom template format which can contain .NET code and string literals in it, this is parsed by the T4 command line tool into .NET code, compiled and executed. The output of the executed code is the text file generated by the template.[2] By using the Text Transformation class, T4 can also be run entirely from within a .NET application, eliminating the need for the end user to have Visual Studio installed.
T4 is used within Microsoft in ASP.NET MVC for the creation of the views and controllers, ADO.NET Entity Framework for entity generation, and ASP.NET Dynamic Data.[3] It is also used outside of Microsoft in projects such as SubSonic.[4]
T4 templating is supported in Visual Studio, MonoDevelop and JetBrains Rider.[5]
There are four types of controls handled by the T4 template transformation engine.
Name | Syntax | Description |
---|---|---|
Directives | <#@ ... #>
|
Instructions for the transformation engine |
Standard control blocks | <# ... #>
|
Code to be executed (e.g. loops) |
Expression control blocks | <#= ... #>
|
Expressions evaluated and converted to a string |
Class feature control blocks | <#+ ... #>
|
Class and function definitions |
Microsoft development tools
| |||||||
---|---|---|---|---|---|---|---|
Development environments |
| ||||||
Languages |
| ||||||
APIs and frameworks |
| ||||||
Database |
| ||||||
Source control |
| ||||||
Testing and debugging |
| ||||||
Delivery |
| ||||||
| |
---|---|
Graphics and UI |
|
Audio |
|
Multimedia |
|
Web |
|
Data access |
|
Networking |
|
Communication |
|
Administration and management |
|
Component model |
|
Libraries |
|
Device drivers |
|
Security |
|
.NET |
|
Software factories |
|
IPC |
|
Accessibility |
|
Text and multilingual support |
|
| |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||
People |
| ||||||||||
Products |
| ||||||||||
Company |
| ||||||||||
Campaigns |
| ||||||||||
Criticism |
| ||||||||||
Litigation |
| ||||||||||
Acquisitions |
| ||||||||||
|
.NET
| |||||||
---|---|---|---|---|---|---|---|
| |||||||
Implementations |
| ||||||
Architecture |
| ||||||
Components |
| ||||||
Tools |
| ||||||
IDEs |
| ||||||
Organizations |
| ||||||
|