简体   繁体   English

Visual Studio:c#交互式shell窗口

[英]Visual Studio: c# interactive shell window

Is there a way to use the C# interactive shell window (from the Roslyn CTP) outside of VS? 有没有办法在VS之外使用C#交互式shell窗口(来自Roslyn CTP)? Or is there something similar to it that is available? 或者有类似的东西可用吗?

Right now, the interactive window only works inside Visual Studio. 现在,交互式窗口仅适用于Visual Studio。 Roslyn exposes a scripting API which the interactive window uses, so you really want an interactive window running somewhere else, feel free to write it! Roslyn公开了一个交互式窗口使用的脚本API,所以你真的想要一个在其他地方运行的交互式窗口,随意编写它!

After several years (ugh!) there is finally something in this space! 几年之后(呃!),这个空间终于有了! CShell . CShell From the site: 从网站:

CShell is an interactive C# scripting environment. CShell是一个交互式C#脚本环境。 It allows you to use C# without any fluff right in a console like environment caled a read-eval-print-loop (REPL). 它允许您在控制台中使用C#而不会出现任何毛茸茸的情况,例如使用read-eval-print-loop(REPL)的环境。 Your code is directly evaluated and executed in a shell window, no separate executable has to be compiled and then run in a different process. 您的代码将直接在shell窗口中进行评估和执行,不必编译单独的可执行文件,然后在不同的进程中运行。 More elaborate code can be written in a C# script and then evaluated as one file, only one line, or a selection. 可以在C#脚本中编写更复杂的代码,然后将其评估为一个文件,仅一行或选择。 Then, your results can be easily dumped to HTML (like LINQPad) or viewed as a data grid or plotted to a chart. 然后,您的结果可以轻松转储到HTML(如LINQPad)或作为数据网格查看或绘制到图表。

To be clear, the C# Interactive window uses several Visual Studio components (such as the VS Editor), so it cannot be hosted outside of VS. 需要明确的是,C#Interactive窗口使用多个Visual Studio组件(例如VS编辑器),因此无法在VS之外托管。 As Jason Malinowski said, you can create a quick-and-dirty Interactive window outside of VS pretty easily using the Roslyn Scripting APIs . 正如Jason Malinowski所说,使用Roslyn Scripting API可以很容易地在VS之外创建一个快速且脏的交互式窗口。 Also, if you're looking to evaluate code outside of VS, you can create a C# Script file (.csx), add top-level code just as you can in the Interactive window, and run it with the rcsi.exe binary that ships with the Roslyn CTP. 此外,如果您要评估VS之外的代码,可以创建C#脚本文件(.csx),在交互式窗口中添加顶级代码,并使用rcsi.exe二进制文件运行它与Roslyn CTP一起发货。

csi.exe is the command-line version of C# interactive. csi.exe是C#interactive的命令行版本。 It's shipped in the box with Visual Studio. 它随Visual Studio一起提供。 Type csi from a Developer Command prompt. 在Developer Command提示符下键入csi。

Here is a quick Example, pretty minimal though. 这是一个快速的例子,尽管很小。 Don't support blocks {} 不支持块{}

http://www.amazedsaint.com/2011/10/c-vnext-roslynan-introduction-and-quick.html http://www.amazedsaint.com/2011/10/c-vnext-roslynan-introduction-and-quick.html

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

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