July 2009 - Posts
To get the latest build of T4MVC: Go to download page on CodePlex This post is a continuation of various previous posts on the T4MVC template for ASP.NET MVC: A new and improved ASP.NET MVC T4 template The MVC T4 template is now up on CodePlex T4MVC 2.2 update: Routing, Forms, DI container, fixes I last blogged about version 2.2, and there have been a number of changes since that (you can get the full history at the top of the T4MVC.tt file). This post describes some of those changes. T4MVC now uses a separate settings file Previously, if you wanted to customize T4MVC, you’d have to change T4MVC.tt directly. This is fine until you want to grab the next build, and have to hand merge the changes. Instead, it is now using a separate...
A while back, I blogged about how ASP.NET Dynamic Data apps can uses an Associated Metadata class (aka a ‘buddy’ class) to add metadata attributed to properties defined in a generated class. It’s a mostly ugly thing that was made necessary by limitations of the C# and VB.NET languages: they don’t let you add attributes to properties defined in another partial class. What I didn’t mention there is that this ‘buddy’ class mechanism is actually not specific to Dynamic Data apps, and can in fact be used anywhere. Since I’ve recently heard of several cases of users trying to do something similar, I’ll describe how it’s done. If you’re familiar with TypeDescriptionProviders (which have been around since ancient times), this will look very trivial...
T4 templates have proven to be useful is a whole range of scenarios, and more and more developers are finding interesting things to do with them. For the most part, all those scenarios fall under two very distinct categories: “support code” versus one-time generation. Unlike my previous post on CodeDom vs. T4 , here we’re not talking about making a choice between two competing technologies, but simply about using T4 in the way that makes sense for a given scenario. Let’s start with a brief description of the two usage patterns: Support code : here, a T4 template generates a file that you rarely need to look at, and you should never modify. Instead, it contains “support code” that you can code against. A great example of this...
Last month , I wrote a number of posts on using T4 templates to get strong typing in ASP.NET MVC applications. The result is the T4MVC template available on CodePlex . This template has been pretty popular with many MVC users, and I received a huge amount of feedback on improving it. Most of it has been integrated into the CodePlex version (see the extensive History section in the TT file!). While T4MVC is only useful to MVC applications, someone suggested that ASP.NET WebForms applications could also benefit from some strong typing, so I put together a little T4 template that does some of that. Unlike T4MVC which tries to cover a whole range of MVC scenarios (relating to Controllers, Actions and Views), this template just does one thing: it...
More Posts