You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Check what you learned about debugging in Visual Studio.
7
7
author: alexwolfmsft
8
8
ms.author: alexwolf
9
9
manager: jmartens
@@ -33,36 +33,36 @@ quiz:
33
33
choices:
34
34
- content: '`Debug.Assert(count != 0, "Count should not be 0.");`'
35
35
isCorrect: false
36
-
explanation: "Assert tests a condition. If it's true, nothing will happen or else the application will enter break mode. So here, if the count is 0, it will enter break mode."
36
+
explanation: "Assert tests a condition. If it's true, nothing happens or else the application enters break mode. So here, if the count is 0, it enters break mode."
37
37
- content: '`Debug.Assert(count == 0, "Count should not be 0.");`'
38
38
isCorrect: false
39
-
explanation: "Assert tests a condition. If it's true, nothing will happen or else the application will enter break mode. So here, if the count is 0, nothing will happen."
39
+
explanation: "Assert tests a condition. If it's true, nothing happens or else the application enters break mode. So here, if the count is 0, nothing happens."
40
40
- content: '`Debug.WriteIf(count != 0, "Count should not be 0.");`'
41
41
isCorrect: false
42
42
explanation: "This code prints a message when the count doesn't equal 0."
43
43
- content: '`Debug.WriteIf(count == 0, "Count should not be 0.");`'
44
44
isCorrect: true
45
-
explanation: "This code will only print a debug message when the count is 0."
45
+
explanation: "This code only prints a debug message when the count is 0."
46
46
- content: "What are the top two values a debugger provides?"
47
47
choices:
48
48
- content: "Control of your program execution and observation of your program's state"
49
49
isCorrect: true
50
50
explanation: "The two main values almost every debugger provides are the ability to control program execution and to observe program state."
51
-
- content: "Modifying program values and changing your program output"
51
+
- content: "Modifying program values and changing your program output."
52
52
isCorrect: false
53
-
explanation: "Changing your program's output isn't useful because it will only have effect when the application is being debugged."
54
-
- content: "Observing your program's state and modifying your program values"
53
+
explanation: "Changing your program's output isn't useful because it only has effect when the application is being debugged."
54
+
- content: "Observing your program's state and modifying your program values."
55
55
isCorrect: false
56
56
explanation: "Observing and modifying values are important, but it's also important to be able to control the flow of program execution."
57
-
- content: "Editing your program while running and editing program values"
57
+
- content: "Editing your program while running and editing program values."
58
58
isCorrect: false
59
59
explanation: "Editing programs is useful, but observing your program's operational state is another important value that the .NET debugger provides."
60
60
- content: "Which Visual Studio debugger window is most useful to observe the current value of a specific variable across different functions?"
61
61
choices:
62
62
- content: "Use the Locals window because it shows all variables that are currently in scope."
63
63
isCorrect: false
64
64
explanation: "While the Locals window does display all variables currently in scope, it's not the best way to watch the value of a specific variable."
65
-
- content: "Hover over the variable in the code editor to display the value."
65
+
- content: "Display the value by hovering over the variable in the code editor."
66
66
isCorrect: false
67
67
explanation: "While hovering does display the variable's current value, it's a manual process and isn't efficient."
68
68
- content: "Use the Watch window to select specific variables or expressions to watch throughout the program's execution."
Visual Studio provides very powerful tools to help you debug and diagnose issues in your applications. These tools are especially valuable for analyzing state and tracking down bugs while your application is running.
1
+
Visual Studio provides powerful tools to help you debug and diagnose issues in your applications. These tools are especially valuable for analyzing state and tracking down bugs while your application is running.
2
2
3
3
:::image source="../media/visual-studio-tools.png" alt-text="Screenshot of Visual Studio debugging tools.":::
4
4
5
-
## Fix Bugs Before the Application Launches
5
+
## Fix bugs before the application launches
6
6
7
-
Suppose that you work for a team that's building a new application, but you keep finding bugs in the code. The team would like to find and fix all of these issues before the app goes live. However, the issues are too subtle or complex to diagnose just by reading the code. You're looking for additional tools and assistance to track down problems while the app is running with different inputs and parameters.
7
+
Suppose that you work for a team that's building a new application, but you keep finding bugs in the code. The team would like to find and fix all of these issues before the app goes live. However, the issues are too subtle or complex to diagnose just by reading the code. You're looking for tools to assist you in tracking down problems while the app is running with different inputs and parameters.
8
8
9
-
## What will we be doing?
9
+
## What are you going to do?
10
10
11
-
This module shows you how to use the Visual Studio debugger with a .NET program. You'll learn how to leverage common features like break points and step through your code line by line. You'll also learn how to inspect the state of your program as it executesusing tools like the Watch and Locals windows. Finally, you'll also use diagnostic features like the Call Stack and Traces to review code execution in greater depth.
11
+
This module shows you how to use the Visual Studio debugger with a .NET program. You learn how to use common features like break points and how to step through your code line by line. You also learn how to inspect the state of your program as it executes, by using tools like the Watch and Locals windows. Finally, you learn how to use diagnostic features like the Call Stack and Traces to review code execution in greater depth.
12
12
13
13
:::image source="../media/visual-studio-intro.png" alt-text="Screenshot of Visual Studio debugging in action.":::
14
14
15
15
## What's the main goal?
16
16
17
-
By the end of this module, you'll understand how to use Visual Studio's debugging tools to analyze and fix issues in your application code.
17
+
By the end of this module, you understand how to use Visual Studio's debugging tools to analyze and fix issues in your application code.
Copy file name to clipboardExpand all lines: learn-pr/language/dotnet-debug-visual-studio/includes/2-debugger.md
+9-11Lines changed: 9 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,31 +2,29 @@ During your journey as a developer, there's always *that* moment when you end up
2
2
3
3
> Why isn't my code working?
4
4
5
-
Asking this question is a normal part of any developer's day. The trick is to get comfortable with finding and fixing your bugs with a minimum of time and frustration. When there's a bug in your program, everyone usually has their own way of dealing with this problem.
5
+
Asking this question is a normal part of any developer's day. The trick is to get comfortable with finding and fixing your bugs with a minimum of time and frustration. When there's a bug in your program, do you deal with it in one of these ways?
6
6
7
-
You probably already have tried one or more of these debugging approaches yourself:
8
-
9
-
- Try running your program again because it *should* work.
7
+
- Run the program again because it *should* work.
10
8
- Explain your issue to a rubber duck.
11
-
- Read through your code again to find out the issue.
9
+
- Read through your code again to find the issue.
12
10
- Take a walk outside.
13
11
- Spam a few `Console.WriteLine("here")` messages in your code.
14
12
15
-
You might have various degrees of success with these methods. The one approach that's commonly regarded as being more often successful is using a debugger. But what's a debugger exactly?
13
+
You might have various degrees of success with these methods, but one approach is commonly regarded as being the most successful. Using a debugger. But what exactly is a debugger?
16
14
17
-
A debugger is a software tool you can use to observe and control the execution flow of your program with an analytical approach. Its design goal is to help find the root cause of a bug and help you resolve it. It works by either hosting your program in its own execution process or running as a separate process that's attached to your running program, like .NET.
15
+
A debugger is a software tool you can use to observe and control the execution flow of your program with an analytical approach. Its design goal is to help you find the root cause of a bug and help you resolve it. It works by hosting your program in its own execution process. Or, by running as a separate process attached to your program, like .NET.
18
16
19
-
Debuggers come in different flavors. Some work directly from the command line while others come with a graphical user interface. In this module, we'll use Visual Studio's integrated graphical debugger.
17
+
Debuggers come in different flavors. Some work directly from the command line while others come with a graphical user interface. In this module, we use Visual Studio's integrated graphical debugger.
20
18
21
19
## Why use a debugger?
22
20
23
-
If you're not running your code through a debugger, that means you're probably *guessing* what's happening in your program. The primary benefit of using a debugger is that you can *watch* your program running. You can follow your program execution one line of code at a time. In this way, you avoid the chance of guessing wrong.
21
+
If you're not running your code through a debugger, it means you're probably *guessing* what's happening in your program. The primary benefit of using a debugger is that you can *watch* your program running. You can follow your program execution one line of code at a time. In this way, you avoid the chance of guessing wrong.
24
22
25
23
Every debugger has its own set of features. The two most important ones that come with almost all of them are:
26
24
27
-
-*Controlling your program execution*. You can pause your program and run it step by step, which allows you to see which code is executed and how it affects your program's state.
25
+
-*Controlling your program execution*. You can pause your program and run it step by step, which allows you to see which code is executing and how it affects your program's state.
28
26
-*Observing of your program's state*. For example, you can look at the value of your variables and function parameters at any point during your code execution.
29
27
30
-
Mastering debugger usage is an important skill for a developer that's often overlooked. It makes you more efficient at hunting bugs in your code and can help you quickly understand how a program works.
28
+
Using a debugger effectively is an important but overlooked skill for a developer. It makes you more efficient at hunting bugs in your code and can help you quickly understand how a program works.
0 commit comments