It just so happens I was looking at this very thing last week. I'm currently still relying on the old free MyGeneration for code generation. Nothing like being able to make List and CRUD screens, business objects, and data-access components within a few minutes from a database table and a bit of additional metadata. It's most useful for data-driven apps I find.
I did give CodeSmith a look over (being so similar to MyGeneration), but decided that I can probably do everything I need with T4. Like you Greg, I was going to use XML files to hold the metadata; except I was going to hack together a quick tool that allows me to navigate to a table in the database, set metadata on fields, and dump out the xml file for me. Nathan On 16 October 2013 11:29, Thomas Koster <[email protected]> wrote: > Hi group, > > On Saturday, 12 October 2013, Greg Keogh wrote: > >> ...so I decided to use T4 templates to generate it all. I'm really happy >> with the results and this post is basically just a reminder that in my >> opinion, good old fashioned code generation still has a place in the modern >> world. >> > > I agree that code generation still has its place and would even go as far > as saying it is *necessary* for most "real world" projects. I do have > some criticisms of T4 though. > > My biggest issue with T4 is that prima facie it is not properly > integrated, or integrable, into msbuild. A human often has to "Run custom > tool" or "Transform all templates" manually in the IDE. If you are also > mucking around with multiple revisions, e.g. using your VCS to bisect or > even just to update, stale output can easily get out of hand that may > result in subtly broken builds. > > From past Googlings I have only managed to turn up hack solutions, mostly > three kinds: > > 1. Hand-write msbuild targets into your csproj that shell out to the > TextTransform.exe tool in the SDK. This is not the same thing as the VS > custom tool, resulting generated output that is different from the VS > TextTemplatingFileGenerator custom tool, if it even works at all. It is too > easy to write a T4 template that is incompatible with one or other host. > 2. Install the Visual Studio Visualization and Modeling SDK to make > use of its msbuild targets (VS2010 and up only). This is yet another T4 > host that is different from both the VS custom tool and TextTransform.exe. > And why burden your developers with such a huge compile-time dependency for > what should be a trivial msbuild configuration? What about build servers > that do not even have VS installed? > 3. Commit generated output to your VCS. I put this hack in the same > basket as committing binaries. > > I am very interested in what T4 aficionados do to really make it work in > large projects. What do you do when you build a fresh checkout of a project > with many T4 templates? What about automated builds or continuous > integration servers? > > p.s. I experience a homomorphic problem with most other code generation > tasks in VS, especially DataSets generated from xsd files. > > -- > Thomas > > >
