微软罗斯林与codeDOM [英] Microsoft Roslyn vs. CodeDom

查看:164
本文介绍了微软罗斯林与codeDOM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从<一个href="http://www.infoworld.com/d/application-development/microsofts-roslyn-reinventing-the-compiler-we-know-it-176671">$p$pss对于新的发布关于InfoWorld的href="http://www.microsoft.com/download/en/details.aspx?id=27746">微软罗斯林:

From a press release yesterday on InfoWorld regarding the new Microsoft Roslyn:

这样的解构的最明显的优势编译器   它允许整个编译执行过程中被从调用   在.NET应用程序。 Hejlsberg为证明一个C#程序,   通过几个code段为C#编译器为字符串;编译器   返回所产生的IL组装code作为对象,这是当时   传递给公共语言运行库(CLR)执行。瞧!随着   罗斯林,C#收益的动态语言的能力产生和调用   code运行时。

The most obvious advantage of this kind of "deconstructed" compiler is that it allows the entire compile-execute process to be invoked from within .Net applications. Hejlsberg demonstrated a C# program that passed a few code snippets to the C# compiler as strings; the compiler returned the resulting IL assembly code as an object, which was then passed to the Common Language Runtime (CLR) for execution. Voilà! With Roslyn, C# gains a dynamic language's ability to generate and invoke code at runtime.

由于.NET 4的发布与<一个我已经能够做到这一点href="http://msdn.microsoft.com/en-us/library/system.$c$cdom.compiler.$c$cdomprovider.compileassemblyfromsource.aspx"><$c$c>CSharp$c$cProvider.CompileAssemblyFromSource这是我在写前一段时间所做的正是这一个ASP.Net项目其实使用 - 允许用户在输入code到一个文本框,选择组件/命名空间来引用,然后执行和显示从$输出C $ C对即时的现场环境code测试在Windows Azure上。

I've been able to do this since the release of .NET 4 with CSharpCodeProvider.CompileAssemblyFromSource which I in fact use in an ASP.Net project written awhile ago that does exactly that - allows a user to type in code into a textbox, choose assemblies/namespaces to reference, and then execute and display the output from that code on-the-fly for live environment code testing on Windows Azure.

时的/一个precurser到罗斯林 codeDOM 部分?什么是罗斯林超过 codeDOM

Is CodeDom part of / a precurser to Roslyn? What's the special benefit of Roslyn over CodeDom?

推荐答案

免责声明:我为微软工作的罗斯林小组

Disclaimer: I work for Microsoft on the Roslyn team.

codeDOM是precursor到罗斯林,但只能勉强关系。从本质上讲,codeDOM是一个简单的和(有点)LANGAGE不可知的方式来生成中添加了.NET 1.0支持设计师(一拉的WinForms)code。因为codeDOM是在提供一个统一的模型,可以产生code在C#,VB等语言的一种尝试,它缺乏高保真与任何它所支持的语言(这就是为什么你不能创建一个与codeDOM switch语句)。 CSHARP codeProvider.CompileAssemblyFromSource它仅仅是执行csc.exe的一个包装。

CodeDom is a precursor to Roslyn, but is only marginally related. Essentially, CodeDom is a simple and (somewhat) langage agnostic way to generate code that was added in .NET 1.0 to support designers (a la WinForms). Because CodeDom was an attempt at providing a unified model that can generate code in C#, VB, and other languages, it lacks high fidelity with any of the languages that it supports (that's why you can't create a switch statement with CodeDom). CSharpCodeProvider.CompileAssemblyFromSource is simply a wrapper around executing csc.exe.

罗斯林是一个完全不同的动物。这是双方的C#和从地上爬起来使用管理code VB编译器重写 - C#中VB C#和VB(csc.exe的今天和VBC.EXE该船舶的版本都写在本土code)。建立他们管理code的好处是,用户可参考实际的编译器从.NET应用程序库(无包装需要)。

Roslyn is a completely different animal. It is a rewrite of both the C# and VB compilers from the ground up using managed code -- C# in C# and VB in VB (the versions of csc.exe and vbc.exe that ship today are written in native code). The advantage of building them in managed code is that users can reference the real compilers as libraries from .NET applications (no wrappers needed).

构建编译器管道的每个组成部分,我们已经在上面公开的公共API的:

While building each component of the compiler pipeline, we've exposed public APIs on top:

  • 分析器 - >语法树API
  • 符号表/元数据导入 - >符号API
  • 粘合剂 - >绑定与流量分析的API
  • 在IL发射器 - >的Emit API

罗斯林可以作为一个复杂的C#和VB源$ C ​​$ C发电机,但是这其中的相似之处,以codeDOM结束。在罗斯林编译器的API可用于为C动态解析code,进行语义分析,编译和评估$ C $,等等。

Roslyn can be used as a sophisticated C# and VB source code generator, but that's where the similarity to CodeDom ends. The Roslyn Compiler APIs can be used to parse code, perform semantic analysis, compile and evaluate code dynamically, etc.

在除了编译器,罗斯林团队也在重建Visual Studio的C#和VB的IDE功能的顶部市民编译器的API 的。因此,编译器API是足够丰富打造的Visual Studio的设计时工具,如智能感知和提取方法重构。此外,在层的编译器上面,罗斯林提供了更高层次的分析或数据转换服务。例如,有用于使用C#和VB格式化规则,格式化code或找到一个解决方案中,以一个特定符号的所有引用的服务。

In addition to the compilers, the Roslyn team is also rebuilding the Visual Studio C# and VB IDE features on top of the public compiler APIs. So, the compiler APIs are rich enough to build the Visual Studio design-time tools, like IntelliSense and the Extract Method refactoring. Also, at layers above the compiler, Roslyn offers services for higher-level analysis or data transformation. For example, there are services for formatting code using the C# and VB formatting rules, or finding all references to a particular symbol within a solution.

说真的,这里不仅仅是一个的罗斯林超过codeDOM特别的好处。凡codeDOM填补了非常具体的code一代的需要,罗斯林是通过提供一个框架,允许您构建几乎任何类型的C#或VB语言工具,你能想到的解决整个语言工具的空间。

Really, there isn't just one special benefit of Roslyn over CodeDom. Where CodeDom filled a very specific code generation need, Roslyn is tackling the entire language tooling space by providing a framework to allow you to build just about any sort of C# or VB language tool you can think of.

这篇关于微软罗斯林与codeDOM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆