F#有一个REPL(读取 - 评估 - 打印循环)F#Interactive,C:\Program Files (x86)\Microsoft F#\v4.0\Fsi.exe
。
我知道C#现在有自己的交互式REPL,与Roslyn一起发布。如何在Visual Studio外部打开? csi.exe
在哪里?
C#Interactive窗口和csi.exe REPL被添加到Visual Studio 2015 Update 1(强调我的):
Introducing Interactive
交互式窗口又回来了! C#Interactive窗口返回Visual Studio 2015 Update 1以及其他一些交互式处理:
- C#互动。 C#Interactive窗口本质上是一个read-eval-print-loop(REPL),允许您使用.NET技术进行游戏和探索,同时利用IntelliSense,语法着色等编辑器功能。了解有关如何使用C#的更多信息在第9频道互动或阅读我们的初学者演练。
- CSI。如果您不想打开Visual Studio来使用C#或运行脚本文件,则可以从Developer Command Prompt访问交互式引擎。键入
csi /path/myScript.csx
以执行脚本文件或仅键入csi
以放入命令行REPL。- 脚本API。 Scripting API使您能够在主机创建的执行环境中执行C#代码片段。您可以通过查看我们的代码示例来了解有关如何创建自己的C#脚本引擎的更多信息。
见What’s New in Visual Studio 2015 Update 1 for .NET Managed Languages。
https://www.visualstudio.com/en-us/news/vs2015-update1-vs.aspx
>csi
Microsoft (R) Visual C# Interactive Compiler version 1.1.0.51109
Copyright (C) Microsoft Corporation. All rights reserved.
Type "#help" for more information.
> #help
Keyboard shortcuts:
Enter If the current submission appears to be complete, evaluate it. Otherwise, insert a new line.
Escape Clear the current submission.
UpArrow Replace the current submission with a previous submission.
DownArrow Replace the current submission with a subsequent submission (after having previously navigated backwards).
REPL commands:
#help Display help on available commands and key bindings.
Script directives:
#r Add a metadata reference to specified assembly and all its dependencies, e.g. #r "myLib.dll".
#load Load specified script file and execute it, e.g. #load "myScript.csx".
>
> Enumerable.Range(10)
(1,12): error CS7036: There is no argument given that corresponds to the required formal parameter 'count' of 'Enumerable.Range(int, int)'
> Enumerable.Range(1, 10)
RangeIterator { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
我创建了你要求的东西,一个在VisualStudio之外运行的基于Roslyn的REPL。
您可以从PoC - Roslyn C# ScriptEngine Execute v1.0.exe下载它,Video: Using O2's Roslyn-based C# REPL Script environment是一个独立的exe,包含所有Roslyn程序集作为嵌入式资源。另见O2 Platform
请注意,我为C# REPL Script Environment开发了一个更强大的C#REPL,您可以从other stand-alone tools查看和下载
关于Roslyn的主题,这里有一些我创建的Util - View Roslyn AST Graph v1.0.exe:
C:\Program Files (x86)\Microsoft Codename Roslyn CTP\Binaries\rcsi.exe
- 显示代码编译和安全扫描的集成(Cat.NET将在第一次执行此工具时下载)请注意,所有这些工具和O2平台都是在开源许可下发布的,所以请随意扩展并使它们更好:)
我找到的唯一可执行文件是.csx
,它可以执行http://scriptcs.net/文件。但它似乎并没有真正支持REPL。
脚本如何:https://roslynpad.net/?
有一个REPL,你甚至可以获得NuGet的力量。
它可能不是替代品,但我主要使用RoslynPad进行快速研究和测试。我也用过Linqpad。根据他们的网站http://channel9.msdn.com/Events/PDC/PDC08/TL16#time=65m00s,RoslynPad是“基于Roslyn的简单C#编辑器”。您可以编写小脚本,并且可以查看变量值,也可以保存它们。
Anders Hejlsberg在此视频中构建了一个C#REPL循环,65分钟内:
qazxswpoi
这是Roslyn的一个旧版本,但同样的想法适用(和eval !;)。