C# - some debugger aid and tricks

you can employe some tricks or employ some aids that helps you effecient at the C# debugger, generally with the smart tricks or aids, you want to 

  1. help debugger to print more useful information
  2. hide some unncessary details from the user. 

it is meant to be a compilation of the tricks, so expect this content to be changed in the future. 

DebuggerNonUserCodeAttribute

check on the MSDN at http://msdn.microsoft.com/en-us/library/system.diagnostics.debuggernonusercodeattribute.aspx

and the quote: 

 

msdn 写道
Designer provided types and members that are not part of the code specifically created by the user can complicate the debugging experience. This attribute suppresses the display of these adjunct types and members in the debugger window and automatically steps through, rather than into, designer provided code. When the debugger encounters this attribute when stepping through user code, the user experience is to not see the designer provided code and to step to the next user-supplied code statement.

adjunct: in terms of attribute, it means that types that has been decorated with the attribute.

 Let's seen an example. 

  class Program
  {
    static void Main(string[] args)
    {
      Program p = new Program();
      p.PrivateMethod();
    }


    [System.Diagnostics.DebuggerNonUserCode]
    private void PrivateMethod()
    {
      Console.WriteLine("You can see me, but your debugger cannot stop at me!!");
    }

  }

 

你可能感兴趣的:(C#)