What Does a T4/Code Generation Harness Need to do?

I’m struggling to get the AppVenture Community Edition Code Generation harness into release because I can’t figure out where the boundaries should be. I initially thought I could just reuse my old stuff in the area of data extraction and mapping/morphing, but too much has changed.

What’s in:

  • Multi-UI supporting core code generation engine
  • Full composability via MEF
  • Configuration driven ordering of automatically discovered templates
  • Template focused generation (templates know stuff)
  • Multi-file output via a simple naming mechanism
  • Support for VB 9 XML literal templates
  • Support for T4 templates
  • A few example templates at Hello <item> level
  • Key service interfaces defined
  • T4 property extraction/value setting
  • Partial data extraction (tables and a few others)
  • Rudimentary US English pluralization service

What’s delayed:

  • Full data extraction (views, foreign keys, etc)
  • Mapping across data/object impedance mismatch boundary
  • Full project templates (stored procs and biz layer)
  • Hashing output files to protect handcrafted code
  • Services to load stored procedures
  • Services to create project files
  • XSLT template support
  • More services such as a better naming service

The core of this design is that I do not want to stand between you and your templates, metadata or services. Thus if you have metadata, you can hook this up and generate anything you can write T4 or VB9 XML literal templates for. You can create any services, metadata or templates you want.

Delaying stuff is hard. I want this to fully meet the capabilities of the GenDotNet harness so I can retire it. This is a vastly superior way to approach the problem.

So, where’s the boundary? For this tool to be worth a look, what does it need to do? This is V1, the rest will come. I’m trying to balance when to release V1 and I’m doing this all in my “spare” time so some patience will be needed.

Comments please!

5 thoughts on “What Does a T4/Code Generation Harness Need to do?”

  1. I would like to see a meta data service that can run against the code files.ie EnvDTE.CodeType arguments from within Visual Studio.

    I would also like to see support from micro code generation. Like smaller design time generation rather than a huge build time generate all or nothing process.

  2. Hi Kathleen,

    i finally got some minutes to discuss T4 Code Gen here. Just downloaded your T4-Host. Great stuff. Thats what people need. string in, string out. As with xsl 🙂

    What does Multi-UI mean?

    I see an issue with “Template focused generation”. Sure templates know stuff. But often you’ve got several input models that want to be rendered with the same template. Would the template discover the inputs?

    How does the multi-file-generation work? Calls within the templates?

    One place where code generation is used ALL THE TIME is, when generating web pages. I think the way they handle URLs and links (same as file- and classnames, right?) could give some nice hints.

    [Firefox crashed here, but recovered my text. puhh]

    Another issue i have been thinking of is using extension methods for generating code for specific metadata.


    With C#4 even myObject.GenerateMyTemplate() 🙂 This would let you organize your templates in a kind-of object-oriented way.

    Polimorphic Templates: Sorry. Just hacking down lots of ideas 😉 A template mytemplate.t4 for any object could be overriden by MyMetaDataTypeName.mytemplate.t4. myObject.Generate(“mytemplate.t4”) would still just figure it out.

    I gotta stop 🙂

    Is there a chance to get the bits prior to your release?

    I couldn’t find a GenDotNet CTP anyware. Is this the same as the T4Host on AppVenture? Ore am I just to confused?

  3. Hi Eric,

    theese two approaches are totally different. In one way, code-generation-nothing-or-all should be called compilation. That is what it is about.

    Micro code generation is about design-time tools.


  4. The problems with a bullet list…

    Multi-UI means really multi-front end. The work goes on in a class library that you can attach to a GUI,a command line runner (for builds), embed in something else, or if someone has the energy make a VS addon. I won’t look at that until we get a stable 2010 CTP.

    Template focused generation – talk to me about what you mean by multiple input models. This is a fully composable system, so the template only knows the interface for the metadata. You can create it anyway you want. But the template also produces (via code and accessing the interface or T4 directives) the output file name, the properties/parameters it needs, and the assmeblies it wants to reference. That’s what I mean by template focused,although it may not be a good term. Is that what you want?

    In myObject.Generate(… What type is MyObject?

    My bits are so unstable and dynamic that I’m not crazy about sending them, but you can ping me vi aemail if you really want them. I did a lot of stabilization today so am much closer.


Leave a Reply

Your email address will not be published. Required fields are marked *