Codesmith is a suite of tools now that allow you to generate code from templates that you write. The professional version includes an IDE for creating and debugging the templates.
I have used various incarnations of Codesmith for several years, and I like the tool. It has always left me somewhat unsatisfied though. For the many years when the tool was more Sharewary (c) and cheap, I would forgive its troubles.
However with its new (as of a year and a half ago) price $399 a head (discounts available for large orders), I don't think there are any excuses anymore.
Firstly the templates that come with the tool, should work, work well, and not require tweaking and modification. For years the standard reply has been that the templates are there just as examples to get your started. In my opinion they should either put more effort into the templates there are there, or remove them completely in lieu of more complete documentation.
For instance the TypedDataSet template, which has been with the product for years, does not understand how to handle a primary key that is using an identity field (auto increment). How come?
On a more fundamental level though Codesmith needs to evolve. I would love to see a more domain specific language and language features added.
String handling and manipulation should be vastly improved. For instance Camel Casing changes to a string should be built in.
This template fragment illustrates some of the issues:
SELECT
<% for (int i = 0; i < SourceTable.Columns.Count; i++) { %>
[<%= SourceTable.Columns[i].Name %>]<% if (i < SourceTable.Columns.Count - 1) { %>,<% } %>
<% } %>
FROM
[<%= GetClassName(SourceTable.Name) %>]
WHERE
<% for (int i = 0; i < SourceTable.PrimaryKey.MemberColumns.Count; i++) { %>
[<%= SourceTable.PrimaryKey.MemberColumns[i].Name %>] = @<%= SourceTable.PrimaryKey.MemberColumns[i].Name %><% if (i < SourceTable.PrimaryKey.MemberColumns.Count - 1) { %>,<% } %>
<% } %>
;
Since a lot of development in CodeSmith has to do with Sql development. Some form of a built in embedded Sql handeling would be nice, that has an implicit understanding of the required iterations.
One should be able to handle parameters as a group, and not have to have explicit iterations over each and every one.
I would suggest:
Select SourceTable.Parameters.All
From SourceTable
Where SourceTable.Parameters.PrimaryKey = @Parameter1
Conversion from language specific (C#) to other language specific type (Sql) should be handled transparently through a configuration.
CodeSmith has also decided to follow in Microsofts shoes and require activation of the software. As a roving consultant, who moves from client to client, and different projects at the same client, I can sometimes use my companies laptop, and sometimes the client provides me with a computer. I often develop inside a Virtual PC as well. In any case, I carry around with me a memory stick of great software, that increases my productivity and makes the client happier. I cannot make CodeSmith part of that toolset, because I cannot keep activating the software.
A cheaper alternative to Codesmith is MyGeneration (free), which does much of the same things that Codesmith does, and comes with its own IDE. It it less polished than CodeSmith. They have a tool that says it can convert from Codesmith templates to MyGenerations templates.