NHibernate Forge
The official new home for the NHibernate for .NET community

hbm2net

I did an attempt of resuming the project hbm2net, creating a Text Template Transformation Toolkit (T4)  renderer, hosting the T4 engine. T4 templates allow to easily mix templates with additional code.The current version is not production code, but a proof-of-concept. If anyone interested a download is provided, containing the source and a single unit test to show the idea. A ready to use binary version could be found here (post is in italian, but is easy to grasp how to try it),as I said, it is not tested for production. Please let me know if the idea is useful / interesting.


Posted oct 19 2009, 08:43 a.m. by felicepollano
Filed under:

Comments

Fabio Maulo wrote re: hbm2net
on 10-19-2009 12:55

a step-by-step post about how create classes from hbm would be useful

felicepollano wrote re: hbm2net
on 10-19-2009 13:12

Well, with the binary version:

Unzip in a folder, an example hbm file is present in the zip, as well as a config file to use the t4generator.

Then simple use hbm2net --config=t4config.xml *.hbm.xml. You should see the output under the folder "generated" in the current directory. May be more interesting will be have a look at the sources: I provided a modified version of the original unit test: by launching the test called T4DefaultTemplate you should se how the job is done. The templates currently used are embedded as resources file in the genertaor assembly.

Hope this help.

uberVU - social comments wrote Social comments and analytics for this post
on 10-19-2009 14:07

This post was mentioned on Twitter by nhibernate: Blogged: hbm2net : I did an attempt of resuming the project hbm2net, creating a Text Template Transforma.. http://bit.ly/1Ov9ZR

DimkaG wrote re: hbm2net
on 10-20-2009 6:28

The idea is very interesting and it is most anticipated. In the past we tried to create such a prototype but encountered serious problems with hosting T4 templates outside the DTE host. Today we are using NVelocity templates for class generation in a couple of projects. The downside is that generated classes are not automatically added to the solution and NVelocity templates are less intuitive for .Net programmers. Having a T4 alternative would boost programmers productivity and make the code generation process more friendly.

felicepollano wrote re: hbm2net
on 10-20-2009 7:02

I found some problem too in passing "variables" to t4 templates, basically the problem was on serializing the ClassMapping stuff, because hosting t4 needs a separate app-domain. So i cut-off the problem in a tricky way: just reused the same app domain, this has as a side effect a memory leakage, and I accepted it since this is a tool to launch one-shot. There is some other advantage in using t4 instead of NVelocity: you can easily embed some code to do some generation logic in the template itself.

Powered by Community Server (Commercial Edition), by Telligent Systems