Generating Code

When you've finished setting properties for the template, you're ready to generate code. To do this, click the Generate button at the bottom of the template's property sheet. CodeSmith will take the property values that you entered and combine them with the template to create the code, and display it in an expanded window. The code will be selected so that you can copy it to the clipboard with a single click of Ctrl+C.

In this case, the code window contains 320 lines of generated code for the hash table class, implementing the IDictionary, ICollection, IEnumerable, and ICloneable interfaces. There's nothing there that you couldn't write yourself if you're a reasonably experienced C# developer - but why bother? This is the sort of routine work that CodeSmith is ideally suited for. With CodeSmith, you can devote your time and energy to identifying patterns in your code, turning them into templates, and then reuse them with maximum flexibility in the future.

Next: Inspecting the Template

Advanced: Using a CodeSmith Project to Execute CodeSmith Templates from Anywhere