T4 vs CodeDom vs Oslo [closed]

点点圈 提交于 2019-12-04 11:04:35

Go with T4 - easy decision.

  • Oslo is too new and the tools are too raw to be anything than an eval-only technology
  • CodeDOM is powerfull, if you need to generate CLR classes at run-time, and are willing to sacrifice easy modification to your generated output.
  • T4 (with the T4 toolkit) is a easy to use general purpose code generation tool. Only difficulty I've had so far is in build-time integrations.

Generally speaking I see code generation as part of a complete modeling/coding story. It should be accompanied by a generic framework in which most of the plumbing is done. In my opinion it is not useful to generate huge classes whereas a decent framework with well-defined extension points or hooks will be much better to maintain and to extend.

You will need to define some formalized language for the user stories, be it XML or an Oslo domain language. Oslo would require your domain experts to learn the Oslo tooling. You could use Word + XML. Then you define a good-looking template in Word, with an embedded XML schema and after the story is written you can get it from Word in formalized XML syntax.This XML can of course be used to drive generators, via XSLT or Linq.

CodeDOM is powerful, but rather cumbersome. It is IMHO not an easy to use solution and it does not have real template support.

I have no experience with T4, but its templating features are a pre.

The Oslo product is indeed quite new, requires .Net 4.0, a runtime environment. It is still only a CTP. It is a very powerful environment, although I have some doubts about the database generation story.

Hope this helps.

Well, Oslo does not fit the list. It has no code generation story so far. So stick with T4.

Oslo has not the intention to generate code for you. You will have to create a runtime (C# program for example) that changes it behavior depending on the data. You can see it like an internet browser.

I don't believe that Oslo requires a .Net 4.0, like Rine mentions. For my internship at Avanade Netherland I’m creating Oslo MSchema and MGrammars and a C#3.5 runtime. Depending on the given data it will creating (not generating) WCF services and run those.

There are some interesting application of Oslo

  • the "new LDAP" System.Identity, more in PDC session video http://microsoftpdc.com/Sessions/SVC28
  • System.Modelling (I think) Microsoft.UML2 where you can push informations about methods, classes, modules etc. in the Repository, analyze it and create reports. For example create report with methods added/removed between 2 buils http://microsoftpdc.com/Sessions/SVR19
  • and of course modelling
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!