Text Template Transformation Toolkit

Last updated
Text Template Transformation Toolkit (T4)
Original author(s) Novell, Xamarin, Microsoft
Initial release2005;18 years ago (2005)
Stable release
v2.0.5 / June 13, 2019;4 years ago (2019-06-13) [1]
Repository github.com/mono/t4
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".

Contents

Overview

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, HTML or XAML.

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]

Controls

There are four types of controls handled by the T4 template transformation engine.

NameSyntaxDescription
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

History

See also

Related Research Articles

<span class="mw-page-title-main">Visual Basic (.NET)</span> Object-oriented computer programming language

Visual Basic (VB), originally called Visual Basic .NET (VB.NET), is a multi-paradigm, object-oriented programming language, implemented on .NET, Mono, and the .NET Framework. Microsoft launched VB.NET in 2002 as the successor to its original Visual Basic language, the last version of which was Visual Basic 6.0. Although the ".NET" portion of the name was dropped in 2005, this article uses "Visual Basic [.NET]" to refer to all Visual Basic languages released since 2002, in order to distinguish between them and the classic Visual Basic. Along with C# and F#, it is one of the three main languages targeting the .NET ecosystem. Microsoft updated its VB language strategy on 6 Feb 2023 stating that VB is a stable language now and Microsoft will keep maintaining it.

<span class="mw-page-title-main">Microsoft XNA</span> Freeware set of tools by Microsoft

Microsoft XNA is a freeware set of tools with a managed runtime environment that Microsoft developed to facilitate video game development. XNA is based on .NET Framework, with versions that run on Windows and Xbox 360. XNA Game Studio can help develop XNA games. The XNA toolset was announced on March 24, 2004, at the Game Developers Conference in San Jose, California. A first Community Technology Preview of XNA Build was released on March 14, 2006.

ASP.NET is an open-source, server-side web-application framework designed for web development to produce dynamic web pages. It was developed by Microsoft to allow programmers to build dynamic web sites, applications and services. The name stands for Active Server Pages Network Enabled Technologies.

<span class="mw-page-title-main">SharpDevelop</span>

SharpDevelop is a discontinued free and open source integrated development environment (IDE) for the .NET Framework, Mono, Gtk# and Glade# platforms. It supports development in C#, Visual Basic .NET, Boo, F#, IronPython and IronRuby programming languages.

Windows Presentation Foundation (WPF) is a free and open-source graphical subsystem originally developed by Microsoft for rendering user interfaces in Windows-based applications. WPF, previously known as "Avalon", was initially released as part of .NET Framework 3.0 in 2006. WPF uses DirectX and attempts to provide a consistent programming model for building applications. It separates the user interface from business logic, and resembles similar XML-oriented object models, such as those implemented in XUL and SVG.

Microsoft Build Engine, or MSBuild, is a set of free and open-source build tools for managed code under the Common Language Infrastructure as well as native C and C++ code. It was first released in 2003 and was a part of .NET Framework. MSBuild is included with Visual Studio, but can also be run independently through MSBuild's command-line interface.

Sandcastle is a documentation generator from Microsoft. It automatically produces MSDN-style code documentation out of reflection information of .NET assemblies and XML documentation comments found in the source code of these assemblies. It can also be used to produce user documentation from Microsoft Assistance Markup Language (MAML) with the same look and feel as reference documentation.

TypeScript is a free and open-source high-level programming language developed by Microsoft that adds static typing with optional type annotations to JavaScript. It is designed for the development of large applications and transpiles to JavaScript. Because TypeScript is a superset of JavaScript, all JavaScript programs are syntactically valid TypeScript, but they can fail to type-check for safety reasons.

Azure DevOps Server is a Microsoft product that provides version control, reporting, requirements management, project management, automated builds, testing and release management capabilities. It covers the entire application lifecycle and enables DevOps capabilities. Azure DevOps can be used as a back-end to numerous integrated development environments (IDEs) but is tailored for Microsoft Visual Studio and Eclipse on all platforms.

ASP.NET MVC is a web application framework developed by Microsoft that implements the model–view–controller (MVC) pattern. It is no longer in active development. It is open-source software, apart from the ASP.NET Web Forms component, which is proprietary.

<span class="mw-page-title-main">Visual Studio</span> Code editor and IDE

Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs including websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platforms such as Windows API, Windows Forms, Windows Presentation Foundation, Windows Store and Microsoft Silverlight. It can produce both native code and managed code.

<span class="mw-page-title-main">.NET Framework</span> Software platform developed by Microsoft

The .NET Framework is a proprietary software framework developed by Microsoft that runs primarily on Microsoft Windows. It was the predominant implementation of the Common Language Infrastructure (CLI) until being superseded by the cross-platform .NET project. It includes a large class library called Framework Class Library (FCL) and provides language interoperability across several programming languages. Programs written for .NET Framework execute in a software environment named the Common Language Runtime (CLR). The CLR is an application virtual machine that provides services such as security, memory management, and exception handling. As such, computer code written using .NET Framework is called "managed code". FCL and CLR together constitute the .NET Framework.

<span class="mw-page-title-main">XML Notepad</span> XML editor developed by Microsoft

XML Notepad is an open-source XML editor written by Chris Lovett and published by Microsoft. The editor features incremental search in both tree and text views, drag/drop support, IntelliSense, find/replace with regular expressions and XPath expressions, and support for XInclude. The editor has good performance on large XML documents and has real time XML schema validation. The editor also features an HTML viewer for displaying XSLT transformation results and a built-in XML comparison tool.

NuGet is a package manager, primarily used for packaging and distributing software written using the .NET framework. The Outercurve Foundation initially created it under the name NuPack. Since its introduction in 2010, NuGet has evolved into a larger ecosystem of tools and services, including a free and open-source client application, hosted package servers, and software deployment tools.

Razor is an ASP.NET programming syntax used to create dynamic web pages with the C# or VB.NET programming languages. Razor was in development in June 2010 and was released for Microsoft Visual Studio 2010 in January 2011. Razor is a simple-syntax view engine and was released as part of MVC 3 and the WebMatrix tool set.

<span class="mw-page-title-main">Mono (software)</span> Computer software project

Mono is a free and open-source .NET Framework-compatible software framework. Originally by Ximian, it was later acquired by Novell, and is now being led by Xamarin, a subsidiary of Microsoft and the .NET Foundation. Mono can be run on many software systems.

MonoGame is a free and open source C# framework used by game developers to make games for multiple platforms and other systems. It is also used to make Windows and Windows Phone games run on other systems. It supports iOS, Android, macOS, tvOS, Linux, PlayStation 4, PlayStation Vita, Xbox One and Nintendo Switch. It implements the Microsoft XNA 4 application programming interface (API). It has been used for several games, including Bastion and Fez.

<span class="mw-page-title-main">.NET</span> Free and open-source software platform developed by Microsoft

.NET is a free and open-source, managed computer software framework for Windows, Linux, and macOS operating systems. It is a cross-platform successor to .NET Framework. The project is mainly developed by Microsoft employees by way of the .NET Foundation, and released under an MIT License.

Microsoft, a technology company historically known for its opposition to the open source software paradigm, turned to embrace the approach in the 2010s. From the 1970s through 2000s under CEOs Bill Gates and Steve Ballmer, Microsoft viewed the community creation and sharing of communal code, later to be known as free and open source software, as a threat to its business, and both executives spoke negatively against it. In the 2010s, as the industry turned towards cloud, embedded, and mobile computing—technologies powered by open source advances—CEO Satya Nadella led Microsoft towards open source adoption although Microsoft's traditional Windows business continued to grow throughout this period generating revenues of 26.8 billion in the third quarter of 2018, while Microsoft's Azure cloud revenues nearly doubled.

References

  1. "Tags · mono/t4 · GitHub". GitHub T4 repository. Retrieved 2020-01-06.
  2. Web Templates (2013), Website templates, Website Templates South Africa, ISBN   978-1-4251-3374-0 , retrieved 19 November 2013
  3. "Fun with T4 templates and Dynamic Data - Angle Bracket Percent - Site Home - MSDN Blogs". Blogs.msdn.com. 2008-11-26. Retrieved 2012-05-17.
  4. "SubSonic v3's T4 Templates « Daily Cycle". Gcapnias.wordpress.com. 2009-01-12. Retrieved 2012-05-17.
  5. "Rider: The Cross-Platform .NET IDE from JetBrains".
  6. "What's new in T4 in Visual Studio 2010 - [Profoundly Esoteric Image] - Site Home - MSDN Blogs". Blogs.msdn.com. 2010-04-15. Retrieved 2012-05-17.
  7. "Code Generation and T4 Text Templates - Visual Studio (Windows)".
  8. "Mono.TextTemplating". GitHub . 22 October 2021.
  9. "ForTea". GitHub . 20 October 2021.