After looking at the "Using DebuggerDisplay Attribute" article on MSDN, they suggest that you could override the ToString() function of your class as an alternate option rather than using DebuggerDisplay attribute. Overriding the ToString() method won't hide your beans either.
If a C# object has an overridden
ToString(), the debugger will call the
override and show its result instead
of the standard {}. Thus, if
you have overridden ToString(), you do
not have to use DebuggerDisplay. If
you use both, the DebuggerDisplay
attribute takes precedence over the
ToString() override.
Are you able to override the ToString() method on your class or are you using it for other purposes?
I don't know if you've already considered this or not, but I thought I'd suggest it just incase it helps. :-)
For completeness so anyone else can quickly mock it up; here's a quick example that I made:
namespace StackOverflow
{
//broken BeanPouch class that uses the DebuggerDisplay attribute
[System.Diagnostics.DebuggerDisplay("Count = {Count}")]
class BrokenBeanPouch : List<MagicBean>
{ }
//working BeanPouch class that overrides ToString
class WorkingBeanPouch : List<MagicBean>
{
public override string ToString()
{
return string.Format("Count = {0}", this.Count);
}
}
class Program
{
static WorkingBeanPouch myWorkingBeans = new WorkingBeanPouch()
{
new MagicBean() { Value = 4.99m }, new MagicBean() { Value = 5.99m }, new MagicBean() { Value = 3.99m }
};
static BrokenBeanPouch myBrokenBeans = new BrokenBeanPouch()
{
new MagicBean() { Value = 4.99m }, new MagicBean() { Value = 5.99m }, new MagicBean() { Value = 3.99m }
};
static void Main(string[] args)
{
//break here so we can watch the beans in the watch window
System.Diagnostics.Debugger.Break();
}
}
class MagicBean
{
public decimal Value { get; set; }
}
}