简体   繁体   English

如何在Visual Studio中使用更改后的Roslyn

[英]How to use an altered Roslyn in Visual Studio

C# isn't enough for me, so I've taken advantage of the newly-open sourced Roslyn to extend it, say by modifying it to use French quotes . C#对我来说还不够,因此我利用了新开放源代码的Roslyn对其进行扩展,例如通过将其修改为使用法语引号进行扩展。

But I don't want to build my newly-French-quoted files on the command line! 但是我不想在命令行上构建新的法语引用文件! I want Intellisense! 我要Intellisense! I want a nice UI! 我想要一个不错的用户界面! In short, I want to get Visual Studio to use my Roslyn, not Microsoft's. 简而言之,我想让Visual Studio使用我的 Roslyn,而不是Microsoft的Roslyn。

Can I do this yet? 我可以这样做吗? If so, how ? 如果是这样, 怎么办?

Quoted straight from this link in your question: 直接从您的问题中的此链接引用:

ADVANCED USAGE 高级用法

It is also possible to update your copy of Visual Studio to use your own built version of Roslyn (for example, to see how the IDE reacts to your changes), but it's slightly complicated: 也可以更新您的Visual Studio副本以使用自己的内置版本的Roslyn(例如,查看IDE如何响应您的更改),但这有点复杂:

First of all, you'll need to use the release fork, not the master fork. 首先,您需要使用释放叉子,而不是主叉子。 This is because the compiler code is constantly changing in reaction to feedback, and that includes changes to the APIs that are used by the non-open IDE bits in the Roslyn preview in order to access compiler information (until the APIs get locked down as we get closer to completion). 这是因为编译器代码会不断变化以响应反馈,并且其中包括对Roslyn预览中非开放IDE位使用的API的更改,以便访问编译器信息(直到我们锁定这些API时,接近完成)。 When these APIs change, the ability to communicate between the two is lost. 当这些API更改时,两者之间的通信能力就会丧失。 The release fork, however, accurately reflects the state of the code at the time that the Roslyn preview was snapped, and so is safe to use as a baseline for this sort of thing. 但是,发布分支在Roslyn预览被捕捉时准确地反映了代码的状态,因此可以安全地用作此类事情的基准。 (You can see the fork on the Roslyn CodePlex site by choosing “Source Code” and then opening the “Browsing changes in” dropdown – it's called “releases\\build-preview.”) (您可以在Roslyn CodePlex站点上查看分叉,方法是选择“源代码”,然后打开“浏览更改”下拉菜单-称为“版本\\构建预览”。)

To switch to this fork in Git, you will need to execute the following two commands from an appropriate Git prompt in your enlistment: 要在Git中切换到此派生,您将需要从清单中适当的Git提示符处执行以下两个命令:

Git fetch Git获取

Git checkout – track origin/releases/build-preview Git结帐–跟踪来源/发布/构建预览

Your git repository will now have the contents of the releases/build-preview branch. 您的git存储库现在将具有releases / build-preview分支的内容。 Once you've done this, you can switch back and forth between the branches using Git checkout master and git checkout releases/build-preview. 完成此操作后,您可以使用Git checkout master和git checkout releases / build-preview在分支之间来回切换。 (Details on Git usage are beyond the scope of this blog; see http://www.git-scm.com/book/en/Git-Branching-Remote-Branches for more information on branching in Git.) (有关Git使用的详细信息不在本博客的讨论范围之内;有关Git中分支的更多信息,请参见http://www.git-scm.com/book/en/Git-Branching-Remote-Branches 。)

Second, you'll need to disable Visual Studio's strong-name assembly checking for the relevant assemblies first. 其次,您需要首先禁用Visual Studio的强名称程序集检查相关程序集。 There's a script to help with that, which you can find checked into the source code at Src/Tools/Microsoft.CodeAnalysis.Toolset.Open/Scripts/Prepare.bat. 有一个脚本可以帮助您解决此问题,您可以在Src / Tools / Microsoft.CodeAnalysis.Toolset.Open / Scripts / Prepare.bat中找到源代码。

With all of that done, make your changes. 完成所有这些操作后,进行更改。 Then, after building, ensure that CompilerPackage is set as the startup project, and then F5/Ctrl+F5 to launch a VS instance containing the changes. 然后,在构建之后,确保将CompilerPackage设置为启动项目,然后确保按F5 / Ctrl + F5启动包含更改的VS实例。

Please note that we will never accept pull requests for the release fork – we need to keep it pristine and accurately reflecting the state of the code relative to the Roslyn preview bits. 请注意,我们永远不会接受释放叉的拉取请求-我们需要保持原始状态,并准确反映代码相对于Roslyn预览位的状态。 Anything you actually want considered for submission would need to be ported to a fork created from the master first. 您实际上要考虑提交的所有内容都需要先移植到由主服务器创建的fork中。

Interesting times ahead. 有趣的时刻。 Though I have a certain amount of trepidation about finding myself in a company where they use an entirely customised compiler to do awful, awful things. 尽管我对于在一家公司使用完全定制的编译器来执行糟糕的事情的公司感到不安。 The gun to shoot yourself in the foot with has just been upgraded... 用脚射击自己的枪刚刚升级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM