Archive June 2008
All of the articles archived for the month that you have specified are displayed below.
DeepZoom
- By: ben|UNDER|hoffman
- On: 06/30/2008 15:05:10
- In: Software Development
- Comments: 0
T4 Templates - Code Generation in Visual Studio
- By: ben|UNDER|hoffman
- On: 06/18/2008 12:17:31
- In: Software Development
- Comments: 0
Recently I was listening to the .NET Rocks podcast on my afternoon commute and they were discussing a topic that is somewhat familiar to me, albeit in a different domain, code generation. This time the domain was .NET development, namely code generation within Visual Studio. They were taling about T4 templates, now included in Visual Studio 2008, and I believe they mentioned the editor from Clarius Consulting. It seemed pretty interesting at the time (in comparison to the commute traffic?). While googling the topic later at home, I stumbled upon an article by Hilton Giesenow at his blog where he mentioned that he put together a screencast demonstrating the topic. I really like the screencast medium, and am always interested in checking out one on an interesting topic so I pulled it down and watched it. Pretty neat stuff. Anyway, I filed it away as 'might-be-useful-someday', and got on with my life.
Well, recently I had occasion for about 100+ dependency properties on a class. (I don't want emails saying 'Oh, why would you ever need that, derive from THIS instead' or 'Just use a collection' or something, thats not the point here.) So, dependency properties are exceptionally tedious to add to your class, often times requiring 30ish line of code each - most of it boilerplate. Now, once you have them it gives you tremendous power, but its a bear getting there. Anyway, since there would be, and generally is, tons of boilerplate code here, I figured it would be a good opportunity to test out the code generation stuff thats built in to VS2008. The amazing thing is that you can write C# that writes your C# (wish there was C# intellisense in the template editor). This is very cool and gets you thinking at a different level about your code. Anyway, very cool stuff - you never know what you will find in your travels and when it might come in handy. Learn on!