Let me remind you that we’re in the model’s CreateTask method, which is called with the value “sleep” in the T_TodoModels.cs VerifyAddTasks test.
Once it's stopped on an instruction, there are two possible choices:
Move down the method code called via Step Into (
F11
) by suspending the execution.Let the debugger execute it, including the calls to sub-functions, using Step Over
(
F10
), and pause once the execution is finished.
Both actions can be accessed from the Visual Studio Debug toolbar:
You can access them directly using the keyboard shortcuts F11
and F10
.
It’s also possible to let the code execute up to a particular instruction. To do this, leave the mouse stationary for a few seconds to make a green symbol appear:
Clicking on this does exactly what we want: it executes the code and suspends execution just before the return.
And what if we want to skip executing InternalAddTask?
Again, leave the mouse in front of the return for a few seconds, and press the Ctrl
key to see a symbol appear. It will be yellow this time:
Right-clicking also gives you access to the two functions Run to Cursor (Ctrl
+ F10
) and Set Next Statement (Ctrl
+ Shift
+ F10
):
Let's recap!
You now have all the means for navigating step-by-step through the execution of the code to:
Go down to a method.
Execute a method.
Execute everything up to an instruction.
Completely skip execution of one part of the code.
With these tools at your disposal, you are now able to find the origin of the bug and fix it. This will be the subject of the final chapter in this part of the course on debugging C# applications. 😉