C# Interactive in Rider

Posted on by Maarten Balliauw

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!

Comments below can no longer be edited.

15 Responses to C# Interactive in Rider

  1. Jarl Gullberg says:

    December 1, 2017

    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.

    • Maarten Balliauw says:

      December 1, 2017

      What are the parameters you are setting? Are they saved in settings and just not applied in the interactive command?

    • Maarten Balliauw says:

      December 2, 2017

      We will get this solved in one of the next EAP builds. Thanks!

  2. Derek Price says:

    December 7, 2017

    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

    • Maarten Balliauw says:

      December 7, 2017

      Just like in a C# file – write using System.Text.RegularExpressions; first to load the namespace into the execution context.

      • Derek Price says:

        December 7, 2017

        Great – thanks. Maybe a future feature would be auto imports? 🙂

  3. Mike Fayer says:

    May 16, 2018

    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. Maarten Balliauw says:

    May 21, 2018

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

  5. Michael says:

    October 24, 2018

    I apologize for being a bit off topic. I’m looking for an Immediate Window like Visual Studio has. All searches lead me to this C# interactive windows. As far as I can tell, the interactive window doesn’t attach to the process being debugged and work like Immediate Window.

    Does the immediate window feature exist in Rider, or should I just use Watch window

  6. Michael says:

    October 24, 2018

    As always happens, I found the feature (or a suitable replacement) just seconds after posting my query. I found the “Evaluate” window. I’ve looked several times over the last few weeks and did not discover it until now.

  7. Vladimir Bondarev says:

    December 13, 2018

    Hello. I’m using Rider and pure .Net Core 2.x (without Mono) and C# Interactive is very tasty feature. Can I use it? In the settings I see only Windows path.


Subscribe to .NET Tools updates