Home
Options

Hide properties in default Dump() implementation

Is there a way to hide properties in the default Dump() implementation?

I don't want to write a custom dump method nor have to exclude these properties. I don't want these objects to be dumped at all when in a property like this. In this particular case, it's a reference to the parent object that I don't want to display here.

public interface ISomeInterface
{
    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    [DebuggerHidden]
    IParent Parent { get; }
    string SomeProperty { get; }
}

It doesn't recognize the [DebuggerBrowsable(DebuggerBrowsableState.Never)] or [DebuggerHidden] attributes it seems. Is there another attribute I should use? Can it be updated to recognize these?

Comments

  • Options

    The DebuggerBrowsable attribute isn't a great fit because it would also hide the member from the debugger in Visual Studio which isn't always what you'd want.

    DebuggerHidden instructs the IDE to skip over the member when stepping, which could be an undesirable side-effect. Also, where that attribute has already been applied to members, LINQPad would stop displaying that member which would be a breaking change, as well as potentially undesirable.

    Have you considered adding the following method to the type whose Dump behavior you wish to customize?

    object ToDump() => Util.ToExpando (this, exclude:"Parent");
    
  • Options

    I'm working on an external general purpose library and using LINQPad to test it out and don't want to add LINQPad-specific methods. I want to keep it free of any extra fluff. I was just trying the attributes to see if I'd see any change.

    I suppose implementing a static dump method to handle that type would have to do for now.

  • Options

    I forgot to mention, the source code for ToExpando is here, so that you don't have to take a dependency on LINQPad.Runtime.

Sign In or Register to comment.