COTW: DebuggerNonUserCodeAttribute Class
The DebuggerNonUserCodeAttribute class allows you to specify classes, structs, constructors, properties, and methods that are not considered “user code”. Using this attribute is the same as applying both DebuggerHiddenAttribute and DebuggerStepThroughAttribute, with one notable exception.
In my previous blog entry about the DebuggerHiddenAttribute, I said
In the tool-tip above, Visual Studio implies that if ‘Just My Code’ was disabled then we would be able to step into class members that have the DebuggerHiddenAttribute. Although, in my tests this was not the case. With ‘Just My Code’ disabled, Visual Studio shows the break point as enabled, but it is never hit and I cannot step into the “hidden” method.
I was referring to the following image, which implies that I should be able to debug items marked with the DebuggerHiddenAttribute:
I found that if ‘Just My Code’ is disabled, then Visual Studio does ignore DebuggerNonUserCodeAttribute (but not DebuggerHiddenAttribute). Therefore, it’s probably better to use the DebuggerNonUserCodeAttribute in most cases, since it can be disabled by the user.
