Can I set breakpoints to all methods in a class at once in Visual Studio?

前端 未结 6 1874
盖世英雄少女心
盖世英雄少女心 2020-12-28 13:06

I have 40-50 methods in a class, I want to add breakpoints to all of them. Can I add breakpoints to all of them at once?

6条回答
  •  旧时难觅i
    2020-12-28 13:42

    The accepted answer didn't work for me for some reason. And I don't think my workaround applies to Visual Studio 2010. But I used the Macros for Visual Studio extension with my Visual Studio 2015 to do this.

    Steps:

    1. Find (Ctrl+F) the right indentation for the opening brace of the methods. Typically that is 8 white spaces (or 2 tabs etc. based upon the settings you might've made).
    2. Append this with an opening brace {.
    3. Prepend this with \r\n to make sure it does not match any nested braces. Now it might look like \r\n {. Also, turn on the regular expression search (by pressing the * on the search dialog).
    4. Start recording a macro.
    5. Press F3 and then press F9 to add a breakpoint. This adds a breakpoint to the first method found using the trick.
    6. Stop recording the macro. Play it for the number of method you might have.
    7. Caution: Be aware of when you reach the end. Otherwise it will start again from the top and that start removing the breakpoints you just added.

    Let me know it there is any confusion.

提交回复
热议问题