Debugging Tips and Tricks in Visual Studio 2013

​I came across this TechEd video that I found really useful with optimising my debugging with VS2013. My notes on the video are listed below (numbers in square brackets are pointers to the times the subjects of those lines are discussed), but here’s a link to Daniel Moth’s original video:

(in case this is moved, you can grab the video from my public folder)

01. Just My Code added for JavaScript
02. [00.07.00] .NET Framework source stepping (if you turn Just Me Code off, you can step in the various methods of the framework)
03. [00.08.20] Start debugging by stepping into the application with F11 – debug start up issues (don’t need to search for the entry point of the application and place a breakpoint)
04. [00.09.30] Start debugging by running to cursor with CTRL+F10 to execute application to a specific line you want to debug without the need for breakpoints
05. [00.10.40] Data Visualisers (text, xml, html, json is new includes search and tree view of the object model)
06. [00.12.28] CTRL key turns pop ups in VS transparent (intellisense, expanded data visualisers, etc)
07. [00.13.15] Pin stuff all over the place, add comments and export/import DataTips (instead of adding objects to the Watch window, pin them -or, indivisual properties of these objects- by clicking the pin icon at the far right of the expanded visualiser)
08. [00.17.38] Get DataTips from comments, also available to be done on the fly, also supports expression evaluation (hover over a variable name or epression included in a comment and see its actual value)
09. [00.20.56] [DebuggerNonUserCode()] (code to be ignored by the debugger )
10. [00.22.08] Call Stack window, display parameter values (performance impact, but useful)
11. [00.23.40] Move point of execution at debugging time, jump over code, or re-execute code by drag-drop or using “Set Next Statement” Ctrl+Shift+F10. The process state does not initialise! You will need to manually reset values in the DataTip if that’s necessary.
12. [00.25.25] Step Into Specific function when multiple function calls exist in the same line
13. [00.27.05] Autos Window, display return values for all functions you just stepped over (use this to identify which function did not perform as expected, move the execution/breakpoint over the multiple function calls line and then use Step Into Specific)
14. [00.29.50] Start debugging with the Immediate Window
15. [00.30.25] Debugger.Break(); < Breakpoint that always stays in your code. Useful with debugging through the Immediate Window.
16. [00.21.30] Tracepoints (right click Breakpoints, select When Hit, print messages to the output window, use {} to output values)
17. [00.33.38] Change breakpoint location (right click breakpoint, select Location)
18. [00.37.00] Parallel Watch for Multithreaded applications and Recursive methods (add variables to watch across all stack frames)
19. [00.39.30] Run to Cursor to stop execution on return (run to cursor to a calling method to have the debugger stop after it has completed its calls)
20. [00.40.05] Async + Await (debug calls in the Call Stack window – “how did I get here” solved)
21. [00.41.40] Make Object ID, right click on a Local or Watch and click on Make Object ID (keep track of values across execution context, even if variable is out of scope)
22. [00.44.18] Add Watch from inside the Watch window (add first class Watches)
23. [00.45.00] public override string ToString(), override the ToString() method of a class, to do something like return “Title = ” + this.Title;
24. [00.45.25] [DebuggerDisplay(“The answer is {answer}”)] Added attribute to tell the debugger what to display in the Watch window (this is the recommended way to achieve the functionality in 23)
25. [00.46.35] c:\users\user\documents\Visual Studio 2014\Visualizers\autoexp.cs add your own debugger display attributes
26. [00.49.10] Peek Definition Alt+F12 (open an inline mini editor that allows you to edit the definition of a method)
27. [00.50.05] Restart Debugging Alth+Shift+F5 (faster Stop and Start debugging)
28. [00.51.50] Function Breakpoints Ctrl+B, place breakpoints at the entry point of functions. Allows you to add breakpoints to code you do not own (.net framework function)
29. [00.57.25] Full Screen Shift+Alt+Enter (go full screen and add windows you want)
30. [00.58.20] Debug location (tells you where you are when debugging – process, thread, stack frame)
31. [00.58.28] Multithreaded Debugging (Show threads in source, Parallel Stacks -show all the threads that have calls stacks, Parallel Watch -shows all the threads that are in the current function (useful to compare data), .AsParallel() this is parallel Linq, Conditional Breakpoints, Switch to Thread, Flag threads, Run Flagged Threads To Cursor -useful to execute all threads until a specific line and then break execution to compare state, Freeze – freezes specific thread so that all others continue execution while this one is frozen, Thaw – unfreezes frozen threads, Filter breakpoints based on Thread Characteristics)
32. [01.07.00] Tasks Window (displays async operations in flight – what else is happening that hasn’t completed yet)
33. [01.08.33] Pseudo-variables (in the Watch window, dollar and characters adds a pseudo variable like $user)
34. [01.09.15] Format Specifiers per Expression (in the Watch window, add a comma next to the property name to format the value output in the Watch window. d=decimal, h=hexadecimal, nq=no quotes, ac=force expression evaluation (i.e. you don’t need to click on the refresh icon to get the object), hidden=displays all public and non-public members, raw=displays item in raw item mode, results=used with IEnumerables to display the result of a query expression)
35. [01.10.20] Debug JavaScript Store Apps (right click project, select properties, under Configuration Properties, in Debugging, select the Debugger Type to Native with Script)
36. [01.12.20] Sound when breakpoint is hit (if it takes long to hit a breakpoint, you can setup your Windows Sound configuration to sound off when breakpoints are hit)

MGR: the Intelogist

About MGR: the Intelogist

SharePoint Server developer, turned Sitefinity developer, turned Angular developer, turned SharePoint Online consultant, turned Unily consultant, turned O365 consultant... Never a dull moment!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

This site uses Akismet to reduce spam. Learn how your comment data is processed.