Archives / 2003 / April
  • Code Generation Network

    Many people have pointed out the existance of the Code Generation Network.  This looks like a very nice site and has a big list of code generation tools.  While browsing through it, I found a link to this interview of Dave Thomas.  I agree with a lot of what he has to say.  Until recently, CodeSmith has been a "smelly" code generation tool since it didn't have a lot of support for active generation, but with the recent addition of the VS.NET code generator it can now be used as an active generator.  I also have plans to add command line support and, thanks to a great suggestion by Duncan Godwin, I have also added a Nant build task to my TODO list.  As soon as I can get CodeSmith legally transfered to me, I will be able to start working on these ideas.  I truely believe that CodeSmith has the best template based code generation engine out of everything I have looked at and if I get to work adding more active generation support it will truely be a very powerful tool.


  • CodeSmith

    I have started to look at using codesmith for a project I am working on and so far I am very impressed with the tool. (Eric , the code smith himself, is looking for some legal aid if you are so qualified/inclined.) There are a couple of things that I am trying to figure out how to incorporate into the generation process, and as far as I can tell they are not there yet.

    • The first is the ability to do batch processing. I want to be able to point to a database and then create stored procedures for each table.
    • The second is the ability to save the generated script or code to a file after it is generated.

    I think I can accomplish both of these things in the actual template, but it would be much smoother to keep each template individual and have the tool do the batch processing and saving of the files. I know Eric has alot more to worry about right now then adding new features to the tool, but I figured I would throw these out there nonetheless. The last thing, which might just be my ignorance, is a way to edit the compiled template directly.

    Eric is also toying with making the project open source, this decision is of course completely up to him, but I would love to see him package it as a small software package and make a little money from it. I would be in line as one of the first to buy it.

    [James Avery]

    Thanks for the glowing review!

    Here are a some things that have been on my TODO list and should address your needs:

    1. Create CodeSmith Batch (.csb) format.  This will basically turn CodeSmith into a scripting engine with the powerful addition of being able to select properties to drive the script.  This combined with #2 and #3 will enable CodeSmith to be a very powerful batch processing engine.

    2. Add a designer for the DatabaseSchema object so this can be selected as a property for your template or batch file.

    3. Create a CodeTemplateProperty directive.  This will enable you to specify a template (.cst file) to be compiled and added to your batch or template as a property.  This will enable you to do something like:

    <%@ Batch Language="C#"
       Description="Generates one big SQL script of stored procedures for an entire database." %>
    <%@ Property Name="SourceDatabase" Type="SchemaExplorer.DatabaseSchema" %>
    <%@ CodeTemplateProperty Name="StoredProcedureTemplate" Src="StoredProcedures.cst" %>
    foreach (TableSchema table in SourceDatabase.Tables)
       StoredProcedureTemplate.SourceTable = table;

    4. Create a command line interface for CodeSmith.  I am not sure how I will implement this, but I really want to be able to use CodeSmith on the command line.

    Also, in the CodeSmith window there is a "Save Template Output" button.  This allows you to save the generated output to a file.  Also, you can set the default filename for the template by overriding the GetFileName method (see the CSharpTypedCollection.cst for an example of this).


  • CodeSmith and a MMC Snapin

    Eric J. Smith is looking for some help to make sure that the CodeSmith code generator remains legally available. I'd pony up the whole amount if I was still working for a fat dot-com. As it is, I'll be happy to chip in if someone gets a legal fund going here. Better still would be some pro-bono legal work, if anyone out there is qualified.

    [Larkware News]

    Eric, count me in. You might want to set up a PayPal donate button. CodeSmith is a great tool.

    [ScottW's ASP.NET WebLog]

    Thanks Scott!  I have a PayPal donate button on the CodeSmith page, but I will include one here as well.



    ** ATTENTION: CodeSmith is in need of some legal assistance.  I no longer work for RedRiver Systems, but they are willing to transfer ownership of CodeSmith and the SchemaExplorer API to me on the condition that they recieve an unconditional, non-revocable license to the software including free updates forever in the event that I decide to make CodeSmith a commercial product (I have no plans to do this, but they have to cover themselves).  This should remain in affect in the event that I decide to sell my rights to a 3rd party.  It should also state that they will be released from any and all liability associated with the use of CodeSmith once it is transferred to me or subsequently to anyone else.  I need for someone with a legal background to write a contract to this affect or for enough people to make donations (think it will cost about $200) so that I can afford to pay a lawyer to do this for me.  Once this is complete, I will be releasing a non-expiring build of CodeSmith with support for Visual Studio .NET 2003 final and I am also very strongly considering moving the project to SourceForge under an open-source license immediately after this transfer is complete.  If you can help, please email me at  Thanks!

     Donations are appreciated!


  • Olymars

    Lots of negative talk regarding OlyMars lately. I will admit that I don't have the time to figure out how to use it (gave it a try a few times, but just wasn't my style). However, it is still a very cool tool, it just has a crappy interface on top of it, but it isn't meant to be production code anyway now is it? My understanding is that it is just a research project...and when is the last time you saw a research project with warm fuzzy documentation and a sexy UI?

    [Jesse Ezell]

    It's not just the interface.  The templates have a very steep learning curve as well.  IMO, the ASP style syntax is absolutely perfect for template based code generation.  That's why CodeSmith has nearly identical syntax as ASP.NET.  Not only is it the perfect syntax, but everyone already knows it!  Anyone using Olymars, please give CodeSmith a try!


  • OlyMars == Confusion

    Let me put it this way. If the instructions for using a condom were as complicated as the ones for using OlyMars, AIDS would have killed us all by now. 

    [Robert McLaws]

    Totally agree here...I've tried to use the thing...I still don't get it. Somebody clue me in here.

    [David Stone]

    Haha... what a great line!  I have to agree 100%... I still can't believe that Microsoft allows their name to be put on that thing.