I have a couple ANTLR-generated code files, and I'm currently happy with how they are working. I'd like to configure my project in Visual Studio (2008) so the debugger skips over methods defined in those files. How can I do this?
views:
49answers:
1
+3
A:
You can attach the DebuggerStepThrough
attribute to properties to make it skip them. You can still set breakpoints in the methods.
[DebuggerStepThrough()]
private void DontDebugMe(string message) {}
....
or
[DebuggerStepThrough()]
public class BuhBye { .. }
I should add that you can also use the DebuggerNonUserCode
attribute and DebuggerHidden
to prevent VS from stepping in at all, or even respecting breakpoints in the code. Doubt you want that, though.
DebuggerNonUserCode
also prevents the property/etc from displaying in the debugger window.
I use the StepThrough one all over the place though, since we compile in 3rd party code's and I don't want to step into their methods when debugging, or go into the container's name resolution/object creation code. Very handy for that.
Andrew Backer
2010-04-15 22:16:15
This is exactly what I need, but unfortunately I can't figure out how to attach this attribute to the classes that ANTLR generates. I'm not sure that I have access to decorate the class with an attribute. I tried applying it to another partial declaration of the class, but it didn't affect the original class file.
Chris Farmer
2010-04-15 22:23:11
The notes I'm seeing on the google seem to say that decorating one part of a partial class should do it for both. The compiler textually combines them, so I don't see why it shouldn't.
Andrew Backer
2010-04-15 22:31:24
Hmmm. I can step into my generated file's constructor but not into methods in my own partial fragment. I will play some more with it.
Chris Farmer
2010-04-15 23:06:40