.NET Core 3 released - What’s new?

With .NET Core 3 released today, in this story we will look at some of great features that are available with .NET Core 3.

C#8.0 and F#4.7 are also released with .NET Core 3.

WPF and Win Forms

WPF and Win Forms are open source. They ship in a new component called “Windows Desktop” that is part of the Windows version of the .NET Core SDK.

Executable App by default

The native executable is generated by default when app is build using dotnet build . The executable can be run using double click (or running exe from command prompt) on windows and ./filename on Linux and macOS. An executable is provided is based on SDK environment (32/64 bit, OS Platform) used.

Local dotnet tools

Just like Global tools in .NET Core 2.1, .NET Core 3 supports local dotnet tools. When a local tool is called, dotnet searches for a manifest up the directory structure and searches for requested tool in manifest file. The tool manifest file can be checked into source control so that correct tools will be installed.

Fast JSON reader

System.Text.Json.Utf8JsonReader is a high-performance, low allocation, forward-only reader for UTF-8 encoded JSON text, it can also read from a ReadOnlySpan<byte> . It is designed to to write JSON API that require less memory and improve performance of ASP.NET Core web server itself. While JSON.NET will still be there and can be used instead or with it as it has larger feature set.

Tiered Compilation

Tiered compilation was added as an opt-in feature in .NET Core 2.1. It’s a feature that enables the runtime to more adaptively use the Just-In-Time (JIT) compiler to get better performance, both at startup and to maximize throughput. It is enabled by default with .NET Core 3.0.

dotnet build now copies dependencies

dotnet build now copies NuGet dependencies from the NuGet cache to build output folder during the build operation. Earlier those dependencies were only copied as part of dotnet publish. This change allows to xcopy build output to different machine.

.NET Core SDK installers will now Upgrade in Place

The .NET Core SDK MSI installers for Windows will start upgrading patch versions in place. This will reduce the number of SDKs that are installed on machines.

The upgrade policy will specifically target .NET Core SDK feature bands. Feature bands are defined in hundreds groups in the patch section of the version number. For example, 3.0.101 and 3.0.201 are versions in two different feature bands while 3.0.101 and 3.0.199 are in the same feature band

Publishing Single file EXEs

Single-file executable can be published using dotnet publish. It generates self-extracting executable containing all dependencies, including native dependencies, as resources. At startup, it copies all dependencies to a temp directory and loads them from there. It is architecture specific so Run time Identifier (RID) must be specified during publishing:

dotnet publish -r win10-x64 /p:PublishSingleFile=true

Ready to Run Images

ReadyToRun (R2R) format is form of ahead-of-time (AOT) compilation. R2R binaries improve startup performance by reducing the amount of work the JIT needs to do as your application is loading. R2R assemblies contain IL and native code. They are compiled for a specific minimum .NET Core runtime version and runtime environment (RID). Compared to NGEN (where compilation is done at client machines), native image is generated as a part of the application build, though currently publish command need to be run from desired target.

To enable R2R need to do following:

// In project file
<PublishReadyToRun>true</PublishReadyToRun>
// publish with valid RID, example:
dotnet publish -r win-x64 -c Release

Trimming unused assemblies during publish

The .NET core 3.0 SDK comes with a tool that can reduce the size of apps by analyzing IL and trimming unused assemblies. It is like Tree-shaking. The unused framework libraries are removed, reducing size of app, useful when app is published as self-contained app.

To use this feature, set PublishTrimmed=true in project and publish it as self-contained app. It uses IL linker to scan the IL of application to detect which code is actually required, so if reflection or dynamic behaviour is used then such assembly may not be available, to retain such assembly during trimming need to add following in project file or using alternative ways mentioned here

<ItemGroup>
<TrimmerRootAssembly Include="System.IO.FileSystem" />
</ItemGroup>

HTTP/2 support in HttpClient

HttpClient now add supports for making HTTP/2 requests. While the default is HTTP/1.1, the HTTP/2 can be used by setting the version on your HTTP request message

using (var request = new HttpRequestMessage(HttpMethod.Get, "/") { Version = new Version(2, 0) })// or set default version
var client = new HttpClient(){DefaultRequestVersion = new Version(2, 0)};

SDK size improvements

The .NET Core SDK is significantly smaller with .NET Core 3.0. The SDK is constructed using purpose-built “packs” of various kinds (reference assemblies, frameworks, templates) instead of NuGet packages, which included many artifacts that were not required and wasted a lot of space.

Performance improvements

There are tons of performance improvements, check out Performance Improvements in .NET Core 3.0 blog post for more information.

.NET Platform Dependent Intrinsics

Many APIs are added that allow access to certain performance-oriented CPU instructions, such as the SIMD or Bit Manipulation instruction sets. These instructions can help achieve big performance improvements in certain scenarios, such as processing data efficiently in parallel. Also, Floating point APIs have been updated to comply with IEEE 754–2008 revision.

Cryptography

AES-GCM and AES-CCM are supported ciphers, implemented via System.Security.Cryptography.AesGcm and System.Security.Cryptography.AesCcm. These algorithms are both Authenticated Encryption with Association Data (AEAD) algorithms, and the first Authenticated Encryption (AE) algorithms added to .NET Core.

NET Core 3.0 now supports the import and export of asymmetric public and private keys from standard formats, without needing to use an X.509 certificate.

Thanks for reading, there are many more features please check out release blog for more details.

--

--

--

Full stack .Net developer, Web developer and Web Surfer.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

CSS Basic: Font weight

8 Phases of Mobile App Development Life Cycle

CI4 launches web development app only on its current release and rework — refactor set on the stage.

Car Hacking | faster reverse engineering using CanoPy

Troubleshoot Issues Installing Extensions and Add-ons for Creative Cloud apps

Google Summer of Code 2021: Sympy (Week-5)

How to install an SSL Certificate on Google Cloud Platform?

Introduction to HMS Accelerate Kit, Importance of Multithreading and Application on Project

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chirag Rupani

Chirag Rupani

Full stack .Net developer, Web developer and Web Surfer.

More from Medium

Understand Advanced AssemblyLoadContext with C#

Global Using Directive in C# 10 with net 6.0

How to Create SVG Files Programmatically in C# .NET

【C#】Behavioral Patterns Iterator Mode