CodeSmith Rocks!

I've been working on building a really great web application using ASP.NET 2.0 over the past three months, and I needed a really great tool to make building the site easier. I tested a bunch of other tools (though I won't name them cause I'll get flamed), and I just wasn't satisfied. Not wanting to have to write any more code than I had to, I wanted to be able to design a platform that would allow me to easily change things as the requirements got more complex.

Enter CodeSmith. I'd heard a bunch of people rave about it, but I never really gave it a shot before. So I installed it, and as I started my trial, there was XHEO's Licensing component to taunt me. You see, I love XHEO's unreleased OR system. But unreleased = unsupported, and Paul's gung-ho on his anti-ILDASM technology, so I'm not holding my breath.

Anyways, I got it going, and was impressed. The IDE feels a little childish to me, and I was rather pissed that it didn't support VS2005 or .NET 2.0 language options, but oh well. The learning curve on the API was a tad steep too, but I picked it up pretty quickly. Soon, I had generated all of my SPROCS with ease.

But then my head started spinning when I thought of all the data access code I'd have to write. So I tried out some of the built-in templates, but I didn't like their access architecture. I'm a huge fan of the Provider Model, and I don't like data access code in the same class as the object properties. Yeah, it's nice to be able to call Object.Save(), but's it's just as nice to call ObjectManager.Save(object).

So I built myself a template to generate an ObjectManager. Then I wrote a template to generate all the Object Managers. Then I wrote a template to generate an object. Then I wrote a template to generate all the objects. Then I wrote a template to generate all the SPROCS, managers, and objects. And when I was done, I generated over 10,000 lines of code in just a few seconds. Not bad for a hard week's work.

In short, CodeSmith helped me do in a week what would have taken a team of 3 developers a month to accomplish. And I know that every single line of code is written to MY standards... something which is usually extremely tedious. I can't believe I waited this long to try it, and now I don't think I'll ever be able to code without it.

Maybe now I'll have time for all those little side projects... ;)


  • You might want to have a look at

    It's almost the same thing ... only it works better for me :)

    You might want to have a look at what works best for you...

  • Edit the .config files to use the following:



    <requiredRuntime version="v2.0.50727" />



    Make sure and remove all the "supportedRuntime" elements. Now you can use generics and anonymous methods in your CodeSmith templates. For example:

    Action<int> writeValue = delegate(int inputValue)

    { %>

    Your value is: <%= inputValue.ToString() %>

    <% };





  • Oh, I forgot to mention, CodeSmith 2.6 (the last freeware version) also works with .NET 2.0. Just edit the .config file to target .NET 2.0. Using anonymous methods in 2.6 allows you to create "sub-templates" inline. Either create your own delegate type or use Action<T> and you can pass the anonymous method input values, and it has access to the templates input properties.


  • Did you look at It's adapter model sounds like the provider model you described. All generated for you.

  • Heh. 2002 called and wants it's headlines back.

  • Well, I removed those elements from the config file, but the IDE still doesn't properly highlight the syntax for new .NET methods. I can't blame them, because there are 30% more methods in 2.0, but it's still kinda annoying.

    Mischa & Jeff- I said I wasn't going to mention names... I didn't like either one.

  • Just a question. What is the advantages of CodeSmith 3 over MyGeneration? I installed it a while ago but the trial period expired before I had time to try it out...

Comments have been disabled for this content.