Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid watch list variable to collapse on value change in Visual studio?

I would like to avoid that the watch window collapse my list variable content on value change during the process of my application in debug mode. I don't know if i'm really clear, see pictures below:

Collapsed:

enter image description here

Expended:

enter image description here

I would like to see the content of my list and let the content of my list expanded even if a string of my list change. Is there a way to lock the watch window?

like image 498
Émile Pettersen-Coulombe Avatar asked Aug 25 '16 14:08

Émile Pettersen-Coulombe


People also ask

How do I enable expand collapse in Visual Studio?

CTRL + M + M will collapse/expand the current section.

How do I add quick watch to Visual Studio?

Right-click on a variable choose “Add Watch” in the context menu. Right-click on a variable in the DataTip and choose “Add Watch” “Add Watch” button from QuickWatch.

How do you break a variable change in Visual Studio?

In fact, you can now right-click a variable name in the Local window and then select Break When Value Changes (see Figure 58). Visual Studio will automatically track your variable, and it will break the application execution when the variable value changes.


1 Answers

As @JasonH mentioned, list will stay expanded while variable references same object and watch will show modified element in red color. List will collapse when you assign new reference to a variable. I am not aware of any option to change this behavior.

As an alternative, you can pin items in a list you are interested in. Or you can pin all items. In this you will get list expanded event if reference changes. But It will be available only in this concrete tab. Here is an example and picture of each step:

var ints = new [] {"1", "2", "3", "4"};
ints[1] = "3";
ints = new[] { "1" };

Step 1 Step 2 Step 3

like image 100
Andrii Litvinov Avatar answered Sep 28 '22 06:09

Andrii Litvinov