Skip to content

Fix git push error for protected CLA branch #2313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b7765e2
Move Docker Tools links to the left side.
ghogen Jan 31, 2019
b6959be
Remove external links
ghogen Jan 31, 2019
ab83c9a
Add quickstart link, use "Container Tools" name
ghogen Jan 31, 2019
75a3707
adjust structure
ghogen Jan 31, 2019
ad1cc38
move container tools to "containers"
ghogen Jan 31, 2019
2d5c088
Add documentation for concurrency SAL on smart lock types
Feb 1, 2019
d0e0589
office-development -> sharepoint-development
gewarren Feb 1, 2019
83607a8
minor edits
Mikejo5000 Feb 1, 2019
c879789
VS 2019 and ASP.NET Core 2.2 version of quickstart
ghogen Feb 1, 2019
bf7278e
Merge pull request #3807 from Mikejo5000/mikejo-nodejs
PRMerger15 Feb 1, 2019
f9b0941
syntax issues fixed
ghogen Feb 1, 2019
dcd8aa5
link fixes
ghogen Feb 1, 2019
0043b98
Remove dupe h1s
ghogen Feb 1, 2019
d9bd5cb
update image
ghogen Feb 1, 2019
780714c
remove 2017 from first para
ghogen Feb 1, 2019
d214969
date
ghogen Feb 1, 2019
5ced49f
Merge pull request #3806 from MicrosoftDocs/gewarren-patch-3
gewarren Feb 1, 2019
32adf21
Merge pull request #3803 from sunnychatterjee/doc/sunnych/concurrency…
PRMerger20 Feb 1, 2019
6ac84e2
Merge pull request #3794 from ghogen/docker-tools-work
TrishaMc Feb 1, 2019
7b4ace3
add info about code metrics nuget package
gewarren Feb 2, 2019
c99ca33
fixes #2260 - add info about code metrics nuget package
gewarren Feb 2, 2019
3de30e1
Merge branch 'codemetrix' of github.com:gewarren/visualstudio-docs-pr…
gewarren Feb 2, 2019
f8b22b1
fix bookmarks and move metrics.exe section down
gewarren Feb 2, 2019
6f21046
change tracking links for downloads from Button to Inline
TerryGLee Feb 2, 2019
7575fd8
Merge pull request #3811 from TerryGLee/tglee-urlupdate
PRMerger18 Feb 2, 2019
f673757
clarify 'new metrics.exe'
gewarren Feb 2, 2019
21383b0
change tracking links for downloads from Button to Inline
TerryGLee Feb 2, 2019
6ccad6f
Merge pull request #3812 from TerryGLee/tglee-urlupdate
PRMerger8 Feb 2, 2019
87a6171
Merge pull request #3809 from gewarren/codemetrix
GitHubber17 Feb 3, 2019
0f7411c
Merge pull request #3814 from MicrosoftDocs/master
Feb 4, 2019
9299307
Merging changes synced from https://github.com/MicrosoftDocs/visualst…
gewarren Feb 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .openpublishing.redirection.json
Original file line number Diff line number Diff line change
Expand Up @@ -7131,6 +7131,32 @@
"source_path": "docs/ide/whats-new-visual-studio.md",
"redirect_url": "/visualstudio/ide/whats-new-visual-studio-2019",
"redirect_document_id": true
},
{
"source_path": "docs/docker/vs-azure-tools-docker-edit-and-refresh.md",
"redirect_url": "/visualstudio/containers/vs-azure-tools-docker-edit-and-refresh",
"redirect_document_id": true
},
{
"source_path": "docs/docker/docker-tools.md",
"redirect_url": "/visualstudio/containers/docker-tools",
"redirect_document_id": true
},
{
"source_path": "docs/docker/vs-azure-tools-docker-hosting-web-apps-in-docker.md",
"redirect_url": "/visualstudio/containers/vs-azure-tools-docker-hosting-web-apps-in-docker",
"redirect_document_id": true
},
{
"source_path": "docs/docker/vs-azure-tools-docker-setup.md",
"redirect_url": "/visualstudio/containers/vs-azure-tools-docker-setup",
"redirect_document_id": true
},
{
"source_path": "docs/docker/vs-azure-tools-docker-troubleshooting-docker-errors.md",
"redirect_url": "/visualstudio/containers/vs-azure-tools-docker-troubleshooting-docker-errors",
"redirect_document_id": true
}

]
}
13 changes: 13 additions & 0 deletions docs/code-quality/annotating-locking-behavior.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ To avoid concurrency bugs in your multithreaded program, always follow an approp
|`_Interlocked_operand_`|The annotated function parameter is the target operand of one of the various Interlocked functions. Those operands must have specific additional properties.|
|`_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.|


## Smart Lock and RAII Annotations
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.

|Annotation|Description|
|----------------|-----------------|
|`_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.|
|`_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.|
|`_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.|
|`_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)`.|
|`_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.|
|`_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`.|

## See Also

- [Using SAL Annotations to Reduce C/C++ Code Defects](../code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects.md)
Expand Down
122 changes: 81 additions & 41 deletions docs/code-quality/how-to-generate-code-metrics-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,46 +43,58 @@ The results are generated and the **Code Metrics Results** window is displayed.

## Command-line code metrics

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*.
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.

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.
### Microsoft.CodeAnalysis.Metrics NuGet package

### Generate the executable
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:

To generate the executable *Metrics.exe*, follow these steps:

1. Clone the [dotnet/roslyn-analyzers](https://github.com/dotnet/roslyn-analyzers) repo.
2. Open Developer Command Prompt for Visual Studio as an administrator.
3. From the root of the **roslyn-analyzers** repo, execute the following command: `Restore.cmd`
4. Change directory to *src\Tools*.
5. Execute the following command to build the **Metrics.csproj** project:

```shell
msbuild /m /v:m /p:Configuration=Release Metrics.csproj
```

An executable named *Metrics.exe* is generated in the *artifacts\bin* directory under the repo root.

> [!TIP]
> To build *Metrics.exe* in [legacy mode](#legacy-mode), execute the following command:
>
> ```shell
> msbuild /m /v:m /t:rebuild /p:LEGACY_CODE_METRICS_MODE=true Metrics.csproj
> ```

### Usage
```shell
C:\source\repos\ClassLibrary3\ClassLibrary3>msbuild /t:Metrics
Microsoft (R) Build Engine version 16.0.360-preview+g9781d96883 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 1/22/2019 4:29:57 PM.
Project "C:\source\repos\ClassLibrary3\ClassLibrary3\ClassLibrary3.csproj" on node 1 (Metrics target(s))
.
Metrics:
C:\source\repos\ClassLibrary3\packages\Microsoft.CodeMetrics.2.6.4-ci\build\\..\Metrics\Metrics.exe /project:C:\source\repos\ClassLibrary3\ClassLibrary3\ClassLibrary3.csproj /out:ClassLibrary3.Metrics.xml
Loading ClassLibrary3.csproj...
Computing code metrics for ClassLibrary3.csproj...
Writing output to 'ClassLibrary3.Metrics.xml'...
Completed Successfully.
Done Building Project "C:\source\repos\ClassLibrary3\ClassLibrary3\ClassLibrary3.csproj" (Metrics target(s)).

Build succeeded.
0 Warning(s)
0 Error(s)
```

To run *Metrics.exe*, supply a project or solution and an output XML file as arguments. For example:
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:

```shell
C:\>Metrics.exe /project:ConsoleApp20.csproj /out:report.xml
Loading ConsoleApp20.csproj...
Computing code metrics for ConsoleApp20.csproj...
Writing output to 'report.xml'...
Completed Successfully.
C:\source\repos\ClassLibrary3\ClassLibrary3>msbuild /t:Metrics /p:LEGACY_CODE_METRICS_MODE=true /p:MetricsOutputFile="Legacy.xml"
Microsoft (R) Build Engine version 16.0.360-preview+g9781d96883 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 1/22/2019 4:31:00 PM.
The "MetricsOutputFile" property is a global property, and cannot be modified.
Project "C:\source\repos\ClassLibrary3\ClassLibrary3\ClassLibrary3.csproj" on node 1 (Metrics target(s))
.
Metrics:
C:\source\repos\ClassLibrary3\packages\Microsoft.CodeMetrics.2.6.4-ci\build\\..\Metrics.Legacy\Metrics.Legacy.exe /project:C:\source\repos\ClassLibrary3\ClassLibrary3\ClassLibrary3.csproj /out:Legacy.xml
Loading ClassLibrary3.csproj...
Computing code metrics for ClassLibrary3.csproj...
Writing output to 'Legacy.xml'...
Completed Successfully.
Done Building Project "C:\source\repos\ClassLibrary3\ClassLibrary3\ClassLibrary3.csproj" (Metrics target(s)).

Build succeeded.
0 Warning(s)
0 Error(s)
```

### Output
### Code metrics output

The generated XML output takes the following format:

Expand Down Expand Up @@ -118,7 +130,7 @@ The generated XML output takes the following format:
<Metric Name="LinesOfCode" Value="7" />
</Metrics>
<Members>
<Method Name="void Program.Main(string[] args)" File="C:\Users\mavasani\source\repos\ConsoleApp20\ConsoleApp20\Program.cs" Line="7">
<Method Name="void Program.Main(string[] args)" File="C:\source\repos\ConsoleApp20\ConsoleApp20\Program.cs" Line="7">
<Metrics>
<Metric Name="MaintainabilityIndex" Value="100" />
<Metric Name="CyclomaticComplexity" Value="1" />
Expand All @@ -137,28 +149,56 @@ The generated XML output takes the following format:
</CodeMetricsReport>
```

### Tool differences
### Metrics.exe

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.
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:

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.
1. Clone the [dotnet/roslyn-analyzers](https://github.com/dotnet/roslyn-analyzers) repo.
2. Open Developer Command Prompt for Visual Studio as an administrator.
3. From the root of the **roslyn-analyzers** repo, execute the following command: `Restore.cmd`
4. Change directory to *src\Tools*.
5. Execute the following command to build the **Metrics.csproj** project:

#### Metric value differences
```shell
msbuild /m /v:m /p:Configuration=Release Metrics.csproj
```

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.
An executable named *Metrics.exe* is generated in the *artifacts\bin* directory under the repo root.

#### Metrics.exe usage

To run *Metrics.exe*, supply a project or solution and an output XML file as arguments. For example:

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.
```shell
C:\>Metrics.exe /project:ConsoleApp20.csproj /out:report.xml
Loading ConsoleApp20.csproj...
Computing code metrics for ConsoleApp20.csproj...
Writing output to 'report.xml'...
Completed Successfully.
```

### Legacy mode
#### Legacy mode

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:
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:

```shell
msbuild /m /v:m /t:rebuild /p:LEGACY_CODE_METRICS_MODE=true Metrics.csproj
```

For more information, see [Enable generating code metrics in legacy mode](https://github.com/dotnet/roslyn-analyzers/pull/1841).

### Previous versions

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.

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.

#### Metric value differences

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.

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.

## See also

- [Use the Code Metrics Results window](../code-quality/working-with-code-metrics-data.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
tocHref: /visualstudio/
topicHref: /visualstudio/
items:
- name: Visual Studio Tools for Docker
tocHref: /visualstudio/docker
topicHref: /visualstudio/docker/
- name: Visual Studio Container Tools
tocHref: /visualstudio/containers
topicHref: /visualstudio/containers/

31 changes: 31 additions & 0 deletions docs/containers/docker-tools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: Visual Studio Tools for Docker with ASP.NET Core
author: ghogen
description: Learn how to use Visual Studio 2017 tooling and Docker for Windows
ms.author: ghogen
ms.date: 02/01/2019
ms.prod: visual-studio-dev15
ms.technology: vs-azure
ms.topic: include
---
# Quickstart: Visual Studio Tools for Docker

::: moniker range="vs-2017"

[!include[Visual Studio Docker Tools](includes/vs-2017/docker-tools.md)]

::: moniker-end

::: moniker range=">= vs-2019"

[!include[Visual Studio Docker Tools](includes/vs-2019/docker-tools.md)]

::: moniker-end

## Additional resources

* [Container development with Visual Studio](/visualstudio/containers)
* [Troubleshoot Visual Studio 2017 development with Docker](vs-azure-tools-docker-troubleshooting-docker-errors.md)
* [Visual Studio Tools for Docker GitHub repository](https://github.com/Microsoft/DockerTools)

[0]:media/vs-azure-tools-docker-hosting-web-apps-in-docker/vs-acr-provisioning-dialog.png
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ title: Visual Studio Tools for Docker with ASP.NET Core
author: ghogen
description: Learn how to use Visual Studio 2017 tooling and Docker for Windows
ms.author: ghogen
ms.date: 12/17/2018
ms.date: 02/01/2019
ms.prod: visual-studio-dev15
ms.technology: vs-azure
ms.topic: include
---
# Quickstart: Visual Studio Tools for Docker

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.
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.

## Prerequisites

* [Docker Desktop](https://hub.docker.com/editions/community/docker-ce-desktop-windows)
* [Visual Studio 2017](https://visualstudio.microsoft.com/) with the **Web Development**, **Azure Tools** workload, and/or **.NET Core cross-platform development** workload installed
* 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/).

## Installation and setup

Expand All @@ -29,7 +30,7 @@ For Docker installation, first review the information at [Docker Desktop for Win
1. Select **Web Application**.
1. Check the **Enable Docker Support** checkbox.

![Enable Docker Support check box](media/docker-tools/enable-docker-support.PNG)
![Enable Docker Support check box](../../media/docker-tools/enable-docker-support.PNG)

1. Select the type of container you want (Windows or Linux) and click **OK**.

Expand Down Expand Up @@ -112,12 +113,14 @@ Once the develop and debug cycle of the app is completed, you can create a produ

1. Click **Create**

## Next steps

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).

## Additional resources

* [Container development with Visual Studio](/visualstudio/containers)
* [Troubleshoot Visual Studio 2017 development with Docker](vs-azure-tools-docker-troubleshooting-docker-errors.md)
* [Troubleshoot Visual Studio 2017 development with Docker](../../vs-azure-tools-docker-troubleshooting-docker-errors.md)
* [Visual Studio Tools for Docker GitHub repository](https://github.com/Microsoft/DockerTools)

[0]:media/vs-azure-tools-docker-hosting-web-apps-in-docker/vs-acr-provisioning-dialog.png
[0]:../../media/vs-azure-tools-docker-hosting-web-apps-in-docker/vs-acr-provisioning-dialog.png
Loading