开发者

Hiding private fields without using attributes

开发者 https://www.devze.com 2022-12-30 23:17 出处:网络
There are two problems with [Debu开发者_高级运维ggerBrowsable]. First, itneeds to be on all your fields. And second, if your using auto properties, you don\'t have fields.

There are two problems with [Debu开发者_高级运维ggerBrowsable]. 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号