What I Learned from .NET Conf 2020

.NET Conference 2020 banner Source: .NET Conf 2020

Last week .NET Conf 2020 happened. Taking place November 10th-12th, the conference celebrated 10 years as a virtual event for developers. This year was the first time I was able to watch most of the sessions in a timely manner so I decided to highlight what I learned.

If you don’t know, .NET Conf is a free, 3-day virtual developer event, co-organized by Microsoft and the .NET community. This year .NET 5 was launched at the conference. It’s a major release that includes tons of new features and improvements which were the main topics for most of the sessions.

.NET 5 Released

.NET 5 is the next version of .NET Core. It’s everything that exists in .NET Core and more. .NET 5 continues Microsoft’s effort to make .NET a free, open-source, cross-platform framework that unifies desktop, Web, cloud, mobile, gaming, IoT, and AI applications.

Scott Hunter kicked off the conference with an opening keynote to welcome the audience to .NET 5. He talked about the new features and had some great guests join in and show off some demos.

.NET Conf 2020 slide listing .NET 5 features Source: .NET Conf 2020 Keynote - Welcome to .NET 5

.NET 5 comes with continued improvements in overall performance. Hunter showed the improvements in performance compared to .NET Core 3.1 where .NET 5 performed 38% better with Plantext, 42% with Json serialization, and 20% with Fortunes when performing tests on TechEmpower equivalnet hardware. He also showed performance improvements in sockets on Linux and serialization of large collections and arrays.

One thing that surprises me is the new features and updates for Windows desktop applications. .NET 5 continues to support Windows Forms and WPF designers. A new desktop control named WebView2 was introduced. It basically allows you to embed Microsoft Edge (based on Chromium) in your native desktop applications.

ClickOnce application deployment was added to support publishing client applications. It gives you the ability to simply right-click on your application and publish it.

Single file applications are a part of unifying the .NET platform by allowing applications to be published as a single file. .NET Conf 2020 had a 20 minute session that provided an Overview of Single File Applications in .NET 5. If you want to see the process of publishing a single file application you can skip to the demo here.

C# 9 Released

C# 9 was released along with .NET 5 and it has some new features in the language. It continues to try and simplify things for developers with less code, which is why I found records and top-level programs to be pretty cool features. Both features aim to remove some of the boilerplate code that’s written in a lot of applications.

Records

A record is a new type of class. It’s a reference type that’s immutable by default. Consider the following code:

public class Person 
{
    public Person(string firstName, string lastName, int age)
    {
        FirstName = firstName;
        LastName = lastName;
        Age = age;
    }

    public string FirstName { get; set; }
    public string LastName { get; set; }
    public int Age { get; set; }
}

Using the record keyword, the code above can now be written with only one line of code:

public record Person(string firstName, string lastName, int age);

Top-level statements

Top-level statements aim to remove more unnecessary boilerplate and simplify getting a program up and running more quickly. It allows the typical structure of namespace, class, Main() method to be excluded. Consider the following code:

using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

The code above can now be written as:

using System;

Console.WriteLine("Hello World!");

Visual Studio

Visual Studio 2019 update 16.8 was also announced during the opening keynote. There’s also a preview version of update 16.9 released as well.

.NET Conf 2020 slide showing Visual Studio updates Source: .NET Conf 2020 Keynote - Welcome to .NET 5

As you can see .NET 5 is included and it has Linux debugging where you can build a .NET 5 project that can be ran and debugged in Linux just like Windows.

There’s also GitHub Codespaces. A codespace is basically a container or virtual environment hosted in the cloud. It can be configured for specific projects and applications based on how it’s defined in the git repository. Using codespaces drastically reduces time spent on setting up and maintaining development environments. You can watch a demo of using a codespace from the GitHub + Visual Studio ❤ .NET session.

You can also check out the Visual Studio 2019 and beyond session to learn more about what all you can do in Visual Studio 2019.

Blazor

.NET Conf 2020 had tons of sessions on Blazor. If you’re like me and haven’t heard much about Blazor, it’s a feature of ASP.NET that allows you to create interactive web UIs using only C#. It eliminates having to go back and forth between JavaScript, HTML, CSS and other front end frameworks. You can develop the front end and back end of a web application with the same developers all using C#.

.NET Conf 2020 slide showing Blazor notes Source: .NET Conf 2020 Keynote - Welcome to .NET 5

In .NET 5, Blazor WebAssembly performance was improved across the stack. Support was added for Blazor Web Assembly Pre-rendering to gain faster load times. It supports server-side prerendering to make pages load faster on the first load, and lazy loading as well, which allows components on a page to load only as they are viewed or utilized.

CSS isolation is included which makes it easier to manage CSS by isolating seperate CSS files for each Razor component.

Auto-refresh is included as well so now UI changes can instantly be displayed in the browser after they are saved.

Packages can now automatically add their own CSS and JavaScript references so you don’t have to manually reference them yourself.

There’s a new InputFile component that renders an input HTML element with a file type so it can be used to upload files in a web application.

A protected browser storage feature allows Blazor applications a method of storing data locally and safely inside the browser using encryption.

Conclusion

Overall I thought .NET Conf 2020 was pretty cool. It was great to watch the sessions and see some of the awesome new features and technology that Microsoft is creating. I’m definitely going to try Blazor and check out WebView2 when I have time.

If you want to catch up on all the sessions, there’s a playlist of them all on the .NET YouTube channel. You can also watch them on Channel 9.

comments powered by Disqus