.NET Tools Early Access Program Features Rider

Immediate Window – Interact with your Code while Debugging in Rider

A valuable part of the debugging experience is experimentation, modifying variables and determining whether the outcomes were what we expected. With the latest release of Rider 2020.3 EAP, we’re happy to give developers more tools that make debugging more effective.

As you may have guessed from the title of this post, the Immediate Window is shipping in Rider 2020.3 EAP.

What is the Immediate Window?

The immediate window offers a way to access the code of our application while it is being executed. While debugging, we can write additional code that can add to or alter the current code execution. Rider’s Immediate Window has many of the same code editing features that we use regularly when developing. We can evaluate expressions, execute statements, print variables, and much more. Let’s take a look at some of those features now.

Using the Immediate Window

The Immediate Window becomes visible as soon as we start a debugging session. We can see the new window on the bottom-right, below the watch variables within the debugger pane.

Debugger pane in immediate window

We can toggle the Immediate Window by clicking the little terminal icon, which is right below the “show watch variables” icon (the glasses).

immediate window icon

The Immediate Window will only accept input when the application is in a paused state, likely due to hitting a breakpoint. Once the window becomes active, we can type any valid C# code, with the full range of code completion features to assist us.

Immediate Window Code Completion

We can also use shortcuts like Alt+Enter to trigger refactorings.

Alt enter example in immediate window

It is also possible to navigate from from the Immediate Window to classes and variables.

Navigation from immediate window

In the following example, we alter the value of one from 1 to 2. Note that the Immediate Window understands the execution context. Being paused in the current scope allows us to access the local variable.

Immediate Window Change Variables

In addition to being able to access previously defined members, we can also define new synthetic variables. In the following example, we instantiate a new instance of a Person class. When we create a new variable, Rider will track its value in the variables window under a synthetic variables collection. We can inspect, pin, and alter these variables under this new category like we would any other variables.

Synthetic Variables In Variable Window

We’ve discussed how to adjust existing variables and create new ones for Rider to track. We can also execute statements without needing to assign them to any variables. Rider will record the last returned value from a run statement under the $result placeholder.

Results placeholder in variables window

The Immediate Window will also track the history of all of our statements. Pressing the up and down arrow keys will cycle through all the statements we’ve executed in the Immediate Window.

Conclusion

To give the Immediate Window a try, you can download the latest version of Rider 2020.3 EAP.

We hope you enjoy using all the new features shipping with Rider, especially the Immediate Window. Remember to leave comments on this post or file issues in the Rider issue tracker.

image description