从调试器隐藏领域 [英] Hiding fields from the debugger

查看:115
本文介绍了从调试器隐藏领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能隐藏字段和/或属性从显示在调试器监视窗口吗?你看,我们已经有了一个类在这里与50多个私人领域,其中大部分是通过公共属性公开。这意味着,我们看到了大量的监视窗口上市数据的重复。

Is it possible to hide fields and/or properties from showing up in the debugger watch window? See, we've got a class here with over 50 private fields, most of which are exposed through public properties. This means we're seeing a duplication of a large number of data in the watch window listing.

这是控制?

推荐答案

试试这个属性:

 [DebuggerBrowsable(DebuggerBrowsableState.Never)]

使用它通过将上述属性的字段声明像这样隐藏你的后盾领域

Use it to hide your backing fields by placing the attribute above the field declaration like this:

class Foo
{
    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    int bar;  // this one will be hidden
    int baz;  // but this one will be visible like normal
}



记住,在 DebuggerBrowsableState 枚举有另外两名成员:

Keep in mind that the DebuggerBrowsableState enumeration has two other members:

折叠: 折叠元素在调试器

RootHidden: 这显示了一个集合的子元素,但隐藏根元素本身。

Collapsed: Collapses the element in the debugger.
RootHidden: This shows child elements of a collection but hides the root element itself.

这篇关于从调试器隐藏领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆