DebuggerDisplay attribute does not work as expected!

Posted by mark on Stack Overflow See other posts from Stack Overflow or by mark
Published on 2009-08-19T19:08:29Z Indexed on 2010/03/16 7:46 UTC
Read the original article Hit count: 287

Dear ladies and sirs.

I know that this attribute should work in C# and yet, in my case it does not. I have a class with a lazy property Children. Accessing this property may have a side effect of roundtripping to the server. So, naturally, I do not want this to happen when I just watch it in the debugger watch window.

Omitting all the irrelevant details the source looks pretty ordinary:

[DebuggerDisplay("(Frozen) {m_children}")]
public IList<IEntityBase> Children
{
  get
  {
    if (m_children == null)
    {
      m_children = FetchChildrenFromDB(this);
    }
    return m_children;
  }
}

And yet, when I watch the object and expand this in the watch window I do not see (Frozen) in the display, meaning the debugger simply ignores the attribute.

Provided the image link is still valid it should be visible below: http://i28.tinypic.com/2zxo9s5.jpg DebuggerDisplay image snapshot

The attribute is really there, according to Reflector. I use VS2008.

Any ideas?

© Stack Overflow or respective owner

Related posts about debugger

Related posts about visual-studio-2008