CShell, the open source C# REPL IDE
- Posted: May 19, 2014 at 6:00AM
- 18,063 views
- 10 comments
Loading user information from Channel 9
Something went wrong getting user information from Channel 9
Loading user information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Sometimes you just need to play with a few lines of C#. You need to try something out, see the results of a quick execution, etc. And you need to wash-rinse-repeat, to build on your just run, add a little more, run it, add more, etc. You need to REPL, to read-eval-print-loop.
Sure you can do this in LINQPad or fire up a Visual Studio project, but neither are really REPL and can be a little overkill. And since you're here, I'm sure you'd also like to see behind the curtain, to not only play with the binary, but see how what goes into the binary, i.e. the source.
I found today's project via Alvin Ashcraft's awesome blog, Dew Drop and post Dew Drop - May 15, 2014 (#1777). If you only have a few minutes a day to scan what's new, Alvin's blog is one of those must read resources.
Now, on with the...
CShell is an interactive C# scripting environment. It allows you to use C# without any fluff right in a console like environment called a 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. More elaborate code can be written in a C# script and then evaluated as one file, only one line, or a selection. Then, your results can be easily dumped to HTML (like LINQPad) or viewed as a data grid or plotted to a chart.
CShell is perfect to explore data and quickly drill deeper into information since you can write one line of code, evaluate it, check out the results, and then write some more code, evaluate it again, and so forth.
If you just want to test one or two lines of C# code without creating a new console project in Visual Studio just fire up CShell, type the code you wanna test and you immediately can see if it works the way you want.
We developed CShell because we needed it for ourselves. Visual Studio was often too heavy weight and LINQPad has no REPL loop. What if you load 2-3 GB of data and then wanna start exploring it, without having to load all the data every time the program is executed? With a REPL loop this is possible. Also we felt the time is ready for a more mature C# scripting environment with projects like NRefactory, Mono.CSharp and Roslyn quickly filling the gaps that remained to realize such a project.
I grabbed the latest code drop, which compiled and ran with no problems...
Here's a snap of the Solution;
So what are the features of CShell? Glad you asked...
- Read Eval Print Loop (REPL): Evaluates C# code on the fly (built using Mono.CSharp). Includes code completions right in the command line.
- C# Code Editor: A powerful editor with code completion that supports C# scripts (.csx files) and normal C# (.cs) files and many more file types. Code from the scripts can be directly sent to the REPL.
- Workspace Explorer: The place to keep all the scripts and other files organized, manages references, and edit the ".cshell" file, in which the whole CShell IDE can be configured using C# code (not XML).
- Sinks: Out of the box there are several ways of viewing any resulting data: Simple console output, LINQPad like XHTML dump, data grids, and plotting.
- Extend CShell: The whole project was built with extensibility in mind, modules that add new editors or sinks and more can be quickly developed and loaded in CShell.
I wonder how/when/if Roslyn will impact this project. Guess we'll have to wait and see. But since it is open source, I guess we could drive that ourselves! :)
If you've been looking for a C# REPL environment, one that's also open source, you've got to check out CShell...