C# Interactive in Rider

In the latest Rider 2017.3 EAP build, we have added a new C# Interactive tool window. It allows running C# statements without having to wait for compilation. This means we can get immediate feedback on what a given expression will return.

The C# Interactive tool window can be opened from the Tools | C# Interactive menu, or by pressing Alt+Enter in the editor and sending a code snippet to the interactive window:
Send line to C# Interactive

We can then use the read-eval-print loop (or REPL) to write any C# expression and evaluate it when pressing enter:
Using CSharp REPL in Rider

All expressions we execute during a C# Interactive session are held in history. We can re-evaluate a certain statement using the up/down arrows, or from the toolbar on the left.
C# Interactive history

The C# Interactive tool window is very useful to draft some code, so we made it easy to get a full transcript of the session – making it easy to copy/paste some snippets into actual code for the project we are working on.
Export transcript from C# Interactive session

On Windows, Rider uses the csi.exe executable that ships with MSBuild. On Mac OS X and Linux, Rider defaults to Mono’s csharp. We do our best to auto-detect the tool location. In case Rider can’t find it or we want to use another C# REPL, we can customize the tool path (and arguments) from the settings.
C# Interactive tool path settings

Download Rider 2017.3 EAP and give it a try! We’d love to hear your feeback!

This entry was posted in How-To's and tagged , , , . Bookmark the permalink.

10 Responses to C# Interactive in Rider

  1. Jarl Gullberg says:

    I’m using the latest EAP on Linux with Mono and the .NET Core 2.0.3 SDK installed. Here, Rider defaults to CSI and can’t initialize an interactive session due to the lack of System.ValueType.dll. It also ignores any changes I make to the executable arguments.

    Switching over to Mono’s csharp works fine.

  2. Derek Price says:

    How do I have the interactive window recognize assemblies? For example, I tried pasting this in the window:

    const string pattern = @”[^\u0000-\u007F]+”;
    Regex.IsMatch(“temp °”, pattern);

    and got this error:

    > > (1,1): error CS0103: The name ‘Regex’ does not exist in the current context

  3. Mike Fayer says:

    Any chance of getting intellisense into C# interactive? That’s what makes this tool really shine in VS2017.

    Another nice feature would be to include all the referenced assemblies in the current project in the interactive session so I don’t have to do a bunch of manual #r’ing.

  4. In the right-hand column, there is a “Votes” section where you can upvote when you have an account in our issue tracker.

Leave a Reply

Your email address will not be published. Required fields are marked *