JetBrains Rider 2020.2 Help

Inspect Variables

When the program is suspended, you can inspect variables and arguments in the context of the currently selected frame: view their values and edit them on the fly. To change the context, select another frame on the Frames pane.

View variables values

There are several ways of viewing variables values.

Variables pane

The default way to examine variables values is use the Variables pane of the Debug window. Note that if a variable is of a complex type, you can expand the corresponding node in the pane to see values that the variable contains.

Sometimes, you may notice that some variables change their color. This happens when the variable value has changed since the last evaluation.

JetBrains Rider: updated variable highlighted in the Debug window

You can quickly navigate from a variable on the Variables pane to its declaration in the source code by pressing F4 or choosing Jump to Source from the context menu.

Inline with code

Another way to see variables values is to look at the code in the editor. By default, JetBrains Rider shows the values of variables at the end of the lines where these variables are declared.

JetBrains Rider debugger: Inline values in the editor

Note, that changed values are also displayed with a different color.

If for some reason, you want to disable showing values inline with code, disable Show Values Inline on the Build, Execution, Deployment | Debugger | Data Views page of JetBrains Rider settings Ctrl+Alt+S.

Code tooltips

When Show value tooltip is enabled on the Build, Execution, Deployment | Debugger | Data Views page of the Settings/Preferences Ctrl+Alt+S , you can hover the mouse over variables to see their values. If the value of a variable or an expression contains child elements, clicking the Add button expands the node and displays all children.

JetBrains Rider: Value tooltips for variables when debugging

Function return values

The Variables pane will display the return value of any method that is called in the current context. This is useful when the result of a method call is not stored in a local variable, for example when using method chaining.

Note that function return values are not available for Unity and other Mono-based projects.

Edit variables values (Edit and continue)

You can also edit your code and continue debugging without restarting. The project will recompile in the background. This works in projects targeting .NET Framework and .NET Core on Windows (except WPF) when Enable Edit And Continue is ticked on the Build, Execution, Deployment | Debugger page of JetBrains Rider settings Ctrl+Alt+S.

There are cases when modifying the code is not possible and a restart is required. These include changing signatures, modifying generic functions, renamings of any kind, and some more. If this happens JetBrains Rider will make you aware by showing a tooltip.

So you can either change code in the editor or edit variable values in the Debug window. This may be convenient, for example, when you want to reproduce a particular context for the debugged function.

  1. In the Variables pane of the Debug window, select the desired variable.

  2. Do one of the following:

    • Press F2.

    • Right-click the variable and select Set Value... from the context menu.

  3. Specify a new value and press Enter.

Customize debugger presentation of complex objects (Pin to top)

If a type neither has a meaningful ToString() override nor is it annotated with the [DebuggerDisplay] attribute, then the presentation of objects of this type in debugger views could be quite uninformative. In Rider, you can customize presentation of such objects by pinning selected members.

In the example below, an object of Album class is presented with its Title and Price fields:

JetBrains Rider: Customizing debugger presentation of complex objects (pinned items)
  1. In the Variables pane of the Debug window, select the desired variable.

  2. Expand the variable, find members that you want to use in the object presentation and click their icons or right-click and choose Pin to top.

  3. The pinned members will move up in the list and their icons will be replaced with the flag icon Icon debugger pinned. Values of the pinned members will be used to form the string presentation of the object in debugger views. So make sure that you choose members that have string-compatible values.

  4. All pinned items in the solution are saved and will be also available after restart. You can see all of them in the Favorites window under the corresponding node.

  5. To stop using a member in the object presentation, click its flag icon Icon debugger pinned in the Variables pane or right-click and choose Unpin, or alternatively, locate the pinned item in the Favorites window and press Delete.

Pinned items will override object presentation even if it has ToString() or is annotated with the [DebuggerDisplay] attribute.

Compare variable values with the clipboard

During debugging, you can compare variable values with the value in the clipboard. This may be especially helpful when debugging strings.

  1. In the Variables pane of the Debug window, select the desired variable.

  2. Right-click the variable and choose Compare Value with Clipboard from the context menu.

The comparison result will be displayed in the Differences viewer.

Last modified: 09 September 2020