A second preview of .NET Core 3? Shucks, Microsoft. You spoil us
JSON writing gets snappier while Remond nails its colours to the IoT mast
Microsoft has kicked out a second preview of .NET Core 3 and naturally we fired up the IDE to see what has changed.
Aside from the improvements in C# 8.0, which require the unwary to manually select the beta language in the project's advanced build properties in order to actually use them, there are some handy new features among the fixes.
JSON and the .NET Core-onauts
First up are the improvements in JSON performance. The arrival of
Utf8JsonWriter heralds a speed bump of 30-80 per cent over JSON.NET's writer when writing UTF-8 encoded JSON text from .NET types.
Utf8JsonReader had already made an appearance in .NET Core 3 Preview 1, claiming a doubling of performance over the Json.NET equivalent, and while less dramatic this time around, the improvement writing the stuff is welcome.
Building on that,
Utf8JsonReader in Preview 2 is
JsonDocument, which takes the JSON data and shovels it into a read-only Document Object Model (DOM) which can be queried and elements enumerated. Again, Redmond reckons that parsing a JSON payload and accessing its members is two to three times the speed of Json.NET.
Your mileage may vary. While definitely snappier, I didn't see such a dramatic jump, although obviously the type and quantity of data will have an impact and, heck, this is still Preview code.
Another feature of Preview 1 that has seen improvement in this second version is support for the Raspberry Pi's GPIO connector. IoT devs just love reading from and writing to those pins to drive the likes of LED displays or read sensor data and to that end a couple of NuGet packages have put in an appearance in the form of
Iot.Device.Bindings with APIs for GPIO, SPI, I2C and PWM devices.
Microsoft delivers a second preview of Visual Studio 2019 (a Redmond thing we actually like)READ MORE
Finally the updated preview has seen an improvement to .NET's command line interface to list tools and their manifest, or create a manifest required by local tools. Pluggers of memory leaks will also be pleased to note the arrival of the assembly unloadability capability of
AssemblyLoaderContext. An application can then load and unload an assembly "forever, without experiencing a memory leak". Strong words.
Windows, macOS and a wide variety of Linux distributions are supported by .NET Core 3, although Microsoft is quite keen that penguinistas consider using Snap if their distro supports it. Even Windows 7 remains a supported option.
As for deploying apps written with the thing? Windows users are directed toward the new app package format MSIX, although Microsoft's Rich Lander hinted at a glorious future containing standalone executables (for the desktop at least):
"We are working on making it possible to create standalone EXEs for desktop apps. The Windows team is enable desktop apps to use WinUI/Xaml, so your standalone app will be able to use that UI stack, or WPF or Windows Forms. Your choice."
Let us hope that "standalone" does not mean "shoveling every .NET Core component into one, bloated EXE". That way lies madness and rampant storage consumption. ®
Sponsored: Becoming a Pragmatic Security Leader