Tom Hollander started an interesteding thread on code generation. He points out challenge of customizing generated code, which comes up often because generated code is usually not exactly what you want. He also brings to light the trade-off between generator flexibility and complexity: the more flexible a code gen template is, the more complex and difficult to configure it becomes. Check out his post at:
http://blogs.msdn.com/tomholl/archive/2007/11/17/code-generators-can-t-live-with-them-can-t-live-without-them.aspx
The post includes some great comments too. Wojtek Kozaczynski posted some additional thoughts on the topic at:
http://blogs.msdn.com/wojtek/archive/2007/11/18/code-generators-when-can-you-live-with-them.aspx