Introduction
.NET Core, the open source and cross-platform cousin of the .NET Framework, was first released in 2016 and supports Windows, Linux and Mac. The latest release, .NET Core 3.0, with a significant number of changes and improvements, was released on 23rd September 2019. The most important changes are discussed in this article.
Major Changes
Windows Desktop Support
Desktop developers have long been waiting for WinForms and WPF support in .NET Core. With the release of .NET Core 3.0, developers can now develop WinForms and WPF apps for .NET Core.
The WPF designer is part of Visual Studio 2019 16.3. The Windows Forms designer is available separately as a VSIX download. It is still in preview and does not support all features of WinForms development in .NET Framework. Feedback from developers about the WinForms designer has been mixed with some calling it “cranky”. Microsoft does not recommend moving your WinForms apps to .NET Core 3.0 yet.
According to Microsoft, backward compatibility was one of the design objectives and most WinForms and WPF applications work “as-is” with .NET Core 3.0 without any code changes. Note that the desktop apps run only on Windows.
You can create and build desktop applications from the command line using the .NET CLI. For example, to quickly create a new Windows Forms app:
dotnet new winforms -o mywinformapp
cd mywinformapp
dotnet run
For creating a new WPF app, use:
dotnet new wpf -o mywpfapp
cd mywpfapp
dotnet run
Native Executables
.NET Core 3.0 produces native executables that can run directly without the dotnet
command. It was earlier available only with self-contained applications, and is a new feature for framework-dependent applications.
#.NET 2.1 and older
dotnet myapp.dll
#.NET 3.0
myapp.exe -- on Windows
./myapp -- on Linux/MacOS
Since the executable produced is native code, it will only run on the operating system and CPU class it was compiled for. For example, an executable produced for Windows will not run on Linux and one produced for x64 will not run on ARM, etc. You can continue using dotnet
command to start your apps as usual, if you prefer.
JSON APIs
JSON APIs for reader/writer, object model and serialization scenarios have been added. These APIs minimize allocations that result in faster performance, and much less work for the garbage collector. These APIs were built from scratch on top of Span<T>
and use UTF8 under the covers instead of UTF16 (like string
).
A Better Garbage Collector
The garbage collector uses less memory by default, often a lot less. This improvement is very beneficial for scenarios where many applications are hosted on the same server. The garbage collector has also been updated to make better use of large numbers of cores, on machines with >64 cores.
Performance Improvements
.NET Core 3.0 comes with a host of performance improvements. Check out the complete list and performance benchmarks here: Performance Improvements in .NET Core 3.0.
Docker Enhancements
.NET Core applications targeted for Docker now work predictably and efficiently in containers. When a container has been configured for limited memory or CPU, the garbage collector and thread pool work much better. .NET Core docker images are smaller, particularly the SDK image.
ARM64 Support
ARM32 support for Linux and Windows were introduced in .NET Core 2.1 and 2.2, respectively. .NET Core 3.0 supports ARM64 which makes it easy to write code for IoT.
IoT Support
Support for IoT development has been enabled through support for Raspberry Pi and ARM chips. You can also use the remote Visual Studio debugger to debug your apps. .NET 3.0 has support for GPIO, PWM, I2C, and SPI protocols, to enable reading sensor data, print messages on a display, interact with radio, etc. IoT devices can be configured through a microsite using APIs hosted on ASP.NET.
Cryptography
.NET Core 3.0 supports algorithms for Authenticated Encryption (AE) and Authenticated Encryption with Association Data (AEAD), through –AES-GCM
and AES-CCM
ciphers, implemented via System.Security.Cryptography.AesGcm
and System.Security.Cryptography.AesCcm
.
Asymmetric public and private keys can now be imported from and exported to, from standard formats, without needing to use an X.509 certificate. Support for inspecting PKCS#8 files and inspecting/manipulating PFX/PKCS#12 files has been added.
API Differences from .NET Core 2.2
For a list of all API changes from .NET Core 2.2, check out this link (follows standard diff formatting):
Language and Framework Enhancements
As part of the .NET Core 3.0 release, related releases were made to languages and frameworks.
C# 8
C# 8 comes with a host of changes and language improvements that make it more interesting than ever to write code in C#. Some of the major changes include:
- Async streams (Combination of iterators and async methods)
- Range and Index classes make it easy to work with arrays.
- Nullable Reference Types to handle nulls code elegantly.
- Interfaces can have default implementations for methods.
- The
using
declaration can be scoped to a variable to avoid code indentation. switch
statement supports pattern matching and now returns an expression.
A separate article is on its way to discuss C# 8 in detail. Watch out.
F# 4.7
F# is a mature, open source, cross-platform, functional-first programming language which was developed entirely via an open RFC (requests for comments) process. For a list of all changes to the latest version of the language, visit Announcing F# 4.7
ASP.NET Core 3.0
ASP.NET Core 3.0 introduces Blazor, a new framework building interactive client-side web UI with .NET Core. For more information, visit What’s new in ASP.NET Core 3.0.
Entity Framework Core 3.0
EF Core 3.0 contains more than 600 product improvements including major features, minor enhancements, and bug fixes. Check out this link for a detailed discussion of the major changes.
IDE Requirements
Visual Studio users must install or upgrade to Visual Studio 2019 16.3, which is a required update to use .NET Core 3.0 on Windows.
It would be Visual Studio for Mac 8.3 for Mac users that want to use .NET Core 3.0.
For developers using Visual Studio Code, just update the C# extension to the latest version to use .NET Core 3.0.
Current Release vs Long-Term Support Release
.NET Core 3.0 is a ‘current’ release and will be superceded by .NET Core 3.1 which will be a long-term supported (LTS) release, i.e., supported for at least 3 years. Adopting to .NET Core 3.0 now will enable you to easily migrate to .NET Core 3.1 when it is released in November 2019.
Supported Platforms
.NET Core 3.0 is supported on the following platforms:
- Alpine: 3.9+
- Debian: 9+
- openSUSE: 42.3+
- Fedora: 26+
- Ubuntu: 16.04+
- RHEL: 6+
- SLES: 12+
- macOS: 10.13+
- Windows Client: 7, 8.1, 10 (1607+)
- Windows Server: 2012 R2 SP1+
.NET Core 3.0 will be available in RHEL 8 in Red Hat Application Streams, after several years of collaboration between Microsoft and Red Hat.
Release Notes
Check out the official Release notes here:
Roadmap and Future Plans
A summary of roadmap and future plans for .NET Core 3.0 and .NET Framework 4.8 can be found here:
Conclusion
.NET Core is on its way to achieve what .NET Framework was initially intended for but couldn’t: True cross-platform execution similar to Java. Though initial versions of .NET Core had a lot of issues, the current version has successfully eliminated the major bottlenecks and is enabling us to write true cross-platform code using .NET. Container and IoT support make it the most ideal platform for .NET developers to write next gen apps.
More Reading
The post New Features and Enhancements in .NET Core 3.0 appeared first on The Developer Space.