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!!");
    }

  }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值