Eric J. Smith's Weblog

CodeSmith, .NET, etc...

August 2005 - Posts

CodeSmith Tips & Tricks: Template Recursion

Here is a simple CodeSmith template that shows how templates can be recursively called, have indentation levels and render to a single output:

<%@ CodeTemplate Language="C#" TargetLanguage="C#" ClassName="RecurseSampleTemplate"  %>
<%@ Property Name="InRecurse" Type="System.Boolean" %>
// Sample header
<% if (this.InRecurse) { %>
// Nested class
<% } else { %>
// Parent class
<%
    RecurseSampleTemplate recurseSample
= new RecurseSampleTemplate();
    recurseSample.InRecurse
= true;
    recurseSample.Response.IndentLevel
= this.Response.IndentLevel + 1;
    recurseSample.Render(
this.Response);
}
%>

Notice how on the CodeTemplate directive we are setting the class name for the template.  Then we can create another instance of the template in code, set some properties on the new instance and render it to the current response object.

Here is what the output of this template looks like:

// Sample header
//
Parent class
//
Sample header
//
Nested class
Posted: Aug 23 2005, 11:23 PM by ejsmith | with 1 comment(s)
Filed under:
CodeSmith 3.1 Released

I'm happy to announce the release of version 3.1 of CodeSmith, a free upgrade for all users of CodeSmith 3.0. Version 3.1 adds additional capabilities to the highly successful version 3.0 release, including:

  • Custom designer support for ColumnSchema and ColumnSchemaCollection.
  • A new OnError virtual method for the CodeTemplate class.
  • A new ParseDefaultValue method for IPropertySerializer (used by the ParseDefaultValue method of CodeTemplate).
  • The sample custom properties project now demonstrates property serialization.
  • Default values are parsed for all types that support conversion from string.
  • Numerous other minor bug fixes and user interface enhancements.

Refer to the included history.txt file for a detailed list of all changes and bug fixes since the original 3.0.0 release.

In addition to code and interface improvements, I'm excited to announce the addition of the CodeSmith User's Guide, written by well-known .NET author Mike Gunderloy. The new User's Guide includes tutorials, complete documentation of the CodeSmith template syntax, information on the CodeSmith Explorer and CodeSmith Studio clients, advice on integrating CodeSmith into your own processes, and strategies for merging code and using CodeSmith for active code generation. The User's Guide complements the existing API Reference to give CodeSmith a comprehensive help system for users of all skill levels.  Mike did an amazing job and if anyone has any technical writing work, I would highly recommend considering Mike for the job.

CodeSmith 3.1 is a completely free upgrade for registered users of version 3.0. Just download and install the latest version from the http://www.codesmithtools.com Web site; your existing license information will be preserved. If you're not a registered user, the 30-day free trial offer continues to apply to CodeSmith 3.1.

Posted: Aug 11 2005, 08:49 AM by ejsmith | with 4 comment(s)
Filed under:
Announcing a New Larkware Contest

It's time for a new contest, and I'm one of the judges.

"As you undoubtedly know by now, the release of Microsoft Visual Studio 2005 and Microsoft SQL Server 2005 is scheduled for the week of November 7. That's just three months from now, and the current beta versions are plenty solid enough to build some useful and interesting software. And you all know that I'm a sucker for useful and interesting software. So, here's your chance to build some for me, using the next generation of Microsoft tools! Even better, it's a chance for you to win a batch of nifty prizes in return. So put on your thinking caps, break out the beta software, and get to work. I know there are a lot of talented developers among the Larkware readership, and I expect great things from your collective efforts."

"All told, the contest features over $15,000 worth of prizes. I expect that should be enough to motivate some superb contest entries - so what are you waiting for? Get coding!"

I'd get going if I were you...

Posted: Aug 09 2005, 02:51 PM by ejsmith | with 1 comment(s)
Filed under: ,
XML-based Code Generation with CodeSmith

Mike Gunderloy has just posted a new article about XML-based Code Generation with CodeSmith over at Developer.com.  Mike does a great job of explaining the new XmlProperty feature in CodeSmith and how powerful it can be in using XML as metadata for your templates.

Posted: Aug 08 2005, 09:32 AM by ejsmith | with 1 comment(s)
Filed under:
CodeSmith 3.0 Tips and Tricks

The presentation at the North Dallas .NET User's Group last night went awesome!  The room was packed (over 265 people) and Rob Howard did an amazing job presenting CodeSmith 3.0 and getting people excited about it like I could never do.    Rob is such a great speaker and it was very surreal seeing him doing a presentation on an application that I wrote.  We recorded the presentation and we will hopefully have it available for everyone to see online in the near future.  In the meantime, here is a link to the slides from the presentation.

We also gave away a free CodeSmith Professional 3.0 license to every single person that attended which ended up being over $105,000 worth of licenses.

If you attended last nights meeting, we'd love to hear any feedback that you may have so that we can make the presentation even better.

Over the next couple of months Rob will be visiting some other User's Groups and giving licenses away to everyone at those as well.  Here is a list of currently scheduled meetings:

Posted: Aug 04 2005, 02:36 PM by ejsmith | with 6 comment(s)
Filed under:
More Posts