With JetBrains Rider, you can not only view values of separate variables, but also evaluate more complex expressions, such as method calls, operator expressions, lambda expressions, and anonymous classes.
Expressions are evaluated in the context of a stack frame currently selected in the Frames pane of the Debug Tool Window
Evaluating expressions in the editor
You can extend or shrink the selection with Ctrl+Alt+Right/ Ctrl+Alt+Left thus changing the evaluated expression:
You can also invoke the value tooltip on a variable, expression, or selection with the Quick Evaluate Expression command (Ctrl+Alt+F8 or Run | Quick Evaluate Expression or Alt -click ).
Evaluating arbitrary expressions in the dedicated dialog
The Evaluate dialog lets you play with variables and expressions in the current context — you can perform various operations and call methods on them, and then analyze results that you get with their current values
For example, if there is a
String myString variable in the current context, you can enter the following expression to check whether the current value of the variable contains a substring:
The Evaluate dialog is non-modal, so you can switch the focus back to the editor to copy other variables and expressions, and you can also open multiple Evaluate dialogs if necessary.
While evaluating expressions, mind the following
A method can be invoked in the Evaluate dialog only if the debugger has stopped at a breakpoint, but has not been paused.
Expression evaluation can only be "single-level". In other words, if JetBrains Rider stops at a breakpoint within a method called from the Expression Evaluation, you cannot use the Expression Evaluation feature again.
Evaluate an arbitrary expression
If you want to start with some expression or a variable, select it in the editor or in any view in the Debug window.
Open the Evaluate dialog in one of the following ways:
Selectfrom the context menu.
Choosefrom the main menu.
Click on the toolbar of the Debug window.
If you have selected something at the first step, the variable or expression will be displayed in the Expression field. Otherwise, type the expression in the field or choose one of the previously evaluated expressions from the list.
Press Enter or click Evaluate. The read-only Result field will show the evaluation output.
If you have assigned a label to an object, you can reference it by this label $[label_name].If the specified expression cannot be evaluated, the Result field explains the reason.
If you want to edit a multi-line expression or a code fragment, click in the Expression field or press Shift+Enter to switch to the multi-line Code fragment view and back.
To switch between the evaluated fragments, press Alt+Down and Alt+Up.
Optionally, you can select another thread where you want an expression to be evaluated in the Frames pane of the Debug window.