Immutable.tt

Rating: No reviews yet
Downloads: 121
Released: Sep 4, 2009
Updated: Sep 4, 2009 by klinkby
Dev status: Beta Help Icon

Recommended Download

Source Code Immutable.tt
source code, 7K, uploaded Sep 4, 2009 - 121 downloads

Release Notes

The best kept Visual Studio 2008 secret is the built in code generator that lets you define
a DSL to write code, xml or whatever for you to be included at compile time. This is
an example that generates complete immutable types from a single line of code (!) .
Add this file to any Visual Studio C# project.

Put the following in a project item file called Size.tt to create
an immutable struct with the float properties Width and Height.
(convert the lt/gt)

<#@ include file="Immutable.tt" #>
<#= Immutable.Struct(Host, "float Width;float Height") #>

Put the following in a project item file called Quote_T.tt to create
an immutable generic class named Quote with the properties Symbol and Rate.

<#@ include file="Immutable.tt" #>
<#= Immutable.Class(Host, "string symbol;T rate") #>

As you save the files, you will see that a .cs file is created below the .tt file,
and the classes have been generated in the project's default namespace. The classes are
partial so you can easily extend them with attributes, base classes or additional methods
in other class files.

Reviews for this release

No reviews yet for this release.