Alongside the new preview, Redmond also unveiled .NET now hosts a fully supported release of Blazor WebAssembly. Let’s start with C#, which is moving to version 9.0 in preview. Microsoft says the new build brings a focus on “supporting terse and immutable representation of data shapes”. Specifically, C# 9.0 gives developers the ability to assign values to object properties when it is created. By focusing on initializers, Microsoft’s lead C# maintainer Mads Torgersen says the language is removing a major hurdle facing developers. The work on supporting terse and immutable representation of data shapes focuses on object initializers, which let users assign values to properties of an object at creation time. But as Torgersen explains, a big limitation today is that properties must be mutable for object initializers to work. “They [properties] function by first calling the object’s constructor (the default, parameterless one in this case) and then assigning to the property setters,” he explains. “Init-only properties fix that! They introduce an init accessor that is a variant of the set accessor which can only be called during object initialization,” Torgersen said, before showing this example: public class Person { public string FirstName { get; init; } public string LastName { get; init; } }
Blazor WebAssembly
Elsewhere in the .NET and C# realm, Microsoft confirmed Blazor WebAssembly has left preview and is now widely available. This new framework for creating interactive web application allows dotnet developers to create solutions that run on a browser with WebAssembly, while still operating like a Progressive Web App (PWA). Daniel Roth, a principal program manager with Microsoft’s ASP.NET team, said Blazor WebAssembly is a “fully featured and supported release … that is ready for production use”. “Blazor WebAssembly includes a proper .NET runtime implemented in WebAssembly, a standardized bytecode for the web. This .NET runtime is downloaded with your Blazor WebAssembly app and enables running normal .NET code directly in the browser. No plugins or code transpilation are required,” said Roth.