Choice of templating engine

The code generator is currently using the T4 templates from Microsoft as its templating engine.

The question is if we keep this templating engine for the re-write of the code generator, or we use a different templating engine.

If we keep T4, and as part of the move to .NET Core, we can then:

  • use the mono version of the T4 template engine (see if exists in .NET Core)
  • or write our own parser of T4 + code generator (not that hard of a task, since T4 is pretty straightforward)

If we want to change, we have to choose a new templating engine, and : migrate / rewrite all the templates that are written in T4 !

We can also make sure the templating engine is switchable, which would be the nicest design and allow any user of the code generator to chose their prefered templating engine. This seems the ideal thing to do, if we can do it on our short timeframe.

As templating engine are concerned, the open that comes to mind is StringTemplate. However I am not convinced about the performance, as I read several complaint about it. Performance is an issue for us, as the generation of a full Generative Objects application is involved hundreds of templates.

We should try the following 2, if we want to retain T4.

If stringtemplate has performance issues, then we need to test performance for similar workloads on the above ones as well.

This thread lists options -

But given existing investment in T4, I’d suggest we need a good reason to move to another templating engine, at least in the short term. My vote is to stick with T4 for now and pick the best of the two T4 for .Net Core options that Velu listed.

What’s the selection criteria: first one to work? performance? most recently maintained?

1 Like

Yes, short term is to use T4.

I am planning in the next weeks to try the various options. I have also seen written somewhere that T4 is already part of .NET Core ?

Yes, I read that somewhere as well, but the bulk of the search result evidence suggests otherwise.

I imagine you want pure .net core, but this might provide an interim:

This suggest that T5 might be the go:
and there is a comment in that article that talks about dotnet CLI t4, which lead me here:

1 Like

Thank you @garth, I will check all this !

Ok I am back on replacing the code generator !

I am confused, it seems to me that T4 are properly working by default on .NET Core… Here a quick demo project I did to test it :

So I will continue this way and see where it brings me