Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio debugging - Order of local variables?

I am wondering on what concept/logic the ordering of the variables is based on in the 'Locals' tab when debugging an application with MS Visual Studio. For me it seems to be somewhat randomly ordered? Or is there any concept behind the ordering of these variables?

Is there an option to sort these variables alphabetically? This would be very handy.

like image 600
Simon Avatar asked Nov 10 '15 09:11

Simon


People also ask

How do I show local variables in debugging?

Locals While debugging you can enable 'Locals' which will show you all variables in the current stack frame. Go to menu Debug->Windows->Locals to make it appear. Watch Although it is a little manually you also can use 'Watch' you can drag and drop any variable to this window or right click then add to watch.

How do I see variable values in Visual Studio debugging?

Hover over a variable to see its value. When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.

How do I view local variables in Visual Studio?

To open the Locals window, while debugging, select Debug > Windows > Locals, or press Alt+4. This topic applies to Visual Studio on Windows.


1 Answers

In my Visual Studio 2008, the sort order of Locals window is as follows: the current class-level Me object is first, with any module-level variables being sub-nodes of that. Then listed below Me are the procedure-level variables in Alphabetical order. After years of searching, I haven't found any way to change the sort order. The only thing left I can think of is a Visual Studio Extensibility Add-In, but I haven't explored that.

I have a strong background in VBA, and I can tell you over there, if there's a Me object in the current context, that comes first just like Visual Studio. But...and here's the difference...the module-level variables are listed in Declaration Order, meaning they're listed in the same order as their Dim statements. And just like Visual Studio, the order can't be changed.

The VBA way of doing it is much more useful, because you can control the order of the Locals window by re-ordering the Dim statements in the code.

like image 115
spinjector Avatar answered Sep 26 '22 15:09

spinjector