Skip to content

Commit d955cb4

Browse files
authored
Merge pull request #5844 from dotnet/master
Update Live with current Master
2 parents 5b08028 + d543214 commit d955cb4

22 files changed

+172
-363
lines changed

docs/core/docker/building-net-docker-images.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ When developing, building, and running containerized applications, we have diffe
4242
* .js and .css files
4343

4444

45-
The reason to include the `dotnet publish` command output in your production image is to keep its' size to a minimum.
45+
The reason to include the `dotnet publish` command output in your production image is to keep its size to a minimum.
4646

4747
Some .NET Core images share layers between different tags so downloading the latest tag is a relatively lightweight process. If you already have an older version on your machine, this architecture decreases the needed disk space.
4848

docs/core/tutorials/consuming-library-with-visual-studio.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
2-
title: Consuming a class library with .NET Core in Visual Studio 2017
2+
title: Consuming a .NET Standard library in Visual Studio 2017
33
description: Learn how to call the members in a class library with Visual Studio 2017.
44
author: BillWagner
55
ms.author: wiwagn
6-
ms.date: 08/07/2017
6+
ms.date: 06/05/2018
77
dev_langs:
88
- "csharp"
99
- "vb"
1010
---
1111

12-
# Consuming a class library with .NET Core in Visual Studio 2017
12+
# Consuming a .NET Standard library in Visual Studio 2017
1313

14-
Once you've created a class library by following the steps in [Building a C# class library with .NET Core in Visual Studio 2017](./library-with-visual-studio.md) or [Building a Visual Basic class library with .NET Core in Visual Studio 2017](vb-library-with-visual-studio.md), tested it in [Testing a class library with .NET Core in Visual Studio 2017](testing-library-with-visual-studio.md), and built a Release version of the library, the next step is to make it available to callers. You can do this in two ways:
14+
Once you've created a .NET Standard class library by following the steps in [Building a C# class library with .NET Core in Visual Studio 2017](./library-with-visual-studio.md) or [Building a Visual Basic class library with .NET Core in Visual Studio 2017](vb-library-with-visual-studio.md), tested it in [Testing a class library with .NET Core in Visual Studio 2017](testing-library-with-visual-studio.md), and built a Release version of the library, the next step is to make it available to callers. You can do this in two ways:
1515

1616
* If the library will be used by a single solution (for example, if it's a component in a single large application), you can include it as a project in your solution.
1717

@@ -44,7 +44,7 @@ Just as you included unit tests in the same solution as your class library, you
4444

4545
[!CODE-csharp[UsingClassLib#1](../../../samples/snippets/csharp/getting_started/with_visual_studio_2017/showcase.cs)]
4646

47-
The code uses the [Console.WindowHeight](xref:System.Console.WindowHeight) property to determine the number of rows in the console window. Whenever the [Console.CursorTop](xref:System.Console.CursorTop) property is greater than or equal to the number of rows in the console window, the code clears the console window and displays a message to the user.
47+
The code uses the `row` variable to maintain a count of the number of rows of data written to the console window. Whenever it is greater than or equal to 25, the code clears the console window and displays a message to the user.
4848

4949
The program prompts the user to enter a string. It indicates whether the string starts with an uppercase character. If the user presses the Enter key without entering a string, the application terminates, and the console window closes.
5050

@@ -74,7 +74,7 @@ Just as you included unit tests in the same solution as your class library, you
7474

7575
[!CODE-vb[UsingClassLib#1](../../../samples/snippets/core/tutorials/vb-library-with-visual-studio/showcase.vb)]
7676

77-
The code uses the [Console.WindowHeight](xref:System.Console.WindowHeight) property to determine the number of rows in the console window. Whenever the [Console.CursorTop](xref:System.Console.CursorTop) property is greater than or equal to the number of rows in the console window, the code clears the console window and displays a message to the user.
77+
The code uses the `row` variable to maintain a count of the number of rows of data written to the console window. Whenever it is greater than or equal to 25, the code clears the console window and displays a message to the user.
7878

7979
The program prompts the user to enter a string. It indicates whether the string starts with an uppercase character. If the user presses the Enter key without entering a string, the application terminates, and the console window closes.
8080

docs/core/whats-new/dotnet-core-2-1.md

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: What's new in .NET Core 2.1
33
description: Learn about the new features found in .NET Core 2.1.
44
author: rpetrusha
55
ms.author: ronpet
6-
ms.date: 05/30/2018
6+
ms.date: 06/06/2018
77
---
88
# What's new in .NET Core 2.1
99

@@ -13,12 +13,12 @@ ms.date: 05/30/2018
1313
- [Roll forward](#roll-forward)
1414
- [Deployment](#deployment)
1515
- [Windows Compatibility Pack](#windows-compatibility-pack)
16-
- [JIT compiler improvements](#jit-compiler-improvements)
16+
- [JIT compilation improvements](#jit-compiler-improvements)
1717
- [API changes](#api-changes)
1818

1919
## Tooling
2020

21-
The .NET Core 2.1.300 SDK, the tooling included with .NET Core 2.1, includes the following changes and enhancements:
21+
The .NET Core 2.1 SDK (v 2.1.300), the tooling included with .NET Core 2.1, includes the following changes and enhancements:
2222

2323
### Build performance improvements
2424

@@ -43,7 +43,9 @@ A number of tools that were available only on a per project basis using [`Dotnet
4343
```console
4444
dotnet watch -- --verbose build
4545
```
46-
46+
47+
Note the `--` option that precedes the `--verbose` option. It delimits the options passed directly to the `dotnet watch` command from the arguments that are passed to the child `dotnet` process. Without it, the `--verbose` option applies to the `dotnet watch` command, not the `dotnet build` command.
48+
4749
For more information, see [Develop ASP.NET Core apps using dotnet watch](/aspnet/core/tutorials/dotnet-watch)
4850

4951
- `dotnet dev-certs` generates and manages certificates used during development in ASP.NET Core applications.
@@ -66,26 +68,30 @@ dotnet tool install -g dotnetsay
6668

6769
Once installed, the tool can be run from the command line by specifying the tool name. For more information, see [.NET Core Global Tools overview](../tools/global-tools.md).
6870

69-
### Single-source tool management with the `dotnet tool` command
71+
### Tool management with the `dotnet tool` command
72+
73+
In .NET Core SDK 2.1 (v 2.1.300), all tools operations use the `dotnet tool` command. The following options are available:
7074

71-
In .NET Core 2.1, all tools operations use the `dotnet tool` command. The following options are available:
75+
- [`dotnet tool install`](../tools/dotnet-tool-install.md) to install a tool.
7276

73-
- `dotnet tool install` to install a tool.
77+
- [`dotnet tool update`](../tools/dotnet-tool-update.md) to uninstall and reinstall a tool, which effectively updates it.
7478

75-
- `dotnet tool update` to uninstall and reinstall a tool, which effectively updates it.
79+
- [`dotnet tool list`](../tools/dotnet-tool-list.md) to list currently installed tools.
7680

77-
- `dotnet tool list` to list currently installed tools.
81+
- [`dotnet tool uninstall`](../tools/dotnet-tool-uninstall.md) to uninstall currently installed tools.
7882

7983
## Roll forward
8084

81-
All .NET Core applications starting with the .NET Core 2.0 automatically roll forward to the latest *minor version* installed on a system. That is, if the .NET Core version that an application was built with is not present, the application runs against the latest installed minor version. In other words, if an application is built with .NET Core 2.0 and .NET Core 2.0 itself is not present on the host system but .NET Core 2.1 is, the application runs with .NET Core 2.1.
85+
All .NET Core applications starting with the .NET Core 2.0 automatically roll forward to the latest *minor version* installed on a system.
86+
87+
Starting with .NET Core 2.0, if the version of .NET Core that an application was built with is not present at runtime, the application automatically runs against the latest installed *minor version* of .NET Core. In other words, if an application is built with .NET Core 2.0, and .NET Core 2.0 is not present on the host system but .NET Core 2.1 is, the application runs with .NET Core 2.1.
8288

8389
> [!IMPORTANT]
8490
> This roll-forward behavior doesn't apply to preview releases. Nor does it apply to major releases. For example, a .NET Core 1.0 application wouldn't roll forward to .NET Core 2.0 or .NET Core 2.1.
8591
8692
You can also disable minor version roll forward in any of three ways:
8793

88-
- Set the `DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX` environment variable equal to 0,
94+
- Set the `DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX` environment variable to 0.
8995

9096
- Add the following line to the runtimeconfig.json file:
9197

@@ -103,31 +109,43 @@ You can also disable minor version roll forward in any of three ways:
103109

104110
### Self-contained application servicing
105111

106-
`dotnet publish` now publishes self-contained applications with a serviced runtime version. When you publish a self-contained application with the .NET Core 2.1 SDK, your application includes the latest serviced runtime version known by that SDK. When you upgrade to the latest SDK, you’ll publish with the latest .NET Core runtime version. This applies for .NET Core 1.0 runtimes and later.
112+
`dotnet publish` now publishes self-contained applications with a serviced runtime version. When you publish a self-contained application with the .NET Core 2.1 SDK (v 2.1.300), your application includes the latest serviced runtime version known by that SDK. When you upgrade to the latest SDK, you’ll publish with the latest .NET Core runtime version. This applies for .NET Core 1.0 runtimes and later.
107113

108114
Self-contained publishing relies on runtime versions on NuGet.org. You do not need to have the serviced runtime on your machine.
109115

110-
Using the .NET Core 2.0 SDK, self-contained applications are published with the .NET Core 2.0.0 runtime unless a different version is specified via the `RuntimeFrameworkVersion` property. With this new behavior, you’ll no longer need to set this property to select a higher runtime version for a self-contained application. The easiest approach going forward is to always publish with .NET Core 2.1 SDK.
116+
Using the .NET Core 2.0 SDK, self-contained applications are published with the .NET Core 2.0.0 runtime unless a different version is specified via the `RuntimeFrameworkVersion` property. With this new behavior, you’ll no longer need to set this property to select a higher runtime version for a self-contained application. The easiest approach going forward is to always publish with .NET Core 2.1 SDK (v 2.1.300).
111117

112118
## Windows Compatibility Pack
113119

114120
When you port existing code from the .NET Framework to .NET Core, you can use the [Windows Compatibility Pack](https://www.nuget.org/packages/Microsoft.Windows.Compatibility). It provides access to 20,000 more APIs than are available in .NET Core. These APIs include types in the <xref:System.Drawing?displayProperty="nameWithType"> namespace, the <xref:System.Diagnostics.EventLog> class, WMI, Performance Counters, Windows Services, and the Windows registry types and members.
115121

116122
## JIT compiler improvements
117123

118-
.NET Core incorporates a new JIT compiler technology called *tiered compilation* (also known as *adaptive optimization*) that can significantly improve performance.
124+
.NET Core incorporates a new JIT compiler technology called *tiered compilation* (also known as *adaptive optimization*) that can significantly improve performance. Tiered compilation is an opt-in setting.
119125

120126
One of the important tasks performed by the JIT compiler is optimizing code execution. For little-used code paths, however, the compiler may spend more time optimizing code than the runtime spends running unoptimized code. Tiered compilation introduces two stages in JIT compilation:
121127

122128
- A **first tier**, which generates code as quickly as possible.
123129

124130
- A **second tier**, which generates optimized code for those methods that are executed frequently. The second tier of compilation is performed in parallel for enhanced performance.
125131

126-
You can test tiered compilation with a .NET Core 2.1 app by setting the following environment variable:
132+
You can opt into tiered compilation in either of two ways.
127133

128-
```console
129-
COMPlus_TieredCompilation="1"
130-
```
134+
- To use tiered compilation in all projects that use the .NET Core 2.1 SDK, set the following environment variable:
135+
136+
```console
137+
COMPlus_TieredCompilation="1"
138+
```
139+
140+
- To use tiered compilation on a per-project basis, add the `<TieredCompilation>` property to the `<PropertyGroup>` section of the MSBuild project file, as the following example shows:
141+
142+
```xml
143+
<PropertyGroup>
144+
<!-- other property definitions -->
145+
146+
<TieredCompilation>true</TieredCompilation>
147+
</PropertyGroup>
148+
```
131149

132150
## API changes
133151

@@ -187,16 +205,20 @@ The sockets implementation introduced in .NET Core 2.1 has a number of advantage
187205

188206
- A significant performance improvement when compared with the previous implementation.
189207

190-
- Elimination on platform dependencies, which simplifies deployment and servicing.
208+
- Elimination of platform dependencies, which simplifies deployment and servicing.
191209

192210
- Consistent behavior across all .NET Core platforms.
193211

194-
Sockets based on <xref:System.Net.Http.SocketsHttpHandler> is the default implementation in .NET Core 2.1. However, you can configure your application to use the older <xref:System.Net.Http.HttpClientHandler> class by calling the <xref:System.AppContext.SetSwitch%2A?displayProperty="nameWithType"> method:
212+
<xref:System.Net.Http.SocketsHttpHandler> is the default implementation in .NET Core 2.1. However, you can configure your application to use the older <xref:System.Net.Http.HttpClientHandler> class by calling the <xref:System.AppContext.SetSwitch%2A?displayProperty="nameWithType"> method:
195213

196214
```csharp
197215
AppContext.SetSwitch("System.Net.Http.useSocketsHttpHandler", false);
198216
```
199217

218+
```vb
219+
AppContext.SetSwitch("System.Net.Http.useSocketsHttpHandler", False)
220+
```
221+
200222
You can also use an environment variable to opt out of using sockets implementations based on <xref:System.Net.Http.SocketsHttpHandler>. To do this, set the `DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER` to either `false` or 0.
201223

202224
On Windows, you can also choose to use <xref:System.Net.Http.WinHttpHandler?displayProperty=nameWithType>, which relies on a native implementation, or the <xref:System.Net.Http.SocketsHttpHandler> class by passing an instance of the class to the <xref:System.Net.Http.HttpClient> constructor.

docs/csharp/delegate-class.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,8 @@ Suppose you wanted to sort a list of strings by their length. Your
109109
comparison function might be the following:
110110

111111
```csharp
112-
private static int CompareLength(string left, string right)
113-
{
114-
return left.Length.CompareTo(right.Length);
115-
}
112+
private static int CompareLength(string left, string right) =>
113+
left.Length.CompareTo(right.Length);
116114
```
117115

118116
The method is declared as a private method. That's fine. You may not

docs/csharp/delegates-events.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ This topic will be covered under the following articles:
4141

4242
This article discusses how you should distinguish between using events and delegates in your designs.
4343

44+
You can download the [delegates sample](https://github.com/dotnet/samples/tree/master/csharp/delegates-and-events) and the [events sample](https://github.com/dotnet/samples/tree/master/csharp/events) from our GitHub samples repository.

docs/csharp/delegates-patterns.md

Lines changed: 10 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -78,35 +78,18 @@ Let's start small: the initial implementation will accept new messages,
7878
and write them using any attached delegate. You can start with one delegate
7979
that writes messages to the console.
8080

81-
```csharp
82-
public static class Logger
83-
{
84-
public static Action<string> WriteMessage;
85-
86-
public static void LogMessage(string msg)
87-
{
88-
WriteMessage(msg);
89-
}
90-
}
91-
```
81+
[!code-csharp[LoggerImplementation](../../samples/csharp/delegates-and-events/Logger.cs#FirstImplementation "A first Logger implementation.")]
9282

9383
The static class above is the simplest thing that can work. We need to
9484
write the single implementation for the method that writes messages
9585
to the console:
9686

97-
```csharp
98-
public static void LogToConsole(string message)
99-
{
100-
Console.Error.WriteLine(message);
101-
}
102-
```
87+
[!code-csharp[LogToConsole](../../samples/csharp/delegates-and-events/Program.cs#LogToConsole "A Console logger.")]
10388

10489
Finally, you need to hook up the delegate by attaching it to
10590
the WriteMessage delegate declared in the logger:
10691

107-
```csharp
108-
Logger.WriteMessage += LogToConsole;
109-
```
92+
[!code-csharp[ConnectDelegate](../../samples/csharp/delegates-and-events/Program.cs#ConnectDelegate "Connect to the delegate")]
11093

11194
## Practices
11295

@@ -130,50 +113,14 @@ creating other logging mechanisms.
130113
Next, let's add a few arguments to the `LogMessage()` method so that
131114
your log class creates more structured messages:
132115

133-
```csharp
134-
// Logger implementation two
135-
public enum Severity
136-
{
137-
Verbose,
138-
Trace,
139-
Information,
140-
Warning,
141-
Error,
142-
Critical
143-
}
144-
145-
public static class Logger
146-
{
147-
public static Action<string> WriteMessage;
148-
149-
public static void LogMessage(Severity s, string component, string msg)
150-
{
151-
var outputMsg = $"{DateTime.Now}\t{s}\t{component}\t{msg}";
152-
WriteMessage(outputMsg);
153-
}
154-
}
155-
```
116+
[!code-csharp[Severity](../../samples/csharp/delegates-and-events/Logger.cs#Severity "Define severities")]
117+
[!code-csharp[NextLogger](../../samples/csharp/delegates-and-events/Logger.cs#LoggerTwo "Refine the Logger")]
156118

157119
Next, let's make use of that `Severity` argument to filter the messages
158120
that are sent to the log's output.
159121

160-
```csharp
161-
public static class Logger
162-
{
163-
public static Action<string> WriteMessage;
164-
165-
public static Severity LogLevel {get;set;} = Severity.Warning;
166-
167-
public static void LogMessage(Severity s, string component, string msg)
168-
{
169-
if (s < LogLevel)
170-
return;
171-
172-
var outputMsg = $"{DateTime.Now}\t{s}\t{component}\t{msg}";
173-
WriteMessage(outputMsg);
174-
}
175-
}
176-
```
122+
[!code-csharp[FinalLogger](../../samples/csharp/delegates-and-events/Logger.cs#LoggerFinal "Finish the Logger")]
123+
177124
## Practices
178125

179126
You've added new features to the logging infrastructure. Because
@@ -198,42 +145,13 @@ each message is generated.
198145

199146
Here is that file based logger:
200147

201-
```csharp
202-
public class FileLogger
203-
{
204-
private readonly string logPath;
205-
public FileLogger(string path)
206-
{
207-
logPath = path;
208-
Logger.WriteMessage += LogMessage;
209-
}
210-
211-
public void DetachLog() => Logger.WriteMessage -= LogMessage;
212-
213-
// make sure this can't throw.
214-
private void LogMessage(string msg)
215-
{
216-
try {
217-
using (var log = File.AppendText(logPath))
218-
{
219-
log.WriteLine(msg);
220-
log.Flush();
221-
}
222-
} catch (Exception e)
223-
{
224-
// Hmm. Not sure what to do.
225-
// Logging is failing...
226-
}
227-
}
228-
}
229-
```
148+
[!code-csharp[FileLogger](../../samples/csharp/delegates-and-events/FileLogger.cs#FileLogger "Log to files")]
149+
230150

231151
Once you've created this class, you can instantiate it and it attaches
232152
its LogMessage method to the Logger component:
233153

234-
```csharp
235-
var file = new FileLogger("log.txt");
236-
```
154+
[!code-csharp[FileLogger](../../samples/csharp/delegates-and-events/Program.cs#FileLogger "Log to files")]
237155

238156
These two are not mutually exclusive. You could attach both log
239157
methods and generate messages to the console and a file:

0 commit comments

Comments
 (0)