marți, 11 mai 2010

Debugging - Tips& Tricks

Debugging - Tips& Tricks 

  • F10 - Step Over (execute, for example, a method at a time)
  • F11 - Step Into (the debugger will go inside the method)
  • Shift - F11 - Step Out (wthin the current method, the execution will complete and will pause at the next statement from where it called)
  • F5 - continue
  • Ctrl + Shit + F10 - Set Next Statement (set execution path to a new line) - option available on the right click, also
  • Ctrl + * - Show Next Statement
  • Conditional breakpoint - set a condition on the breakpoint when you want it to be reach (Right click on breakpoint -> Condition...)
    • Run a Macro
  • Labeling in Break Point (new feature of VS 2010) - in Breakpoint tabs or on breakpoint in code - right click on breakpoint -> Edit Labels...
  • Import/Export Breakpoints (From Breakpoint tab) - there are saved in XML format
  • Breakpoint Filter
  • Last session breakpoint value (VS2010)

DebuggerDisplayAttribute Class 
  • Determines how a class or field is displayed in the debugger variable windows.
    [DebuggerDisplay("Count = {Count}")] class Stat { public int Count {get; set; } }
  • [DebuggerBrowsable(DebuggerBrowsableState.Never)] - the following DebuggerBrowsableAttribute prevents the property following it // from appearing in the debug window for the class.

Output Window:

Highlighting References [C# 4.0]

  • When you click a symbol in source code, all instances of that symbol are highlighted in the document. To move to the next or previous highlighted symbol, you can use CTRL+SHIFT+DOWN ARROW or CTRL+SHIFT+UP ARROW. For more information, see How to: Use Reference Highlighting.

Watch Windows:
  • Local (Ctrl-Alt-V, L)
  • Autos (Ctrl-Alt-V, A)
  • Watch (Ctrl+D, W)
  • Immediate Window (Ctrl-Alt-I)
  • Call Stack
  • Breakpoints window (Ctrl-Alt-B)
    • Ctrl-Shift-F9 - Clear all breakpoints in the project
    • Ctrl-F9 - Enable/Disable a breakpoint
  • Quick Watch Dialog (Ctrl-Alt-Q)
  • Treads Window
    • Main tread has a green rectangle
  • Processes Dialog (Ctrl-Alt-P)
  • Modules
  • IntelliTrace Window
  • Call Hierarchy window (VS 2010)
    • Call Hierarchy (available in C# and C++) enables you to navigate through your code by displaying all calls to and from a selected method, property, or constructor. 

Niciun comentariu:

Trimiteți un comentariu