介绍

微软官方博客详细地介绍了 .NET 6 新增的特性:

成熟

统一命名

统一命名,与之前的混乱告别了。虽然是从 .NET 5 开始的,但是以后再搜索 .NET 6 相关的内容,就不会搜到旧版本的内容了。

We are also taking the opportunity to simplify naming. We thought that if there is only one .NET going forward, we don’t need a clarifying term like “Core”. The shorter name is a simplification and also communicates that .NET 5 has uniform capabilities and behaviors. Feel free to continue to use the “.NET Core” name if you prefer it.

长期支持版本

第一个稳定 LTS 版本,维护 3 年。

生命力旺盛

微软制定了 .NET 的发布计划,决定 .NET 每年发布一个版本,偶数版本是 LTS,奇数版本是普通版本。这样 .NET 就进入了快车道,以后发展速度会非常稳定。

从 Visual Studio Code 与其他文本编辑器比较就可以知道,Visual Studio Code 每个月发布一个新版本,功能迭代非常快,很多缺失的功能都会在新版本中加上,Bug 也会很快修复。而同期的 Atom Sublime 等等几乎没了声音。

在 Stack Overflow 2021 年开发者调查中显示,Visual Studio Code 选择占比高达 71%:

在这背后是微软投入了大量的人力物力。对于 .NET 也是类似的,有微软这个金主在背后不断地支持,相信 .NET 一定会发展地更好。

特性

C# 10

Microsoft .NET 6 also features C# 10, with capabilities to make code faster and more expressive; F# 6, with performance, ease of use, and uniformity improvements;

单文件应用

Single-file Apps

In .NET 6, in-memory single file apps have been enabled for Windows and macOS. In .NET 5, this deployment type was limited to Linux. You can now publish a single-file binary that is both deployed and launched as a single file, for all supported OSes. Single files apps no longer extract any core runtime assemblies to temporary directories.

这个功能非常方便部署。

从源码构建

可以从源码构建,这意味着你可以从头编译一个自己的版本,做任何修改,保证有完整的控制权。

热重载

  • Hot Reload enables you to skip rebuilding and restarting your app to view a new change — while your app is running — supported in Visual Studio 2022 and from the .NET CLI, for C# and Visual Basic.

这个功能正如字面意思,可以方便地进行开发调试,免去了迭代过程中最大的一部分:重新启动。

Arm64 支持

支持 Arm64,包括 macOS Apple Silicon and Windows Arm64.

性能

具体技术

Profile-guided optimization

File IO now has support for symbolic links and has greatly improved performance with a re-written-from-scratch FileStream.

CrossGen 2, for ahead-of-time pre-compilation.

案例

微软登录服务

The gateway is present in 54 Azure datacenters worldwide and serves ~185 Billion requests each day. Up until recently, Azure AD’s gateway was running on .NET 5.0. As of September 2021, it’s running on .NET 6.0.

Efficiency gains by moving to .NET 6.0 The below image shows that application CPU utilization dropped by 33% for the same traffic volume after moving to .NET 6.0 on our production fleet.

IDE 支持

Visual Studio 2022 同步发布,支持 .NET 6。

Rider 很快也会发布支持 .NET 6 的新版本。

游戏开发

.NET 可以非常方便地用于游戏开发

客户端

虽然 Unity 没有集成最新版本的 .NET,但是已经列在计划中了:

服务器

因为服务器的环境是受开发者控制的,因此可以使用最新版本的 .NET。有很多使用 .NET 开发的服务器框架: