如何使 Roslyn 语法可视化工具扩展工作?
Roslyn 安装后,它附带了几个很棒的演示工具。首先,我认为对于那些想要更彻底地学习语法树的人来说,最有价值的是语法可视化工具窗口,它显示了活动 *.cs 文件的语法树。
当我启动这个扩展并在 Visual Studio 的测试实例中尝试它时,一切工作正常。但是当我安装了这个扩展后,它就不再工作了。我还有视图->其他窗口 -> Roslyn Syntax Visualizer 但只弹出一个空窗口工具。
有人有同样的问题并且知道解决方案吗?
我想也许我需要复制这个扩展在重建时生成的 DLL 文件,但我不知道应该把它放在哪里。
后来我发现了另一个有趣的细节 - 当我启动自己的扩展时,语法可视化工具可以工作!因此,它仅适用于 Visual Studio 的测试实例。为什么应该是这样呢?
When Roslyn installed, it comes with a couple of great demo tools. Firstly, the most valuable I think for those who want to learn syntax trees more thoroughly is the Syntax Visualizer Tool Window which shows the syntax tree of active *.cs files.
Everything worked fine when I launched this extension and tried it in a test instance of Visual Studio. But when I have installed this extension, it's not working anymore. I still have View -> Other Windows -> Roslyn Syntax Visualizer but just an empty window tool pops up.
Does anyone have the same problem and know the solution?
I guess that maybe I need to copy DLL files which this extension produces when rebuild but I don't know where should I put it.
Later I found another interesting detail - when I launch my own extension, Syntax Visualizer Tool works! So, it works only in test instance of Visual Studio. Why it should be like that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尼科很可能已经找到了答案。查看 Syntax Visualizer 项目的“调试”属性,发现它是使用 /rootsuffix Roslyn 启动的。另外,如果不以这种方式启动,您应该能够在 C# REPL 和 C# 脚本编辑器窗口中看到语法可视化工具;因为他们是 Roslyn CSharp 编辑。
Nico most likely has the answer. Look in the Debug properties of the Syntax Visualizer project to see that it is launching with /rootsuffix Roslyn. Also, without launching this way, you should be able to see the Syntax Visualizer in the C# REPL and C# Script editor windows; as these are Roslyn CSharp editors.
语法可视化工具仅在您运行启用了 Roslyn 的 Visual Studio 时才起作用。当您启动 Visual Studio 的测试实例时,Roslyn 会自动启用。可以通过将 /rootsuffix Roslyn 添加到快捷方式来手动启动带有 Roslyn 的 Visual Studio,但请注意 Roslyn 尚未完成。默认情况下启用它可能并不可取,具体取决于您正在处理的内容。当然,您也可以使用 Roslyn 创建另一个快捷方式,这样您就可以选择您想要的快捷方式。
如果您在 Visual Studio 的代码选项卡中看到[Roslyn],则可以使用可视化工具。验证 Roslyn 是否已启用的另一种方法是查看您的扩展。 Roslyn 语言服务必须存在才能发挥作用。如果不是这种情况,则可以打开可视化工具,但不会显示任何内容。
您可以在此处找到有关可视化工具扩展的更多信息。
The Syntax Visualizer only works when you are running Visual Studio with Roslyn enabled. When you start a test instance of Visual Studio, Roslyn is automatically enabled. Manually starting Visual Studio with Roslyn can be done by adding /rootsuffix Roslyn to the shortcut, but take care that Roslyn is not finished yet. It might not be advisable to enable it by default, depending on what you are working on. Of course, you can also just create another shortcut with Roslyn, so you can choose which one you want.
If you see [Roslyn] in your code tabs in Visual Studio, then you can use the visualizer. Another way of verifying if Roslyn is enabled is to view your extensions. The Roslyn Language Services has to be there for it to work. If this is not the case, then the visualizer can be opened, but it won't show any contents.
You can find more information about the visualizer extension here.