Code Generation in .NET 2.0
[Andy Santo]
I think that template-based code generation and generics are VERY similar. Personally, I can't wait for generics so that I can use them in my CodeSmith templates. Right now I have to have templates that create a separate typed collection class for each entity class that I generate. Generics are going to be awesome for classes that only vary by type, but what happens when I want to go beyond that? CodeSmith templates are based on things like database schema information (soon they will be based on an O/R mapping XML file), strings, boolean flags, and whatever else I can think of. Unlike generics, my templates can also have complex logic in them.
Speaking of generics, the thing I am looking forward to most in .NET 2.0 is partial classes. I believe partial classes are going to be a godsend to code generation. Currently I have to make sure that my entity classes have enough hooks in them so that I can derive from them and add any custom logic that might be needed, with partial classes I will simply be able to generate half of the class, write the other half by hand and not worry about my custom code being overwritten. Is it time for PDC yet?