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!

About Maarten Balliauw

Maarten Balliauw is a Developer Advocate at JetBrains, working on .NET tools and Space. He focuses on .NET, Azure, web technologies and application performance. Maarten is a frequent speaker at various national and international events. In his free time, he brews his own beer. Follow him on Twitter or check out his personal blog.
This entry was posted in How-To's and tagged , , , . Bookmark the permalink.

15 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.

  5. Michael says:

    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:

    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:

    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.

Leave a Reply

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