Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Any time you find yourself doing one of these repetitive tasks, you've found a candidate for code generation. Creating source code files (or Web pages, or SQL statements, or HTML pages, or any other text file) with minor variations is exactly the sort of thing that CodeSmith GeneratorĀ is designed for. For example, if you're writing C# code, you know that every C# project contains an AssemblyInfo.cs file with metadata about the project. Visual Studio automatically creates a skeleton AssemblyInfo.cs file for you when you create a new project, but it's full of comments designed for the novice developer, and attributes for every conceivable purpose. That's fine as a teaching tool, but it's not what most developers want to see in their source code. So typically, you'll start a new project by cutting out the junk, adding a few comments of your own, and making a standard set of changes to the attributes that remain. That's a perfect candidate for code generation: a process that you do over and over again with a few variations. Let's use CodeSmith GeneratorĀ to generate just the AssemblyInfo.cs file that you need, without all the fluff.

...