Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I set a breakpoint in an inline if in Visual Studio and C#?

Can I set a breakpoint like below (the asterisk symbolises the breakpoint dot)?

    var x = ifThis ?
*       This() :
        That() ;

Environment is C# and Visual Studio 2015.

(I just told a colleague that I was possible but seem to stand corrected)

like image 412
LosManos Avatar asked Nov 24 '15 14:11

LosManos


People also ask

Can we Debug inline function?

For Windows 8, the debugger and the Windows compiler have been enhanced so that you can debug optimized code and debug inline functions. The debugger displays parameters and local variables regardless of whether they are stored in registers or on the stack. The debugger also displays inline functions in the call stack.

How do you Debug an inline function?

GDB displays inlined functions just like non-inlined functions. They appear in backtraces. You can view their arguments and local variables, step into them with step , skip them with next , and escape from them with finish . You can check whether a function was inlined by using the info frame command.

How do I Debug code in Visual Studio line by line?

You can also select the line and then select F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert Breakpoint. The breakpoint appears as a red dot in the left margin next to the line of code. The debugger suspends execution just before the line runs.

How do I set a conditional breakpoint in Visual Studio?

Right-click the breakpoint symbol and select Conditions (or press Alt + F9, C). Or hover over the breakpoint symbol, select the Settings icon, and then select Conditions in the Breakpoint Settings window.


1 Answers

You can only place the breakpoint in the whole line.

However, you can:

  1. Press F11 while debugging to enter the line and see which function was hit;

  2. Add a conditional breakpoint so it will only break in the specified conditional; This is the closest to what you want, and have no practical difference on setting the break point on only one part of the expression, other than the full line being marked in VS.

To add a conditional breakpoint, first set the breakpoint, then right click the red dot on the left -> "Condition..."

like image 131
Ortiga Avatar answered Sep 23 '22 01:09

Ortiga