JetBrains Rider 2024.3 Help

Evaluate Expressions

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 Debug window.

Evaluate expressions in the editor

The easiest way to evaluate expressions is to use editor tooltips. If the value of a variable or an expression contains child elements, clicking the Add button expands the node and displays all children.

  • When Show value tooltip is enabled on the Build, Execution, Deployment | Debugger | Data Views settings page  Ctrl+Alt+S, you can hover over variables and expressions to see the evaluated results:

    JetBrains Rider: Evaluating expression in an editor tooltip
  • When Show value tooltip on code selection is enabled on the Build, Execution, Deployment | Debugger | Data Views settings page  Ctrl+Alt+S JetBrains Rider shows the evaluation result for the selected expression.

    You can extend or shrink the selection with Ctrl+W/Ctrl+Shift+W thus changing the evaluated expression:

    JetBrains Rider: Evaluating selected expression in an editor tooltip
  • 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 ).

Evaluate 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: myString.Contains("text")

JetBrains Rider: Evaluate Expression dialog

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

  1. If you want to start with some expression or a variable, select it in the editor or in any view in the Debug window.

  2. Open the Evaluate dialog in one of the following ways:

    • Press Alt+F8.

    • Select Evaluate Expression from the context menu.

    • Choose Run | Debugging Actions | Evaluate Expression from the main menu.

    • Click Evaluate expression on the toolbar of the Debug window.

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

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

  5. If you want to edit a multi-line expression or a code fragment, click Expand 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.

  6. Optionally, you can select another thread where you want an expression to be evaluated in the Frames pane of the Debug window.

Last modified: 23 September 2024