Is there a way to debug VB.NET With clause in Visual Studio?

后端 未结 2 383
予麋鹿
予麋鹿 2020-12-20 21:17

Sometimes you don\'t really care about the name of a variable, because it does not go outside of your sub\'s scope. In fact, specifying the name would add an extra line of c

相关标签:
2条回答
  • 2020-12-20 22:06

    The With statement with an unnamed variable is a formidable challenge for the debugger, there's no workaround for it. There's just nothing wrong with a small named helper variable like "fsw", it exists anyway, auto-generated by the compiler. Which is not nameless, just unspeakable. Like VB$t_ref$L0), the debugger won't let you type that in since it uses characters that are not valid in VB.NET identifier names. Which is intentional, it ensures it never collides with a name that you used. This also prevents it from showing up in the Autos window.

    You already found the proper workaround by naming the variable. Debugging from there is simple, just hover the mouse over the variable name, not the field name. And of course works well in all the other debugger windows, the Autos window in particular will spring to life. And don't hesitate to drop the With statement in favor of just writing the statement in full, IntelliSense helps a lot to make this less of a chore.

    0 讨论(0)
  • 2020-12-20 22:23

    An option would be to add those variables to the watch list instead, and view the values from the watch window.

    0 讨论(0)
提交回复
热议问题