简体   繁体   中英

Hide null members in Visual Studio watch window

How can I hide null members in watch screen? I don't need that.

Below is an screenshot:

在此处输入图片说明

It doesn't work that way. The inspector is there for you to see all available members . The visibility of the members never has anything to do with the value of the member, null or otherwise. Conceivably you might be able to write a plugin that replaces the inspector in its entirety, to do what you want, but that would be a lot of work.

You can override the ToString on the class to display something that's useful to you. If you don't want to that your best bet might be to use the DebuggerDisplayAttribute attribute to create a DebuggerToString that can be used in the debugger. Have a look at this (MSDN) Enhancing Debugging with the Debugger Display Attributes or (blog) Why override ToString()? Use DebuggerDisplayAttribute instead

You would do this at the class level on your GDicStruct rather than on the properties.

So you could add

[DebuggerDisplayAttribute("{DebuggerToString}")]
public struct GDicStruct
{
    public string DebuggerToString()
    {
        //logic to create debugger string
    }
}

but you have to ask if it's worth the effort.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM