Wednesday, February 13, 2008

XSD.exe and DebuggerStepThrough

Did you ever try to step into properties of classes generated by XSD.EXE when debugging? It doesn't work, does it? Not even on methods that you might have extended the XSD.EXE's partial classes with!


It is a common practice to generate partial classes from XSD schemas using XSD.EXE, and then extend some of them in another source file.

This all works nice and clean, but XSD.EXE is nasty and decorates all the classes it creates with the DebuggerStepThrough attribute.

That makes the debugger treat not only those parts of the classes that were created by XSD.EXE as 'nondebuggable'; you can't step into you own code (those methods in the class part authored by you), either!

Now, here are three ways to fix this:

  • run a search&replace and get rid of all the DebuggerStepThrough attributes
  • in Visual Studio, go to Tools/Options..., unfold the tree on the left-hand side of the dialog that will appear down to Debugging/General, and then uncheck the box next to 'Enable Just My Code'
    (Note that you will still have to set a breakpoint in the code marked as DebuggerStepThrough, otherwise the debugger will skip over it anyway)
  • stop using XSD.EXE :) (thanks to Marcin for this acute observation)


Well - the choice is yours :)

[see: Disable DebuggerStepThroughAttribute in code generated by xsd.exe?]

 

1 comment:

Michael Freidgeim said...

Issue reported to MS Feedback
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=140627
You can rate/validate it.