Microsoft held its big Build developer conference on 6th May 2019. The conference had major announcements pertaining to a new .Net Core 3.0 preview (in conjunction with the September release), to Visual Studio Online, the support for the development of desktop application software, IoT apps, and artificial intelligence/machine learning. Since this write-up is solely written with the purpose of providing useful information pertaining to .Net Core 3.0 Preview 5 we will be concentrating on that in this write-up.
Microsoft has already announced that after .Net 3.0, the Core offerings will be combined with other .Net implementations, including .Net Framework Xamarin, IoT, Azure cloud, Mono, AI, and several others. This will make .Net 5 as a solitary unified version which is slated to release in November 2020. We will throw light on this a little later in our blog i.e., at the end of the write-up. In the forthcoming sections of this content piece, we will be providing information pertaining to some of the ingenious features that are going to rock the .Net development sphere come September, this year. We promise after reading this write-up, you will be able to learn about new things about .Net development which will make your life as a .Net developer easier in the near future.
But, before we look at the different features present in .Net Core 3.0 Preview 5 it is important to look at the brief history behind the launch of .Net Core 3. .Net Core 3 came into prominence on May 7, 2018 after a brief announcement at Microsoft Build. The first preview happened on December 4, 2018 while the second one was done on February 1, 2019.
The first public preview was done on December 4, 2018. The second one happened on February 1, 2019. The great news is that, .Net Core 3 framework now supports artificial intelligence/machine learning, IoT apps, and also desktop application software.
You can download .Net Core 3.0 Preview 5 now for MacOS, Linux, and Windows. It is important to note that ASP.NET Core and EF Core also released their updates simultaneously with Preview 5 on 6th May 2019.
Now, that you have gained a basic insight about the history behind the launch of .Net Core 3, as promised it is time to look at the superlative features present in .Net Core 3.0 Preview 5.
WPF and Windows Forms Update
There is a drastic performance enhancement for WPF and Windows Forms with this new update. Did you know? With the help of this recent update WPF and Windows Forms work as a conjunction ahead-of-time with the help of crossgen. There are a number of reports from the .Net community that validate drastic performance improvement between Preview 4 and Preview 5. During the .Net Core 3.0 Preview 4 Microsoft published more code for WPF which is expected to complete by Preview 7.
Introduction to new SqlClient
Before we discuss this update it is important to know about the function of SqlClient. A SqlClient is the data provider that is used by developers to access SQL Server and Azure SQL database. This is done either with the aid of popular .Net o/RMs, like EF Core or Dapper. Alternatively, you can even employ ADO.NET APIs.
Before this update, SqlClient used to get shipped as a part of a package deal of the System.Data.dll assembly in .Net framework. There was a need to update .Net Framework in Windows to make requisite changes on SqlClient. This was a makeshift arrangement for the .Net developers. But, with the new update, the concentration has been to provide stability. How?
By shifting the SqlClient development out-of-band.
With the help of Microsoft.Data.SqlClient, a new version of SqlClient it is possible to apply NuGet package to both .Net Framework and .Net Core applications.
today it has become easy to apply NuGet package to both .Net Framework and .Net Core applications.
(Note: .Net Core applications include .Net Core 3.0).
The New Things Present in Microsoft.Data.SqlClient
There has always been a concurrent loophole present in .Net core i.e.; lack of support for always encrypted. In this preview this pain area has been addressed. Two other important features are now available on .Net Framework or .Net Core. Namely: Data classification and UTF-8 support. Microsoft has opted to release both of these in conjunction with enhancements in Microsoft.Data.SqlClient at the same time as .Net Core 3.0 release.
What about System.Data.SqlClient?
System.Data.SqlClient will still be effective and receive significant security updates. So, if you are thinking about migrating there is no need for it. If your application is performing up to the mark. But, if in case, you are looking to take advantage of the new features present in this preview, consider upgrading to Microsoft.Data.SqlClient. The process of upgrading is quite simple. Simply install the package and then update the SqlClient namespace in your code.
Note: At times the changes will get affected to the configuration or updated versions of O/RMs is totally contingent on the new SqlClient.
Publishing Solitary EXEs
With the help of this new update, it is now possible for you to publish a single file executable with dotnet publish. This solitary EXE effectively works as a self-extracting executable. It consists of all dependencies i.e.; native dependencies, as a resource. During the start, all the dependencies will get copied to a temporary directory. It will then get loaded there.Then it only requires to unpack the dependencies once.
After this process, the initial process gets finished very quickly without any penalty.
In order to enable the publishing button, add the PublishingSingleFile property to your project file. Alternatively, you can even integrate a new switch on the commandline.
Use this command, in order to get a self-contained single EXE application for a 64-bit Windows:
You need to ensure that the single EXE applications are architecture specific. This way, it is possible to specify a runtime identifier. To get more specific information, look at Single file bundler.
Assembly trimmer, single file bundling, and ahead-of-time compilation (through crossgen) are all new features present in .Net Core 3.0 Preview 5. The amazing part is, you can employ these features together or separately.
Introducing the JSON Serializer (and an update to the writer)
The JSON Serializer is the advanced version of Utf8JsonReader and Utf8JsonWriter. The JSON Serializer is one step ahead of the high-performing Utf8JsonReader and Utf8JsonWriter. The great part is, it deserializes objects from JSON and serialize objects to JSON. There are minimal memory allocations. It also includes support for reading and writing JSON with Steam asynchronously.
In order to get started, employ JsonSerializer Class in the System.Text.Json.Serialization namespace.
Ut8JsonWriter Design Change
On the basis of feedback received from .Net developers from the perspective of usability and readability, Microsoft has introduced design change to Ut8JsonWriter. This was introduced in Preview 2. The writer is now a regular class, instead of a ref struct and executes IDisposable. This enables you to add support for writing to streams directly. Microsoft has also got rid of JsonWriterState. Now, JsonWriterOptions need to be passed-in directly to the Utf8JsonWriter, which maintains its own state. It is even possible for the developers to offset the allocation. This can be done by employing the new Utf8JsonWriter Reset API that lets the developers to reset its state and re-use the writer. There is also an in-built IBufferWriter<T> known as ArrayBufferWriter<T> that can be employed with the Utf8JsonWriter.
Let’s now divert our attention to the code snippet that highlights the writer changes:
If you wish to learn more about the design change, click here.
Microsoft has already announced that .Net Core 3.0 will be .Net 5. This is fantastic news for all .Net developers since there will be only a single .Net moving forward in the future. Developers will be able to use it to target MacOS, iOS, tvOS, Linux, WebAssembly, watchOS, and much more.
The .Net Core team is also expected to introduce new .NET APIs, language features, and runtime capabilities as a part of the first preview of .Net 5 which is expected to release in November 2020.
The great part is, .Net 5 will integrate the positive aspects of .Net Core and Mono, runtime for .Net Core to create a solitary platform that will be employed for all your contemporary .Net code. On top of that, this release will support future enhancements, including Visual Studio Code, Visual Studio for Mac, and Visual Studio 2019.
So, are you expected about the future of .Net Core technology?
Harshal Shah is CEO at WebITGurus, WebITGurus is a best .Net Development Company Offering .Net Applications Development Services like, SharePoint , C#, WCF Solutions, IOT Solution and Asp.net Development.