The transformation of. Net ecosystem NET 6

Time:2022-1-2

. net 6 is from Net 4 framework, the largest version update seen by the ecosystem, although Net core is a very big strategic initiative since 2014, but Net 6 is a really powerful and very important version.

Microsoft MVP lab researcher

The transformation of. Net ecosystem NET 6

It will be officially released on November 9, 2021 Net 6, maybe you think Net 5 has just been released and I have just started to use it NET Core 3.1, . Net6 will be released again. That’s right Net 5 was released on November 10, 2020 Net core 3.1 was released as early as December 2019, and Microsoft has promised to release a version every year NET , . Net 6 is the release according to the schedule. There is a supporting policy corresponding to the release rhythm of this version:
https://dotnet.microsoft.com/…

The transformation of. Net ecosystem NET 6
From Net 5, the odd version has an 18 month patch cycle, while the even version has a three-year patch cycle. If you have migrated your app to Net core 3.1, please note that it has a three-year patch cycle, which will end in December 2022; If you are still in any previous version Net core, you are no longer in the support cycle. Although it has not yet been announced Net framework 4.6.2 and later support officially ended, but Microsoft said Net framework 4.8 is The last major version of the. Net framework will be updated with the windows support plan: new feature development should be for what was previously called Net core (such as. Net 6).

. net 6 has brought many performance improvements and productivity gains, and it is also a long-term supported version. Yes Net Net has made some impressive progress in execution speed and memory usage. If you haven’t been followed, you are likely to be Net framework. For this point, you can see the test report of techempower. For details, see:

https://www.techempower.com/b…

great changes have taken place

We started from Net 5 began to look forward, as a long-term support (LTS) version Net 6 represents further improvements and has a lot of design and performance improvements. We will mainly look at ASP Net 6 runtime performance improvement list and Net 6, you can see that the change is very large.

C# language update

The latest version of c# language is 10.0. There are several interesting changes. For clean csharper, global using and file scope namespace are complementary. Now you can declare global usage for the entire compilation unit (probably the project) and avoid adding the same instruction set to the at the top of each file. File scoped namespaces also allow you to declare namespaces that apply to all code in a given file without a single line, more matching curly braces, and fewer dent levels in the source file.

before

CSharp9_Widget.cs

using System;
using System.Collections.Generic;
using System.Linq;

namespace MyNamespace.Data
{
  class Widget
  {
    private List<WidgetPart> _widgetParts;
    public IEnumerable<WidgetPart> RequiredParts => 
      _widgetParts;

    public bool RequiresPart(int partId) => 
      _widgetParts.Any(x => x.Id == partId);
  }
}

CSharp9_WidgetPartsInventory.cs

using System;
using System.Collections.Generic;
using System.Linq;

namespace MyNamespace.Data
{
  class WidgetPartsInventory
  {
    private Dictionary<int, WidgetPart> _widgetPartsById;

    public bool HavePartsToBuildWidget(Widget widget) => 
      widget.RequiredParts.All(p => 
        _widgetPartsById.ContainsKey(p.Id));
  }
}

Now?

CSharp10_GlobalUsing.cs

global using System;
global using System.Collections.Generic;
global using System.Linq;

CSharp10_Widget.cs

namespace MyNamespace.Data;

class Widget
{
  private List<WidgetPart> _widgetParts;
  public IEnumerable<WidgetPart> RequiredParts => _widgetParts;

  public bool RequiresPart(int partId) => 
    _widgetParts.Any(x => x.Id == partId);
}

CSharp10_WidgetPartsInventory.cs

namespace MyNamespace.Data;

class WidgetPartsInventory
{
  private Dictionary<int, WidgetPart> _widgetPartsById;

  public bool HavePartsToBuildWidget(Widget widget) => 
    widget.RequiredParts.All(p => 
      _widgetPartsById.ContainsKey(p.Id));
}

There are other updates related to record, schema, and interpolation strings, but most of these updates are syntax sugar.

ASP. Net core update

If you read the instructions for each version, it’s easy to see ASP Net core is a core. It has many interesting features from network host and minimum API, hot overload to blazor.
Machine and minimal API, thermal overload to blazor, have many interesting features.

Network host and minimum API

From ASP Net core, each application splits the application initialization code into program CS (for creating a web host) and “startup.cs” (for configuring application problems such as routing and IOC container configuration). In particular, the startup class has a magical feeling that its methods have never been called directly by developers. Instead, webhost automatically calls the configuration method behind the scenes.

ASP. Net team analyzed this design, and compared with other web frameworks, they think that setting involves too much. Therefore, the smallest API concept was born. Now, the application initialization can all be contained in one file. And you may be surprised that the main method is no longer needed. Routes can be defined in application settings, greatly reducing the amount of code to start and run an application.

var builder = WebApplication.CreateBuilder(args);

var app = builder.Build();
app.MapGet(“/”, () => “Hello World!”);
app.Run();

Of course, if you still like the organizational style of separating service settings from application configuration, you can still create extension methods for iservicecollection and iaapplicationbuilder and call them from builders and application objects.

Hot Reload

For several years, many JavaScript frameworks have supported hot overloading, and now it has become ASP. Net in c# as well Net core application standard configuration: through hot reloading, you can edit your c# code during the application running (under the debugger), and your code changes will be automatically reflected in your application without losing the application status. In other words, the application does not need to be restarted. This should be a good improvement for debugging and interactive development workflows. This function is very important for development. It is this small function that Microsoft recently angered open source Net community. The good news is that Microsoft has listened to the voice of the community and restored the hotreload function through cli. For details, see:
https://www.cnblogs.com/shany…

Blazor

In ASP Net core 6 has a lot of updates about blazor. For example, blazor applications can now be compiled directly into the web assembly to speed up the application on the same code as the IL interpreted (i.e., locally compiled. Net) version. The local compile / debug experience is still fast because the long compile time is only suitable for packaging / release. When it comes to performance, blazor webassembly enables multithreading of client code. JavaScript is subject to a single thread in the browser. True multithreading opens up new possibilities for applications that can benefit from parallel processing (depending on browser support, of course).

There is also a very interesting feature that enables blazor to write desktop applications through Maui. The biggest advantage of blazor is that developers can completely write web applications in c# without having to switch to JavaScript in order to write the front end. Without the extra seam between c# and JavaScript, there is no need for a mapping layer between front-end and back-end code. You can use the same c# model on both sides, which means less code is required and therefore less time is required to develop the application. The blazor desktop further extends this concept to allow this shared code to now integrate seamlessly with desktop applications.

MAUI

Maui is the abbreviation of multi platform app UI. It is Microsoft’s next attempt to cross platform UI framework. Maui is the evolution of xamarin and also includes the desktop platform. It allows you to target IOS, Android, MacOS, and windows from a single code base. Maui handles the abstraction of native platform APIs, so you can access content such as device sensors in a platform independent manner. One impression of xamarin is that they end up with few interfaces and don’t look good on any platform. How Maui will solve this problem remains to be seen. If you are concerned about development speed and maintenance costs across multiple platforms, Maui deserves careful study. Maui will be officially released in the second quarter of 2022. It is recommended to take a wait-and-see approach and make a small attempt to understand the long-term development direction of the platform before it is fully adopted.

Microsoft MVP

The transformation of. Net ecosystem NET 6

Microsoft’s most valuable expert is a global award awarded by Microsoft to third-party technology professionals. Over the past 28 years, technology community leaders around the world have won this award for sharing expertise and experience in their online and offline technology communities.

MVP is a strictly selected expert team. They represent the most skilled and intelligent people. They are experts who are enthusiastic and helpful to the community. MVP is committed to helping others through lectures, forum Q & A, creating websites, writing blogs, sharing videos, open source projects, organizing meetings, and helping users in the Microsoft technology community use Microsoft technology to the greatest extent.
For more details, please visit the official website:
https://mvp.microsoft.com/zh-cn


Here are more official Microsoft learning materials and technical documents. Scan the code to get the free version!
The content will be updated from time to time!
The transformation of. Net ecosystem NET 6