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
Copy file name to clipboardExpand all lines: docs/code-quality/code-metrics-cyclomatic-complexity.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: Code metrics - Cyclomatic complexity
3
-
ms.date: 5/7/2021
3
+
ms.date: 12/10/2024
4
4
description: Explore the cyclomatic complexity metric for code metrics in Visual Studio and estimate the difficulty to test, maintain, and troubleshoot your code.
5
5
ms.topic: conceptual
6
6
author: mikejo5000
@@ -25,33 +25,33 @@ Notice the cyclomatic complexity is at 2 (the lowest value possible). If you add
25
25
26
26

27
27
28
-
If you add a decision, the cyclomatic complexity value goes up by 1:
28
+
If you add a decision, the cyclomatic complexity value goes up by one:
29
29
30
30

31
31
32
-
When you change the if statement to a switch statement with 4 decisions to be made then, it goes from the original 2 to 6:
32
+
When you change the if statement to a switch statement with four decisions to be made then, it goes from the original two to six:
33
33
34
34

35
35
36
36
Let's take a look at a (hypothetical) larger code base.
37
37
38
38

39
39
40
-
Notice that most of the items, as you drill down into the Products_Related class, have a value of 1 but a couple of them have a complexity of 5. By itself, this might not be a big deal, but given that most other members have a 1 in the same class, you should definitely look closer at those two items and see what is in them. You can do this by right-clicking the item and choosing **Go To Source Code** from the context menu. Take a closer look at `Product.set(Product)`:
40
+
Notice that most of the items, as you drill down into the Products_Related class, have a value of one but a couple of them have a complexity of five. By itself, this difference might not be a big deal, but given that most other members have a one in the same class, you should definitely look closer at those two items and see what is in them. You can do take a closer look by right-clicking the item and choosing **Go To Source Code** from the context menu. Take a closer look at `Product.set(Product)`:
41
41
42
42

43
43
44
-
Given all the if statements, you can see why the cyclomatic complexity is at a 5. At this point, you might decide that this is an acceptable level of complexity, or you might refactor to reduce the complexity.
44
+
Given all the if statements, you can see why the cyclomatic complexity is at a five. At this point, you might decide that this result is an acceptable level of complexity, or you might refactor to reduce the complexity.
45
45
46
46
## The Magic Number
47
47
48
-
As with many metrics in this industry, there is no exact cyclomatic complexity limit that fits all organizations. However, [NIST235](#nist235) does indicate that a limit of 10 is a good starting point:
48
+
As with many metrics in this industry, there's no exact cyclomatic complexity limit that fits all organizations. However, [NIST235](#nist235) does indicate that a limit of 10 is a good starting point:
49
49
50
-
"The precise number to use as a limit, however, remains somewhat controversial. The original limit of 10 as proposed by McCabe has significant supporting evidence, but limits as high as 15 have been used successfully as well. Limits over 10 should be reserved for projects that have several operational advantages over typical projects, for example experienced staff, formal design, a modern programming language, structured programming, code walkthroughs, and a comprehensive test plan. In other words, an organization can pick a complexity limit greater than 10, but only if it is sure it knows what it is doing and is willing to devote the additional testing effort required by more complex modules." [NIST235](#nist235)
50
+
"The precise number to use as a limit, however, remains somewhat controversial. The original limit of 10 as proposed by McCabe has significant supporting evidence, but limits as high as 15 have been used successfully as well. Limits over 10 should be reserved for projects that have several operational advantages over typical projects, for example experienced staff, formal design, a modern programming language, structured programming, code walkthroughs, and a comprehensive test plan. In other words, an organization can pick a complexity limit greater than 10, but only if it's sure it knows what it's doing and is willing to devote the additional testing effort required by more complex modules." [NIST235](#nist235)
51
51
52
52
## Cyclomatic Complexity and Line Numbers
53
53
54
-
Just looking at the number of lines of code by itself is, at best, a very broad predictor of code quality. There is some basic truth to the idea that the more lines of code in a function, the more likely it is to have errors. However, when you combine cyclomatic complexity with lines of code, then you have a much clearer picture of the potential for errors.
54
+
Just looking at the number of lines of code by itself is, at best, a very broad predictor of code quality. There's some basic truth to the idea that the more lines of code in a function, the more likely it's to have errors. However, when you combine cyclomatic complexity with lines of code, then you have a much clearer picture of the potential for errors.
55
55
56
56
As described by the Software Assurance Technology Center (SATC) at NASA:
Copy file name to clipboardExpand all lines: docs/containers/deploy-app-service.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,8 @@ ms.author: ghogen
14
14
15
15
This tutorial walks you through using Visual Studio to publish your containerized ASP.NET Core web application to an [Azure App Service](/azure/app-service). Azure App Service is an appropriate service for a single-container web app hosted in Azure.
16
16
17
+
You can also deploy to [Azure Container Apps](/azure/container-apps/overview). For a tutorial, see [Deploy to Azure Container Apps using Visual Studio](/azure/container-apps/deploy-visual-studio).
18
+
17
19
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/dotnet/?utm_source=acr-publish-doc&utm_medium=docs&utm_campaign=docs) before you begin.
Copy file name to clipboardExpand all lines: docs/containers/launch-profiles.md
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,14 @@ manager: mijacobs
6
6
ms.subservice: container-tools
7
7
ms.devlang: dotnet
8
8
ms.topic: how-to
9
-
ms.date: 10/08/2021
9
+
ms.date: 12/10/2024
10
10
ms.author: ghogen
11
11
monikerRange: ">=vs-2019"
12
12
---
13
13
14
14
# Launch a subset of Compose services
15
15
16
-
If you have an application that consists of multiple services and uses Docker Compose, you can configure which services run and debug by creating or editing an existing launch profile in Docker Compose launch settings. Launch profiles allow you to dynamically run only the services that matter to your current scenario. You can create and select from launch profiles in order to customize your debugging experience and set specific launch actions such as `Browser Launch URL`. You will also have the option of either choosing each service individually or by choosing a Docker Compose profile, which also looks at your Compose file to determine the group of services to run.
16
+
If you have an application that consists of multiple services and uses Docker Compose, you can configure which services run and debug by creating or editing an existing launch profile in Docker Compose launch settings. Launch profiles allow you to dynamically run only the services that matter to your current scenario. You can create and select from launch profiles in order to customize your debugging experience and set specific launch actions such as `Browser Launch URL`. You also have the option of either choosing each service individually or by choosing a Docker Compose profile, which also looks at your Compose file to determine the group of services to run.
17
17
18
18
For information about Docker Compose profiles, see [Using profiles with Compose](https://docs.docker.com/compose/profiles/).
19
19
@@ -97,7 +97,7 @@ The next example demonstrates selecting between individual services instead of f
97
97
98
98

99
99
100
-
And this information will be saved in *launchSettings.json* as shown below
100
+
And this information is saved in *launchSettings.json* as shown below
101
101
102
102
```json
103
103
{
@@ -124,14 +124,14 @@ And this information will be saved in *launchSettings.json* as shown below
124
124
125
125
You can also further customize launch behaviors by creating Visual Studio launch profiles that make use of the Compose profiles.
126
126
127
-
To create another profile that makes use of the Compose profile, select **Use Docker Compose profiles** and choose `web1`. Now the launch profile includes three services – `webapplication1` (which belongs to both `web` and `web1` Compose profiles), `external1` and `external2`. By default, the services without source code such as `external1` and `external2` have the default action of **Start without debugging**. .NET applications with source code will default to **Start debugging**.
127
+
To create another profile that makes use of the Compose profile, select **Use Docker Compose profiles** and choose `web1`. Now the launch profile includes three services: `webapplication1` (which belongs to both `web` and `web1` Compose profiles), `external1`, and `external2`. By default, the services without source code such as `external1` and `external2` have the default action of **Start without debugging**. .NET applications with source code defaults to **Start debugging**.
128
128
129
129
> [!IMPORTANT]
130
-
> If a service doesn't specify a Compose profile, it will be included in all Compose profiles implicitly.
130
+
> If a service doesn't specify a Compose profile, it's included in all Compose profiles implicitly.
131
131
132
132

133
133
134
-
This information will be saved as shown in the following code. The configuration for the service and its default action are not saved unless you change the default action.
134
+
This information is saved as shown in the following code. The configuration for the service and its default action are not saved unless you change the default action.
135
135
136
136
```json
137
137
{
@@ -172,7 +172,7 @@ You can also change the action of webapplication1 to **Start without debugging**
172
172
173
173
## Properties
174
174
175
-
Here is a description of each property in the *launchSettings.json*:
175
+
Here's a description of each property in the *launchSettings.json*:
Copy file name to clipboardExpand all lines: docs/debugger/using-breakpoints.md
+14-4Lines changed: 14 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -21,13 +21,15 @@ author: mikejo5000
21
21
ms.author: mikejo
22
22
manager: mijacobs
23
23
ms.subservice: debug-diagnostics
24
+
zone_pivot_groups: programming-languages-set-one
24
25
---
25
26
# Use the right type of breakpoint
26
27
27
28
This article shows how to use different types of breakpoints in Visual Studio to improve debugging efficiency. It covers various scenarios where breakpoints can be applied, such as pausing code execution, logging information, and tracking changes in variable states. The article explains how to set conditional breakpoints, tracepoints, data breakpoints, dependent breakpoints, and temporary breakpoints. It also includes detailed instructions on setting function breakpoints. This guide is essential for developers looking to leverage breakpoints for effective debugging in Visual Studio.
28
29
29
30
If you're unfamiliar with using breakpoints in Visual Studio, see [Get started with breakpoints](get-started-with-breakpoints.md) before going through this article.
30
-
31
+
32
+
::: zone pivot="programming-language-dotnet,programming-language-dotnetf,programming-language-cpp,programming-language-all"
31
33
## Scenarios
32
34
33
35
The following table shows common debugging scenarios for breakpoints and the recommended breakpoint type for the scenario.
@@ -43,6 +45,7 @@ The following table shows common debugging scenarios for breakpoints and the rec
43
45
| Can I pause code inside a loop at a certain iteration? | Set a Dependent breakpoint that breaks execution only if another breakpoint is first hit. For more information, see [Hit count](#set-a-hit-count-condition). |
44
46
| Can I pause code at the start of a function when I know the function name but not its location? | You can do this with a function breakpoint. For more information, see [Set function breakpoints](#BKMK_Set_a_breakpoint_in_a_source_file). |
45
47
| Can I pause code at the start of multiple functions with the same name? | When you have multiple functions with the same name (overloaded functions or functions in different projects), you can use a [function breakpoint](#BKMK_Set_a_breakpoint_in_a_source_file). |
48
+
::: zone-end
46
49
47
50
## <aname="BKMK_Print_to_the_Output_window_with_tracepoints"></a> Breakpoint actions and tracepoints
48
51
@@ -103,6 +106,7 @@ If you set a breakpoint condition with invalid syntax, a warning message appears
103
106
>[!NOTE]
104
107
> For the **When changed** field, the debugger doesn't consider the first evaluation of the condition to be a change, so doesn't hit the breakpoint on the first evaluation.
105
108
109
+
::: zone pivot="programming-language-dotnet,programming-language-dotnetf"
106
110
### <aname="using-object-ids-in-breakpoint-conditions-c-and-f"></a> Use Object IDs in conditional expressions (C# and F# only)
107
111
108
112
There are times when you want to observe the behavior of a specific object. For example, you might want to find out why an object was inserted into a collection more than once. In C# and F#, you can create object IDs for specific instances of [reference types](/dotnet/csharp/language-reference/keywords/reference-types), and use them in breakpoint conditions. The object ID is generated by the common language runtime (CLR) debugging services and associated with the object.
@@ -127,6 +131,7 @@ If you set a breakpoint condition with invalid syntax, a warning message appears
127
131
128
132
> [!NOTE]
129
133
> Object IDs create weak references, and do not prevent the object from being garbage collected. They are valid only for the current debugging session.
134
+
::: zone-end
130
135
131
136
### Set a hit count condition
132
137
@@ -191,6 +196,7 @@ You can break execution when a function is called. This is useful, for example,
191
196
192
197
1. Select **OK**.
193
198
199
+
::: zone pivot="programming-language-cpp"
194
200
### Set a function breakpoint using a memory address (native C++ only)
195
201
196
202
You can use the address of an object to set a function breakpoint on a method called by a specific instance of a class. For example, given an addressable object of type `my_class`, you can set a function breakpoint on the `my_method` method that instance calls.
@@ -206,9 +212,10 @@ You can break execution when a function is called. This is useful, for example,
206
212
```cpp
207
213
((my_class *) 0xcccccccc)->my_method
208
214
```
209
-
215
+
::: zone-end
210
216
::: moniker range=">= vs-2019"
211
217
218
+
::: zone pivot="programming-language-dotnet"
212
219
## <aname="BKMK_set_a_data_breakpoint_managed"></a>Set data breakpoints (.NET Core 3.x or .NET 5+)
213
220
214
221
Data breakpoints break execution when a specific object's property changes.
@@ -229,9 +236,10 @@ Data breakpoints for .NET Core and .NET 5+ won't work for:
229
236
- Fields inside of structs
230
237
231
238
For the maximum number that you can set, see [Data breakpoint hardware limits](#data-breakpoint-hardware-limits).
232
-
239
+
::: zone-end
233
240
::: moniker-end
234
241
242
+
::: zone pivot="programming-language-cpp"
235
243
## <aname="BKMK_set_a_data_breakpoint_native_cplusplus"></a>Set data breakpoints (native C++ only)
236
244
237
245
Data breakpoints break execution when a value stored at a specified memory address changes. If the value is read but not changed, execution doesn't break.
@@ -256,7 +264,9 @@ Data breakpoints don't work under the following conditions:
256
264
> - Data breakpoints depend on specific memory addresses. The address of a variable changes from one debugging session to the next, so data breakpoints are automatically disabled at the end of each debugging session.
257
265
>
258
266
> - If you set a data breakpoint on a local variable, the breakpoint remains enabled when the function ends, but the memory address is no longer applicable, so the behavior of the breakpoint is unpredictable. If you set a data breakpoint on a local variable, you should delete or disable the breakpoint before the function ends.
267
+
::: zone-end
259
268
269
+
::: zone pivot="programming-language-dotnet,programming-language-cpp"
260
270
## Data breakpoint hardware limits
261
271
262
272
The Windows kernel and the underlying hardware have the following limits when setting data breakpoints. The limit refers to the maximum number of data breakpoints that you can set.
@@ -266,7 +276,7 @@ The Windows kernel and the underlying hardware have the following limits when se
266
276
|x64 and x86|4|
267
277
|ARM64|2|
268
278
|ARM|1|
269
-
279
+
::: zone-end
270
280
::: moniker range=">= vs-2022"
271
281
## <aname="BKMK_set_a_dependent_breakpoint"></a>Set a dependent breakpoint
Copy file name to clipboardExpand all lines: docs/deployment/deploying-applications-services-and-components-resources.md
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -114,6 +114,18 @@ For more information on publishing to App Service, see:
114
114
-[Publish an ASP.NET Core app to Azure App Service](/aspnet/core/tutorials/publish-to-azure-webapp-using-vs)
115
115
-[Troubleshoot ASP.NET Core on Azure App Service and IIS](/aspnet/core/test/troubleshoot-azure-iis).
116
116
117
+
### Azure WebJobs
118
+
119
+
Azure WebJobs is supported through App Service. See [Develop and deploy WebJobs using Visual Studio](/azure/app-service/webjobs-dotnet-deploy-vs).
120
+
121
+
#### When to choose Azure WebJobs
122
+
123
+
- You have a worker process, a computation that can run without user interaction.
124
+
- The job is on-demand, triggered by an event, or continuous.
125
+
- The job runs on Windows, or .NET Core on Linux (with Visual Studio 17.12 or later).
126
+
127
+
Another option for similar scenarios is Azure Functions. To choose the right option for you, see [Choose the right integration and automation services in Azure](/azure/azure-functions/functions-compare-logic-apps-ms-flow-webjobs).
128
+
117
129
### Azure Container Registry
118
130
119
131
[Azure Container Registry](/azure/container-registry/) allows you to build, store, and manage Docker container images and artifacts in a private registry for all types of container deployments.
0 commit comments