T4 vs CodeDom vs 奥斯陆

发布于 2024-07-12 13:05:47 字数 911 浏览 5 评论 0原文

在我正在处理的应用程序脚手架项目中,我试图决定是否使用 奥斯陆T4CodeDom 用于生成代码。 我们的目标是将依赖关系保持在最低限度,并根据用户故事驱动领域驱动设计的代码生成。 第一步是根据用户故事创建测试,但我们希望领域专家能够在各种不同的媒体(例如自定义应用程序、Word 等)中编写他们的故事,并且仍然根据用户故事生成测试。故事。

目前我所知道的:

  1. CodeDom 需要.NET,但只能输出.NET 类文件(例如.cs、.vb)。 难度相当高。
  2. T4 需要 CodeDom 和 VS Standard+。 难度级别相当合理,尤其是使用 T4 Toolbox 时。
  3. 奥斯陆很新。 我不知道依赖关系,但我想您必须至少使用 .NET 3.5。 我也不确定代码生成能力或添加新语法的复杂性。 然而,领域专家可能可以很容易地在 Intellipad 中编写用户故事。 也不确定将 Word 中的故事转换为 MGrammar 是否容易。

您对上述工具的想法、经验等是什么? 我们希望坚持使用微软或开源工具。

In an application scaffolding project on which I'm working, I'm trying to decide whether to use Oslo, T4 or CodeDom for generating code. Our goals are to keep dependencies to a minimum and drive code generation for a domain driven design from user stories. The first step will be to create the tests from the user stories, but we want the domain experts to be able to write their stories in a variety of different media (e.g. custom app, Word, etc.) and still generate the tests from the stories.

What I know so far:

  1. CodeDom requires .NET but can only output .NET class files (e.g. .cs, .vb). Level of difficulty is fairly high.
  2. T4 requires CodeDom and VS Standard+. Level of difficulty is fairly reasonable, especially with the T4 Toolbox.
  3. Oslo is very new. I have no idea of the dependencies, but I imagine you must be on at least .NET 3.5. I'm also not certain as to the code generation abilities or the complexity for adding new grammars. However, domain experts could probably write user stories in Intellipad quite easily. Also not sure about ease of converting stories in Word to an MGrammar.

What are your thoughts, experiences, etc. with any of the above tools. We want to stick with Microsoft or open source tools.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

浅浅 2024-07-19 13:05:47

选择 T4 - 轻松决定。

  • 比仅评估技术
  • Oslo 太新了,工具也太原始,如果您需要在运行时生成 CLR 类,并且愿意牺牲对生成输出的轻松修改,那么 CodeDOM 的功能就
  • 强大。 T4(带有 T4 工具包)是一种易于使用的通用代码生成工具。 到目前为止,我遇到的唯一困难是构建时集成。

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.
猫弦 2024-07-19 13:05:47

一般来说,我将代码生成视为完整建模/编码故事的一部分。 它应该伴随着一个通用框架,其中大部分的管道工作都已完成。 在我看来,生成巨大的类是没有用的,而具有明确定义的扩展点或挂钩的体面框架将更好地维护和扩展。

您需要为用户故事定义某种形式化语言,可以是 XML,也可以是 Oslo 域语言。 奥斯陆需要您的领域专家学习奥斯陆工具。 您可以使用 Word + XML。 然后,您在 Word 中定义一个漂亮的模板,其中包含嵌入的 XML 模式,在编写故事后,您可以使用形式化的 XML 语法从 Word 中获取它。当然,该 XML 可以用于通过 XSLT 或 Linq 来驱动生成器。

CodeDOM 功能强大,但相当麻烦。 恕我直言,它不是一个易于使用的解决方案,并且它没有真正的模板支持。

我没有使用 T4 的经验,但它的模板功能是一个 pre。

Oslo产品确实很新,需要.Net 4.0这个运行时环境。 它仍然只是一个CTP。 这是一个非常强大的环境,尽管我对数据库生成的故事有一些疑问。

希望这可以帮助。

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.

深海夜未眠 2024-07-19 13:05:47

嗯,奥斯陆不属于这个名单。 到目前为止,它还没有代码生成的故事。 所以还是用T4吧。

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

2024-07-19 13:05:47

Oslo 无意为您生成代码。 您必须创建一个运行时(例如 C# 程序)来根据数据更改其行为。 您可以像互联网浏览器一样查看它。

我不相信奥斯陆需要 .Net 4.0,就像 Rine 提到的那样。 在埃维诺荷兰实习期间,我正在创建 Oslo MSchema 和 MGrammars 以及 C#3.5 运行时。 根据给定的数据,它将创建(而不是生成)WCF 服务并运行这些服务。

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.

慈悲佛祖 2024-07-19 13:05:47

有一些有趣的应用

  • 奥斯陆“新 LDAP”System.Identity ,更多内容请参见 PDC 会话视频 http://microsoftpdc .com/Sessions/SVC28
  • System.Modelling(我认为)Microsoft.UML2,您可以在存储库中推送有关方法、类、模块等的信息,对其进行分析并创建报告。 例如,创建在 2 个构建之间添加/删除方法的报告 http://microsoftpdc.com/Sessions/SVR19
  • 当然还有建模

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文