views:

46

answers:

1

There are two problems with [DebuggerBrowsable]. First, it needs to be on all your fields. And second, if your using auto properties, you don't have fields.

Is there any way to (temporarily) get the debugger to only show public properties, or atleast hide the auto-generated backing field of c#'s auto properties? I'm probably dreaming, but maybe even group them like the class diagram tool?

A: 

Not sure why you'd want to do this, allowing the debugger to peek at your private parts can be pretty important while debugging. Short from overriding the ToString() method, consider using the [DebuggerVisualizer] attribute instead. Quite handy to present a birds-eye view of the object state and still allowing to drill in to the privates when you need to.

Hans Passant
And I agree, however when you have data objects with dozens of fields seeing `<whatever>k__BackingField` everywhere makes it harder to see/find the one you care about. And splattering attribute tags all over your data objects makes them equally hard to work with.
Josh Sterling
Well, that's exactly why [DebuggerVisualizer] is there. You apply it to the class, not each individual member.
Hans Passant
I checked c# express 2008 at home and it's showing properties as just properties (the implicit backing field is not shown) So I guess this wasn't the right question for me to ask. In relation to this question this [DebuggerVisualiser] is probably the right answer.
Josh Sterling