如何使用罗斯林C#编译器和Visual Studio 2015年? [英] How to use roslyn c# compiler with visual studio 2015?

查看:206
本文介绍了如何使用罗斯林C#编译器和Visual Studio 2015年?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些关于罗斯林混乱

I've a bit of confusion about roslyn.

我做了什么:
我已经安装了2015年VS社区版和下载extensibilty> 。downlod编译平台SDK

What I have done: I've installed vs 2015 community edition and download in extensibilty > downlod compiler platform sdk.

所以,我创建了一个简单的控制台应用程序:Hello World示例

So I created a simple console application: hello world example.

现在好了我M期望的choise在vs2015默认的和罗斯林...的C#编译器,但我还没有发现这样的选项。
所以我的第一个问题是:如何选择C#编译器的版本

Well now I'm expect to choise the c# compiler between the vs2015 default one and roslyn..., but I've not found such option. So my first question is: how to select version of c# compiler?

其次,我已经下载了主罗斯林和我建立,后来我发现CSC。 exe文件,好奇怪的事情是,如果我劳克的EXE
我得到C#编译器版本42.42.42.42。 ????右

Second I've downloaded master-roslyn and I build, then I found csc.exe, well the odd things is that if I lauch the exe I get c# compiler version 42.42.42.42. ???? Right?

这时我已经跟着一些教程,但所有的目的?我:
加载从文本文件或字符串瓦尔源和分析或修改语法树,然后编译为VAR

Then I've follow some tutorials, but all purpose me: to load a source from text file or string vars and analyze or change syntax tree, then compile to var.

嗯,这点我很困惑......所以:

Well at this point I'm confused... So:

什么也正是罗斯林?荟萃编译器?这意味着我可以在运行时就像反射改变我的代码?
二:用默认CSC vs2015怎么可以编译或选择罗斯林?
第三:如果我建立罗斯林的定制版本如何使用Vs2015我​​编译我的源?
哪位知道CSC.EXE是罗斯林?任何帮助或命令行打印的代号。

What is roslyn exactly? A meta compiler? This mean that I can change my code at runtime just like Reflection? Second: how can compile with vs2015 with default csc or choose roslyn? third: If I build a custom version of roslyn How can I compile my source using Vs2015 ? Which know if csc.exe is roslyn? No help or command line print the codename.

感谢

推荐答案

所以它看起来像你有几个问题:

So it looks like you've got a few questions:

罗斯林是新的?的Visual Studio 2015如果你正在构建和运行Visual Studio 2015年中的应用程序内默认的编译器,他们正在编制与罗斯林编译器。你会得到采取的所有新的C#6功能,仅在新的编译器可用的优势。

Roslyn is the new default compiler inside of Visual Studio 2015. If you're building and running applications within Visual Studio 2015, they're being compiled with the Roslyn compiler. You'll get to take advantage of all the new C# 6 features that are available only within the new compiler.

如果您正在使用VS2015,罗斯林已经取代完全而且据我知道你不能在2015年VS使用旧的编译器的旧的编译器。

If you're using VS2015, Roslyn has replaced the old compiler entirely and as far as I know you can't use the old compiler within VS 2015.

罗斯林也是一个平台,可以让你建立可以修改,解释和理解其他程序的程序。它不是真正的意思,让你写的修改本身(尽管这可能可以在一定程度上)代码

Roslyn is also a platform that allows you to build programs that can modify, interpret and understand other programs. It's not really meant to let you write code that modifies itself (although that's probably possible to a degree).

常见的用例罗斯林是:


  1. 建筑的代码分析器的Visual Studio中提供错误和警告。

  2. 建筑扩展Visual Studio中理解源代码。

  3. 建立能够理解其他工具或运行的源代码。例如: ScriptCS - 脚本与C#代码

  1. Building Code Analyzers that provide errors and warnings within Visual Studio.
  2. Building extensions for Visual Studio that understand source code.
  3. Building other tools that understand or run source code. Example: ScriptCS - Scripting with C# code.

为了使用罗斯林为这些目的,你拉下来,从在的NuGet Microsoft.CodeAnalysis 包。您可以使用这些程序包来分析代码,分析语法树,分析符号或代码编译并放出IL。

In order to use Roslyn for these purposes, you pull down the Microsoft.CodeAnalysis packages from NuGet. You can use these packages to parse code, analyze syntax trees, analyze symbols or compile code and emit IL.

如果您有兴趣了解更多关于罗斯林,我已经开始了一系列名为了解罗斯林现在的,你可能会感兴趣。

If you're interested in learning more about Roslyn, I've started a series called Learn Roslyn Now that you might be interested in.

当然可以,但我不认为这是外界的变化进行测试,你想一个伟大的想法促进回罗斯林。您可以从GitHub拉下罗斯林和后续的这说明建立和Visual Studio中运行罗斯林。

Yes you can, but I'm not convinced this is a great idea outside of testing changes you want to contribute back to Roslyn. You can pull down Roslyn from GitHub and follow these instructions to build and run Roslyn from within Visual Studio.

如果你按照这些指示,你就可以运行与F5的罗斯林项目。这将启动Visual Studio的新实例的使用您的自定义编译器。这就是微软以外的人会从现在起促进功能的编译器。 (以前你不能部署自定义编译器的Visual Studio,但他们修复了在Visual Studio更新1)。

If you follow those instructions, you'll be able to run the Roslyn project with F5. It will start a new instance of Visual Studio that's using your customized compiler. This is how people outside of Microsoft will contribute features to the compiler from now on. (Previously you couldn't deploy your custom compiler to Visual Studio but they fixed that in Visual Studio Update 1).

这篇关于如何使用罗斯林C#编译器和Visual Studio 2015年?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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