Infosys Microsoft Alliance and Solutions blog

« Windows 7 | Main | WPF - Displaying enums in ComboBox control »

Hiding from Debugger

When writing trivial get/set type properties, I have seen many developers still struggle during debugging since if they do a step into (typically F11), they end up going into the getter and setter methods as well.

Debugger related attributes have been available since early times, but somehow people seem unaware. Typically one can use DebuggerHidden or DebuggerStepThrough attributes, as shown in the following code snippet.

        public int MyIntProperty



            get { return myVar; }


            set { myVar = value; }


This functionality has been further simplified in VS 2008 by virtue of a setting that by default is set to step over properties and operators. See the figure below (VS - Tools - Options).


The issue with this however is that it works globally so if for some properties one wishes to step into and for some one doesn't, this setting will not help and one needs to revert back to using the specific attributes.

An interesting benefit of using the automatic property feature, added with C# 3.5, is that the debugger automatically steps over such property declarations.

        public int MyIntProperty { get; set; }

So apart from making the code concise and one having to think of less variable names, one can also get this side benefit of debugger step through without having to assign any attributes or enabling the setting in VS tools options dialog.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Please key in the two words you see in the box to validate your identity as an authentic user and reduce spam.

Subscribe to this blog's feed

Follow us on

Blogger Profiles

Infosys on Twitter