The Hackers Manifesto

What Gives? Microsofts Code Generation Tool

17. November 2008 19:48 by Scott in   //  Tags: , , , , ,   //   Comments (10)

In a world of Microsoft and third party applications, out comes t4.  t4 is a code generation tool that can compete with CodeSmith, but its FREE and built right into Visual Studio. It has been years since the first edition with very little publication of the actual application. t4 is a free code generation engine from Microsoft that underpins the Domain Specific Languages and Software Factory toolkits.  t4 is a rich code generation and has the ability to stand up against and compete with CodeSmith.  I have used both Codesmith and MyGeneration a lot in the past few years, so I have seen the competition.  What is nice about this old/non publicized tool is that it is built directly into Visual Studio 2008.

t4 is being spear headed into the open source market for free templates by Oleg Sych.  It brings a long a toolbox which can also be download with extra templates along with a GREAT T4 Editor which of course is also free.  There is not more need to spend money on CodeSmith, when Microsoft will do it right out of the box with Visual Studio.

Some have speculated, why hasn't Microsoft published this tool to a greater extent.  We can only think that it has to do with being a Gold Partner.  Microsoft doesn't like to lose Gold Partners and therefore hasn't truly publicized this tool.  The next question you have to ask your self is what can be generated?

  • Site Maps.
  • Database schemas.
  • Session Variables. 
  • Store Procedures.
  • Text Documents.

As of October 2008, t4 Editor has been officially placed as a plug in to Visual Studio 2010, which will boost the ability to generate t4 code through other means besides CodeSmith.

Demos and Other information can be found below.

Point of concern: If your company currently uses CodeSmith, wouldn't it be nice to tell your boss what you found could save the company a few hundred dollars by using something that is already built into Visual Studio? So why not give it a try and save a little money doing it?

kick it on DotNetKicks.com

If you liked this post, please be sure to subscribe to my RSS Feed.

Comments (10) -

Vijay Santhanam
Vijay Santhanam
11/19/2008 2:18:20 AM #

Nice. never heard of t4 before. Looks better than codesmith for real real.

Will t4 move into the framework itself?

Scott
Scott
11/19/2008 6:46:18 AM #

t4 will not be a part of the framework, but a plug-in to Visual Studio it self.  The ability to generate t4 code is not part of .Net.

Alexey Romanov
Alexey Romanov
11/19/2008 9:05:36 AM #

Actually, t4 is already available in Visual Studio 2008, no need for any plug-ins. T4 Editor, which you linked to, is a plug-in which gives you syntax highlighting, autocompletion, etc. when editing the files, but to generate code you just:
1) Add a .tt file to the project;
2) Right-click on it;
3) Choose "Run Custom Tool".

Mike Griffin
Mike Griffin
11/19/2008 10:38:31 AM #

Mike Griffin of MyGeneration and EntitySpaces here. Our EntitySpaces 2009 alpha comes out this weekend, full blown code generation right inside of Visual Studio, it's pretty cool. Here's some info on it ...

www.entityspaces.net/.../...009+Video+Preview.aspx

Part 1
www.entityspaces.net/.../...der+Visual+Studio.aspx

Part 2
www.entityspaces.net/.../...ual+Studio+Part+2.aspx

Mike Griffin
Mike Griffin
11/19/2008 11:35:19 AM #

I wonder if Microsoft is working some kind of deal with CodeSmith? CodeSmith was always the "blessed" code generation while MyGeneration was the Rodney Dangerfield of code generators, no respect, no contests won, no nothing, I'm not bitter, I swear ;) lol

Anyway, I'm suprised I haven't seen any kind of really cool roadmap come out of CodeSmith, a VS shell full blown app, something? Maybe the silence means some kind of deal between CodeSmith and Microsoft, but then there is some kind of relationship between Telligent and CodeSmith so who knows. Anyway, posts like yours can't make CodeSmith happy. I would like to say Eric Smith of CodeSmith has been very good to us at EntitySpaces, carrying out blog posts about EntitySpaces supporting CodeSmith and such, so he's a good guy.

There's plenty of room folks, just like the ADO EF wont kill EntitySpaces T4 is not the end all of code generators ....

Bill Booth
Bill Booth
11/19/2008 7:40:59 PM #

It would be nice to mention that not all versions of the Editor are free.

Bill Booth
Bill Booth
11/19/2008 7:43:00 PM #

It would be nice to mention that not all versions of the Editor are free.

cowgaR
cowgaR
11/20/2008 2:49:05 AM #

btw, subsonic 3.0 uses T4 extensivelly as well, and it is turning up to be one really nice data acees/code generator tool, although not as much of an OR/M like Entity Spaces right now... but things can change Wink

ES is a _very_ nice framework though (from what I see), looking forward to 2009 version...
For now I like things as easy and as simple as possible (not to say ES is complicated), and subsonic is aiming exactly that way. If (for me) it would not be sufficient, I would probably switch to ES if (at that time) Mike won't drive ES towards NHibernate/LLBLGen way - e.g. rich frameworks that even can make caffee for you and do some ironing as well.

back to the point, T4 should become more popular and see big improvements in VS2010 so we don't need to pay (again) for external editors like clarius's one...

robert
robert
11/24/2008 8:56:44 AM #

As someone who has used both extensively, I would say t4 is still a long way away from CodeSmith in terms of sheer ability.  CodeSmith Projects can generate n number of other projects and n number of files and automagically include it in your project file.  T4 is good for the one off code gen file, as you mentioned recipes and things like that.  No question when it's free sometimes that's enough.  But anyone actually writing a DSL and has tried both will immediately know which is easier to use and get out the door with.

Other things like the SchemaExplorer meta data api, and ActiveSnippets which are like VS snippets on steroids which can accept parameters like database tables and xml files and run a template inline your code.  I think the problem with CodeSmith is that the folks just don't know how to use these advanced features.

sidney
sidney
11/13/2011 9:10:38 PM #

Great article, exactly what I was looking for.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading