.NET 7 Preview 1 Released

.NET 7 Preview 1 Released

.NET 7 builds on the foundation laid by .NET 6, including a unified set of base libraries, runtime, and SDK, simplifying the development experience and improving developer productivity.

Last updated 2/19/2022 1:01 AM
WeihanLi amazingdotnet
13 min read
Category
.NET
Tags
.NET C#

Today, we are excited to announce the next milestone in .NET history. While celebrating the community and 20 years of innovation, .NET 7 Preview 1 marks the first step toward the next 20 years of .NET.

ASP.NET Core Preview 1 and EF7 Preview 1 are also being released today.

.NET 7 builds on the foundation established by .NET 6, which includes a unified set of base libraries, runtime, and SDK, simplifying the development experience and improving developer productivity. Key focus areas for .NET 7 include improving support for cloud-native scenarios, tools that make it easier to upgrade legacy projects, and simplifying the developer experience through easier use of containers.

.NET 7 Preview 1 includes support for nullable annotations in APIs, ongoing JIT compiler optimizations, new APIs, and support for more Hot Reload scenarios.

The .NET release includes products, class libraries, runtime, and tooling, representing collaboration among multiple teams both inside and outside Microsoft. The broader themes covered in this blog post do not encompass all key scenarios and investments for .NET 7. They represent significant areas but are only part of all the important work going into .NET 7. We plan extensive investments in ASP.NET Core, Blazor, EF Core, WinForms, WPF, and other platforms. You can learn more about these areas by reading the product roadmaps:

You can download .NET 7 Preview 1 for Windows, macOS, and Linux.

.NET 7 has been tested with Visual Studio 17.2 Preview 1. If you want to try .NET 7 in Visual Studio products, we recommend using a Preview channel version. Visual Studio for Mac support for .NET 7 previews is not yet available but coming soon.

Modern Client: .NET Multi-platform App UI (.NET MAUI)

.NET MAUI is the future of .NET cross-platform native UI and will be part of .NET 7. On Tuesday, we released .NET MAUI Preview 13. We are currently focused on providing .NET MAUI support for .NET 6 and expect to have a release candidate (RC) soon. After we have an RC available, we will focus on releasing additional RCs until we reach the stability required for General Availability (GA). After .NET MAUI GA is released for .NET 6, we will include it in .NET 7, focusing on topics like improving the inner development loop experience, supporting the latest .NET SDK tools, faster application performance, sharing more code, and enhanced interoperability. Check out the .NET MAUI status and project roadmap for more information.

Modern Cloud: Containers and Cloud-Native

Build cloud-native applications from scratch, leveraging modern web-based resources such as database services and managed containers. Cloud-native architectures can improve the scale of large applications while reducing long-term costs by creating autonomous subsystems (often called microservices) that can be deployed and scaled independently of other areas of the application. Microservices architecture is a popular approach because it is flexible, designed to evolve and scale to limits that are difficult to achieve in monolithic architectures.

.NET 7 will make it easier to build cloud-native applications by exploring improvements to the developer experience, such as:

  • Simplifying the setup and configuration required to implement secure authentication and authorization
  • Improving application startup and runtime execution performance.

We will continue to invest in Orleans, a .NET cross-platform framework for building distributed applications known as "Distributed .NET". We will continue to enhance Orleans' comprehensive documentation and make it easier to use and implement by improving Orleans' integration with existing cloud services like Azure App Services and Azure Container Apps.

Containers are the preferred way for many companies today to deploy cloud-native applications and microservices. Relying on containers brings challenges, including managing compatibility, building and publishing images, making images more secure, and simplifying image size and performance. We believe there is an opportunity to create a better experience with .NET containers.

To help customers address these challenges, we plan to make significant improvements to .NET development with containers in .NET 7. For example, we will explore building containers directly via MSBuild as a new SDK feature. We plan to enhance telemetry to improve container observability. We will also focus on making our container images smaller, faster, and more secure, while exploring high-demand application models like rootless and distroless.

Modernization: Upgrading .NET Applications

Since the release of .NET 6, developers have been upgrading their applications to take advantage of new performance improvements, productivity features like Minimal APIs and Hot Reload, new runtime and C# language innovations, and the availability of a mature library and tool ecosystem. In .NET 7, we will continue to enable you to upgrade existing .NET applications to the latest .NET platform and technologies. More analyzers, code fixes, and support for additional application types in the .NET Upgrade Assistant will help you confidently upgrade more of your application portfolio and reduce time on repetitive tasks involved in the upgrade.

We also know that each .NET application model (ASP.NET, WinForms, WPF, etc.) has its unique challenges in modernization and may lack features needed by developers or support from the platform itself. For some of these, like WCF, there may not be a clear direction. We will focus on providing appropriate guidance, documentation, and tools to make these .NET application models easier to upgrade.

Support

.NET 7 is a Current release, meaning it will receive free support and patches for 18 months from the release date. It is important to note that all releases are of equal quality. The only difference between LTS and Current releases is the length of support. For more information on the .NET support policy, see the .NET and .NET Core Official Support Policy.

Breaking Changes

You can find the latest list of .NET 7 breaking changes by reading the breaking changes documentation for .NET 7. It lists breaking changes by area and version with links to detailed explanations.

To see proposed breaking changes still under review, follow the Proposed .NET Breaking Changes GitHub issue.

Preview 1

The Preview 1 release now offers the following features.

Nullable Annotations for Microsoft.Extensions

We have made progress in adding annotations for nullability to the Microsoft.Extensions.* libraries. In .NET 7 Preview 1, the following libraries have been annotated for nullability:

  • Microsoft.Extensions.DependencyInjection.Abstractions
  • Microsoft.Extensions.Logging.Abstractions
  • Microsoft.Extensions.Primitives
  • Microsoft.Extensions.FileSystemGlobbing
  • Microsoft.Extensions.DependencyModel
  • Microsoft.Extensions.Configuration.Abstractions
  • Microsoft.Extensions.FileProviders.Abstractions
  • Microsoft.Extensions.FileProviders.Physical
  • Microsoft.Extensions.Configuration
  • Microsoft.Extensions.Configuration.Binder
  • Microsoft.Extensions.Configuration.CommandLine
  • Microsoft.Extensions.Configuration.EnvironmentVariables
  • Microsoft.Extensions.Configuration.FileExtensions
  • Microsoft.Extensions.Configuration.Ini
  • Microsoft.Extensions.Configuration.Json

By the time .NET 7 is released, we plan to add nullable annotations to all Microsoft.Extensions.* libraries. You can view the remaining libraries and track progress at dotnet/runtime#43605.

A big thank you to @maxkoshevoi, who contributed significantly to this work. Without @maxkoshevoi's help, we wouldn't have come this far.

Observability

Continuing improvements to tracing APIs:

  • Added ActivityContext.TryParse overloads to allow parsing and creating ActivityContext objects, including whether to propagate activity context from a remote parent (related issue).
  • Added Activity.IsStopped() method to indicate whether an Activity object has stopped (related issue).

Code Generation

Community PRs (a big thank you to JIT community contributors!!)

From @am11

Convert some old-style intrinsics to NamedIntrinsic runtime#62271

From @anthonycanino

Add additional binary operations to RangeCheck analysis. runtime#61662

From @SeanWoo

[JIT] [Issue: 61620] Optimize ARM64 for *x = dblCns; runtime#61847

From @SingleAccretion

When calling a better runtime, adjust floating-point CSE runtime#63903 Update hash of new CSE when resizing runtime#61984 Rewrite field selection and always normalize SIMD types in VN runtime#61370 Add documentation on how VN numbers memory runtime#60476 Improve cast value numbering runtime#59841 Expose locals under complex local addresses in block morphing runtime#63100 Handle copy propagation with embedded allocations runtime#63447 Exception set: debugger checks and fixes runtime#63539 Implement "moffset" encoding size optimization in emitOutputAM runtime#62896 Compress operand kind array and optimize OperIsLocal runtime#63253 Make gtHasRef aware of LCL_FLD nodes runtime#62568 Enable global constant propagation for GT_LCL_FLD runtime#61209 Enable global constant propagation for small types runtime#57726 fgMemoryVNForLoopSideEffects attribute type primary selector runtime#60505

From @RalfKornmannEnvision

CoreRT support for ARM64&Unix runtime#41023

From @weilinwa

Optimize FMA code generation based on overrides runtime#58196

Dynamic PGO OSR support for Arm64 JIT: Support OSR for synchronized methods JIT: Handle interactions between OSR, PGO, and tail calls Add 2009 Jit architecture plan (excerpt) JIT: Forward substitution for limited versions of some relops JIT: Save generic context for late devirtualization Arm64 Arm64: Memory barrier improvements Images

Use SIMD operations in InitBlkUnroll/CopyBlkUnroll and increase unroll limit to 128 bytes [Arm64] Continue unrolling InitBlock and CopyBlock up to 128 bytes 'cmeq' and 'fcmeq' Vector64.Zero/Vector128.Zero ARM64 inclusion optimization [arm64] JIT: X % 2 == 0 -> X & 1 == 0 [arm64] JIT: Add sign/zero extension [arm64] JIT: Enable CSE/hoisting for "arrayBase + elementOffset" [arm64] JIT: Fold "A * B + C" into MADD/MSUB Loop optimizations Generalize loop pre-header creation and loop hoisting Loop refactoring and annotation improvements General optimizations Accelerate additional cross-platform hardware intrinsics Implement Narrow and Widen using SIMDAsHWIntrinsic Add IsKnownConstant JIT helper and optimize 'str == ""' with str.StartsWith('c') Allow JIT to keep HFA/HVA in registers when passing as arguments/return values Enable support for nint/nuint for Vector64/128/256 Add support for X86Base.Pause() and ArmBase.Yield() Use preferred region in PAL for JIT relocation hints Support fast tail calls in R2R Allow indirect addressing in tail calls on x64 Optimize indirect unit call sequences more generally Avoid creating extra locals for delegate calls Interop: p/Invoke code generation We are integrating the p/invoke source generator prototyped in .NET 6 into dotnet/runtime and have been converting runtime libraries to use it. This means converted p/invokes are AOT compatible and no longer require IL stub generation at runtime.

We intend to make the p/invoke source generator available outside the runtime in the future. You can follow our remaining work at dotnet/runtime#60595.

New APIs in System.Text.Json

System.Text.Json comes with some small lifecycle enhancements:

  • Developers can now access the default singleton JsonSerializerOptions used internally by System.Text.Json (related issue).
  • Added a JsonWriterOptions.MaxDepth property and ensured this value comes from the serialization's JsonSerializerOptions.MaxDepth equivalent (related issue).
  • Added Patch method to System.Net.Http.Json (related issue).

Hot Reload Improvements

The following edits are now allowed in C# Hot Reload for Blazor WebAssembly and .NET for iOS and Android (related issue):

  • Adding static lambdas to existing methods
  • Adding lambdas that capture this to existing methods that already have at least one lambda capturing this
  • Adding new static or non-virtual instance methods to existing classes
  • Adding new static fields to existing classes
  • Adding new classes

Known issues:

  • Instance fields in newly added classes are not supported
  • Newly added methods and fields in existing or new classes are not visible to reflection

You can follow our progress at dotnet/runtime#57365.

Targeting .NET 7

To use .NET 7, you need to use the .NET 7 Target Framework Moniker (TFM) in your project file. For example:

<TargetFramework>net7.0</TargetFramework>

Full set of .NET 7 TFMs, including OS-specific TFMs:

  • net7.0
  • net7.0-android
  • net7.0-ios
  • net7.0-maccatalyst
  • net7.0-macos
  • net7.0-tvos
  • net7.0-windows

We expect upgrading from .NET 6 to .NET 7 to be straightforward. Please report any breaking changes you discover while testing your existing applications with .NET 7.

Closing Remarks

Microsoft's global team of diverse engineers, working closely with a highly engaged developer community, is building .NET 7. The broad .NET community, including everyone from students and enthusiasts to open-source contributors and enterprise customers, is at the heart of .NET, bringing new ideas, regularly contributing code, and driving the .NET ecosystem forward. We are grateful and thankful for your support, contributions, and insights.

Welcome to .NET 7.

Keep Exploring

Related Reading

More Articles