There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull
example requires it.
Consider adopting the new property pattern, wherever you use IsNullOrEmpty
.
string? hello = "hello world";
namespace XUnitTestProject | |
{ | |
using Xunit; | |
public static class SwitchStatementMapper | |
{ | |
// Don't judge me, it's only for educational purposes :) | |
public static bool Map(string str) => str switch | |
{ | |
"true" => true, |
There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull
example requires it.
Consider adopting the new property pattern, wherever you use IsNullOrEmpty
.
string? hello = "hello world";
The following are examples of various features.
using System; | |
using System.Net.Http; | |
using System.Net.Http.Json; | |
string serviceURL = "https://localhost:5001/WeatherForecast"; | |
HttpClient client = new(); | |
Forecast[] forecasts = await client.GetFromJsonAsync<Forecast[]>(serviceURL); | |
foreach(Forecast forecast in forecasts) | |
{ |
You may be having trouble installing the .NET Framework. This document describes a set of steps you can take that may help you get it installed or help you undertstand why it isn't working.
Not all .NET Framework versions are supported on all Windows versions. .NET Framework 4.8 is the latest version of the .NET Framework. We recommend you install it if you can. The following list describes which .NET Framework versions are supported on various Windows versions.
There are two metrics that are important to consider when discussing the size of Docker images.
The example commands shown below will work on Windows, MacOS, and Linux.
The .NET Core SDK is significantly smaller with .NET Core 3.0. The primary reason is that we changed the way we construct the SDK, by moving to purpose-built “packs” of various kinds (reference assemblies, frameworks, templates). In previous versions (including .NET Core 2.2), we constructed the SDK from NuGet packages, which included many artifacts that were not required and wasted a lot of space.
The following sections demonstrate the size improvements for Windows, Linux and macOS, including container delivery. They detail the process and commands that were used to determine the product sizes, enabling you to reproduce the same results in your own environment. To keep thing simple, zips and tar balls were downloaded from dotnet/core-sdk as opposed to the official installers.
Some readers will be shocked on how large the .NET Core 2.2 installer directory grows when the NuGetFallback archive is expanded to the NuGetFallBackFolder. W
FROM mcr.microsoft.com/dotnet/core/runtime:3.0 AS base | |
WORKDIR /app | |
EXPOSE 80 | |
EXPOSE 443 | |
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build | |
WORKDIR /src | |
COPY ["WebApplication4/WebApplication4.csproj", "WebApplication4/"] | |
RUN dotnet restore "WebApplication4/WebApplication4.csproj" | |
COPY . . |
This workflow explores the 3.0
manifest-based tag in the mcr.microsoft.com/v2/dotnet/core/runtime repo on MCR as an example. It uses curl
to call a set of container registry APIs to find image digests, layer digests, and layer location. This example is intended to show the separation between MCR as a image manifest service and Azure CDN as an image layer service.
This pattern can be used on any operating system, but the specific commands are OS-specific. curl
is included in the latest versions of Windows and is also in most Linux and macOS distributions. findstr
is part of Windows, however, grep
can be used on Linux or macOS instead.
The 3.0
tag is a manifest tag. It represents a set of potential candidate images, for various operating systems and operating systems versions. When a manifest tag is pulled by a docker client, the client picks the best image for the host op