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/annotating-locking-behavior.md
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -100,6 +100,19 @@ To avoid concurrency bugs in your multithreaded program, always follow an approp
100
100
|`_Interlocked_operand_`|The annotated function parameter is the target operand of one of the various Interlocked functions. Those operands must have specific additional properties.|
101
101
|`_Write_guarded_by_(expr)`|Annotates a variable and indicates that whenever the variable is modified, the lock count of the lock object that's named by `expr` is at least one.|
102
102
103
+
104
+
## Smart Lock and RAII Annotations
105
+
Smart locks typically wrap native locks and manage their lifetime. The following table lists annotations that can be used with smart locks and RAII coding patterns with support for `move` semantics.
106
+
107
+
|Annotation|Description|
108
+
|----------------|-----------------|
109
+
|`_Analysis_assume_smart_lock_acquired_`|Tells the analyzer to assume that a smart lock has been acquired. This annotation expects a reference lock type as its parameter.|
110
+
|`_Analysis_assume_smart_lock_released_`|Tells the analyzer to assume that a smart lock has been released. This annotation expects a reference lock type as its parameter.|
111
+
|`_Moves_lock_(target, source)`|Describes `move constructor` operation which transfers lock state from the `source` object to the `target`. The `target` is considered a newly constructed object, so any state it had before is lost and replaced by the `source` state. The `source` is also reset to a clean state with no lock counts or aliasing target, but aliases pointing to it remain unchanged.|
112
+
|`_Replaces_lock_(target, source)`|Describes `move assignment operator` semantics where the target lock is released before transferring the state from the source. This can be regarded as a combination of `_Moves_lock_(target, source)` preceded by a `_Releases_lock_(target)`.|
113
+
|`_Swaps_locks_(left, right)`|Describes the standard `swap` behavior which assumes that objects `left` and `right` exchange their state. The state exchanged includes lock count and aliasing target, if present. Aliases that point to the `left` and `right` objects remain unchanged.|
114
+
|`_Detaches_lock_(detached, lock)`|Describes a scenario in which a lock wrapper type allows dissociation with its contained resource. This is similar to how `std::unique_ptr` works with its internal pointer: it allows programmers to extract the pointer and leave its smart pointer container in a clean state. Similar logic is supported by `std::unique_lock` and can be implemented in custom lock wrappers. The detached lock retains its state (lock count and aliasing target, if any), while the wrapper is reset to contain zero lock count and no aliasing target, while retaining its own aliases. There's no operation on lock counts (releasing and acquiring). This annotation behaves exactly as `_Moves_lock_` except that the detached argument should be `return` rather than `this`.|
115
+
103
116
## See Also
104
117
105
118
-[Using SAL Annotations to Reduce C/C++ Code Defects](../code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects.md)
Copy file name to clipboardExpand all lines: docs/code-quality/how-to-generate-code-metrics-data.md
+81-41Lines changed: 81 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -43,46 +43,58 @@ The results are generated and the **Code Metrics Results** window is displayed.
43
43
44
44
## Command-line code metrics
45
45
46
-
You can generate code metrics data from the command line for C# and Visual Basic projects for .NET Framework, .NET Core, and .NET Standard apps. The command line code metrics tools is called *Metrics.exe*.
46
+
You can generate code metrics data from the command line for C# and Visual Basic projects for .NET Framework, .NET Core, and .NET Standard apps. To run code metrics from the command line, install the [Microsoft.CodeAnalysis.Metrics NuGet package](#microsoftcodeanalysismetrics-nuget-package) or build the [Metrics.exe](#metricsexe) executable yourself.
47
47
48
-
To obtain the *Metrics.exe* executable, you must [generate it yourself](#generate-the-executable). In the near future, a [published version of *Metrics.exe* will be available](https://github.com/dotnet/roslyn-analyzers/issues/1756) so you don't have to build it yourself.
48
+
### Microsoft.CodeAnalysis.Metrics NuGet package
49
49
50
-
### Generate the executable
50
+
The easiest way to generate code metrics data from the command line is by installing the [Microsoft.CodeAnalysis.Metrics](https://www.nuget.org/packages/Microsoft.CodeAnalysis.Metrics/) NuGet package. After you've installed the package, run `msbuild /t:Metrics` from the directory that contains your project file. For example:
51
51
52
-
To generate the executable *Metrics.exe*, follow these steps:
53
-
54
-
1. Clone the [dotnet/roslyn-analyzers](https://github.com/dotnet/roslyn-analyzers) repo.
55
-
2. Open Developer Command Prompt for Visual Studio as an administrator.
56
-
3. From the root of the **roslyn-analyzers** repo, execute the following command: `Restore.cmd`
57
-
4. Change directory to *src\Tools*.
58
-
5. Execute the following command to build the **Metrics.csproj** project:
Computing code metrics for ClassLibrary3.csproj...
64
+
Writing output to 'ClassLibrary3.Metrics.xml'...
65
+
Completed Successfully.
66
+
Done Building Project "C:\source\repos\ClassLibrary3\ClassLibrary3\ClassLibrary3.csproj" (Metrics target(s)).
67
+
68
+
Build succeeded.
69
+
0 Warning(s)
70
+
0 Error(s)
71
+
```
74
72
75
-
To run *Metrics.exe*, supply a project or solution and an output XML file as arguments. For example:
73
+
You can override the output file name by specifying `/p:MetricsOutputFile=<filename>`. You can also get [legacy-style](#previous-versions) code metrics data by specifying `/p:LEGACY_CODE_METRICS_MODE=true`. For example:
@@ -137,28 +149,56 @@ The generated XML output takes the following format:
137
149
</CodeMetricsReport>
138
150
```
139
151
140
-
### Tool differences
152
+
### Metrics.exe
141
153
142
-
Previous versions of Visual Studio, including Visual Studio 2015, included a command-line code metrics tool called *Metrics.exe*. This previous version of the tool did a binary analysis, that is, an assembly-based analysis. The new tool analyzes source code instead. Because the new *Metrics.exe*is source code-based, the results are different to what's generated by previous versions of *Metrics.exe* and within the Visual Studio 2017 IDE.
154
+
If you don't want to install the NuGet package, you can generate and use the *Metrics.exe* executable directly. To generate the *Metrics.exe*executable:
143
155
144
-
The new *Metrics.exe* tool can compute metrics even in the presence of source code errors, as long as the solution and project can be loaded.
156
+
1. Clone the [dotnet/roslyn-analyzers](https://github.com/dotnet/roslyn-analyzers) repo.
157
+
2. Open Developer Command Prompt for Visual Studio as an administrator.
158
+
3. From the root of the **roslyn-analyzers** repo, execute the following command: `Restore.cmd`
159
+
4. Change directory to *src\Tools*.
160
+
5. Execute the following command to build the **Metrics.csproj** project:
The `LinesOfCode` metric is more accurate and reliable in the new *Metrics.exe*. It is independent of any codegen differences and doesn’t change when the toolset or runtime changes. The new *Metrics.exe* counts actual lines of code, including blank lines and comments.
166
+
An executable named *Metrics.exe* is generated in the *artifacts\bin* directory under the repo root.
167
+
168
+
#### Metrics.exe usage
169
+
170
+
To run *Metrics.exe*, supply a project or solution and an output XML file as arguments. For example:
149
171
150
-
Other metrics such as `CyclomaticComplexity` and `MaintainabilityIndex` use the same formulas as previous versions of *Metrics.exe*, but the new *Metrics.exe* counts the number of `IOperations` (logical source instructions) instead of intermediate language (IL) instructions. The numbers will be slightly different from previous versions of *Metrics.exe* and from the Visual Studio 2017 IDE code metrics results.
You can also choose to build *Metrics.exe* in *legacy mode*. The legacy mode version of the tool generates metric values that are closer to what older versions of the tool generated. Additionally, in legacy mode, *Metrics.exe* generates code metrics for the same set of method types that previous versions of the tool generated code metrics for. For example, it doesn't generate code metrics data for field and property initializers. Legacy mode is useful for backwards compatibility or if you have code check-in gates based on code metrics numbers. The command to build *Metrics.exe* in legacy mode is:
182
+
You can choose to build *Metrics.exe* in *legacy mode*. The legacy mode version of the tool generates metric values that are closer to what [older versions of the tool generated](#previous-versions). Additionally, in legacy mode, *Metrics.exe* generates code metrics for the same set of method types that previous versions of the tool generated code metrics for. For example, it doesn't generate code metrics data for field and property initializers. Legacy mode is useful for backwards compatibility or if you have code check-in gates based on code metrics numbers. The command to build *Metrics.exe* in legacy mode is:
For more information, see [Enable generating code metrics in legacy mode](https://github.com/dotnet/roslyn-analyzers/pull/1841).
161
189
190
+
### Previous versions
191
+
192
+
Previous versions of Visual Studio, including Visual Studio 2015, included a command-line code metrics tool that was also called *Metrics.exe*. This previous version of the tool did a binary analysis, that is, an assembly-based analysis. The new tool analyzes source code instead. Because the new command-line code metrics tool is source code-based, the results are different to what's generated by previous versions of *Metrics.exe* and within the Visual Studio 2017 IDE.
193
+
194
+
The new command-line code metrics tool computes metrics even in the presence of source code errors, as long as the solution and project can be loaded.
195
+
196
+
#### Metric value differences
197
+
198
+
The `LinesOfCode` metric is more accurate and reliable in the new command-line code metrics tool. It's independent of any codegen differences and doesn’t change when the toolset or runtime changes. The new tool counts actual lines of code, including blank lines and comments.
199
+
200
+
Other metrics such as `CyclomaticComplexity` and `MaintainabilityIndex` use the same formulas as previous versions of *Metrics.exe*, but the new tool counts the number of `IOperations` (logical source instructions) instead of intermediate language (IL) instructions. The numbers will be slightly different from previous versions of *Metrics.exe* and from the Visual Studio 2017 IDE code metrics results.
201
+
162
202
## See also
163
203
164
204
-[Use the Code Metrics Results window](../code-quality/working-with-code-metrics-data.md)
Copy file name to clipboardExpand all lines: docs/containers/includes/vs-2017/docker-tools.md
+9-6Lines changed: 9 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -3,18 +3,19 @@ title: Visual Studio Tools for Docker with ASP.NET Core
3
3
author: ghogen
4
4
description: Learn how to use Visual Studio 2017 tooling and Docker for Windows
5
5
ms.author: ghogen
6
-
ms.date: 12/17/2018
6
+
ms.date: 02/01/2019
7
7
ms.prod: visual-studio-dev15
8
8
ms.technology: vs-azure
9
+
ms.topic: include
9
10
---
10
-
# Quickstart: Visual Studio Tools for Docker
11
11
12
-
With Visual Studio 2017, you can easily build, debug, and run containerized ASP.NET Core apps and publish them to Azure Container Registry (ACR), Docker Hub, Azure App Service, or your own container registry. In this article, we'll publish to ACR.
12
+
With Visual Studio, you can easily build, debug, and run containerized ASP.NET Core apps and publish them to Azure Container Registry (ACR), Docker Hub, Azure App Service, or your own container registry. In this article, we'll publish to ACR.
*[Visual Studio 2017](https://visualstudio.microsoft.com/) with the **Web Development**, **Azure Tools** workload, and/or **.NET Core cross-platform development** workload installed
18
+
* To publish to Azure Container Registry, an Azure subscription. [Sign up for a free trial](https://azure.microsoft.com/en-us/offers/ms-azr-0044p/).
18
19
19
20
## Installation and setup
20
21
@@ -29,7 +30,7 @@ For Docker installation, first review the information at [Docker Desktop for Win
29
30
1. Select **Web Application**.
30
31
1. Check the **Enable Docker Support** checkbox.
31
32
32
-

33
+

33
34
34
35
1. Select the type of container you want (Windows or Linux) and click **OK**.
35
36
@@ -112,12 +113,14 @@ Once the develop and debug cycle of the app is completed, you can create a produ
112
113
113
114
1. Click **Create**
114
115
116
+
## Next steps
117
+
115
118
You can now pull the container from the registry to any host capable of running Docker images, for example [Azure Container Instances](/azure/container-instances/container-instances-tutorial-deploy-app).
116
119
117
120
## Additional resources
118
121
119
122
*[Container development with Visual Studio](/visualstudio/containers)
120
-
*[Troubleshoot Visual Studio 2017 development with Docker](vs-azure-tools-docker-troubleshooting-docker-errors.md)
123
+
*[Troubleshoot Visual Studio 2017 development with Docker](../../vs-azure-tools-docker-troubleshooting-docker-errors.md)
121
124
*[Visual Studio Tools for Docker GitHub repository](https://github.com/Microsoft/DockerTools)
0 commit comments