Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set breakpoints to all lines in a c# file in visual studio?

I am working with Visual Studio 2015.

I have a big c# class file with lot of properties and methods. I want to set breakpoints to all possible lines (set and get of properties, methods) at once. How can I do that?

like image 512
srh Avatar asked Apr 05 '17 17:04

srh


People also ask

Is there a way to add breakpoints to every line?

I don't think that there's a method to add normal vs breakpoints to every single line though, due to the fact that it's quite useless, considering that you normally just step through the code with F11. 1) Add a break point on the first line of code you want to debug. 2) Run the application.

How do you highlight all breakpoints in C++?

In C# code, breakpoint and current execution lines are automatically highlighted. For C++ code, you can turn on highlighting of breakpoint and current lines by selecting Tools (or Debug) > Options > Debugging > Highlight entire source line for breakpoints and current statement (C++ only).

What are breakpoints in C++?

Breakpoints can be simple (for example, suspending the program on reaching some line of code) or involve more complex logic (checking against additional conditions, writing log messages, and so on). Once set, a breakpoint remains in your project until you remove it explicitly, except for temporary breakpoints ).

How do you set a breakpoint in a for loop?

For example, in the following C# code, you could set a breakpoint on the line of code with the variable assignment ( int testInt = 1 ), the for loop, or any code inside the for loop. You can't set a breakpoint on method signatures, declarations for a namespace or class, or variable declarations if there's no assignment and no getter/setter.


2 Answers

You could add Debugger.Break() on the end of every single line. Therefore you could use the search and replace function of visual studio and replace \n with Debugger.Break()\n (Remember activating the regular expression option). This would cause the debugger to break at every single line, even though you won't have an indicated breakpoint.

I don't think that there's a method to add normal vs breakpoints to every single line though, due to the fact that it's quite useless, considering that you normally just step through the code with F11.

like image 159
MetaColon Avatar answered Oct 11 '22 01:10

MetaColon


I think you are looking for this,

steps to follow:

1) Add a break point on the first line of code you want to debug.

2) Run the application.

3) When you want to run the next line of code, Select Debug | Step Into

4) Repeat step #3 for each line of the code

like image 41
Sajeetharan Avatar answered Oct 11 '22 03:10

Sajeetharan