Code Generation in Microsoft.NET

by Kathleen Dollard

This is the book that inspired the writing of this tool.

The price of the book is worth it for the xslt tutorial chapters alone!

The book describes a set of principles and techniques that can be used to develop code using code generation techniques.
The book intended to provide the reader with the knowledge required to create their own code generation utility.
However as the book provided a sample suite of generation tools to act as examples most discussions of the book treats it as an introduction to the supplied generation tools.
I have taken the other approach and have created my own tool based upon the presented techniques.

Here are the principles:
  1. You have control of the templates that generate your code and can change them as required.
  2. Collect metadata as a separate, distinct step with usable output that can independently evolve.
  3. You or someone unfamiliar with the project can regenerate your code precisely as a one click process - now or at any point in the future.
  4. You embrace handcrafted code by isolation and protecting it. Code generation is a supporting player to human programming and doesn't overwrite files unless they were generated and haven't been edited.
  5. The code generated application is a high quality application. It allows more effective testing, has equal or better performance and is more easily maintained than a similar fully handcrafted application.

Currently Perfect Storm's CodeGen fails to acheive protection of handcrafted code - but I intend to add this as a feature soon.

Protection of handcrafted code can be implemented as a transform filter.

Last edited Aug 20, 2008 at 9:00 PM by chriseyre2000, version 2


No comments yet.