Despite being quite well hidden, Visual Studio’s T4 templating engine is a great feature.
However, whilst putting together a T4 template in Visual Studio 2008, throwing in a simple lambda expression such as:
Can cause the code generation to fail. As it turns out, the T4 template language is set to C# 2.0 by default.
This can easily be fixed by changing the template directive at the head of the template file to C#v3.5:
Ideally this would be the default in a C# 3.5 project, but I’m sure there’s a reason for this…