Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flatten inherited members in Visual Studio's Watch window?

Tags:

Is there some way to make the Watch window display all inherited properties and fields in one long flat list, rather than hidden behind a nested "base" node?

I'm debugging some C# code that makes massive use of inheritance - some of the properties I want to watch are behind three levels of "base" in the Watch window. This would be more or less bearable if I just wanted to examine a single such object, but I'm actually looking at a tree of them...

like image 820
Roman Starkov Avatar asked Feb 17 '10 13:02

Roman Starkov


People also ask

How can you update out of date values in the watch window?

Refresh watch values A refresh icon (circular arrow) might appear in the Watch window when an expression is evaluated. The refresh icon indicates an error or a value that is out of date. To refresh the value, select the refresh icon, or press the spacebar.

How do I use Quick Watch code in Visual Studio?

One helpful tool for when the debugger pauses our program is the 'QuickWatch' window. We open that window with the Shift + F9 key combination or with the 'QuickWatch' option from the right-click menu in the code editor.


1 Answers

see http://blogs.msdn.com/b/jaredpar/archive/2010/02/19/flattening-class-hierarchies-when-debugging-c.aspx

UPDATE: I wrote a commercial tool called OzCode that solves this problem. The idea is that if you're interested in a property of the base class, you can "Star" that property, which causes the property to appear at the top of members list, and also in the text of its parent.

So for example, in the following scenario, I had to expand two base nodes to get to see the properties I wanted, "Important" and "Interesting": No Stars

But once I star these properties, they will always appear at the top, even when viewing variables of the Derived type, so I'll see:

After adding stars

These stars are persisted and will be shown whenever you view a an object of that type in the DataTip or QuickWatch window from that moment on, so the next time you a variable of that type, you won't need to expand those "base" nodes. And because starred values appear as the parent node's text, if you're looking at a tree datastructure of these heavily nested objects (as you stated you were), you will be able to see these properties without even expanding the nodes at all.

FULL DISCLOSURE: I'm the co-author of the tool I've described here.

like image 69
Omer Raviv Avatar answered Nov 03 '22 23:11

Omer Raviv