Announcing .NET 7 Preview 1

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

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

.NET 7 builds on the foundation established by .NET 6, which includes a unified set of base libraries, runtime, and SDK, a simplified development experience, and higher developer productivity. Major areas of focus for .NET 7 include improved support for cloud native scenarios, tools to make it easier to upgrade legacy projects, and simplifying the developer experience by making it easier to work with containers.

.NET 7 Preview 1 includes annotations to APIs to support nullability, ongoing JIT compiler optimizations, new APIs, and support for more hot reload scenarios.

Releases of .NET include products, libraries, runtime, and tooling, and represent a collaboration across multiple teams inside and outside Microsoft. The broader themes covered in this blog post do not encompass all of the key scenarios and investments for .NET 7. They represent large areas but are just a part of all the important work going into .NET 7. We plan to make broad 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:

ASP.NET Core, Blazor, and Orleans
EF7
ML.NET
.NET MAUI
WinForms
WPF
NuGet
Roslyn

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

Installers and binaries
Container images
Linux packages
Release notes
Known issues
GitHub issue tracker

.NET 7 has been tested with Visual Studio 17.2 Preview 1. We recommend you use the preview channel builds if you want to try .NET 7 with Visual Studio family products. Visual Studio for Mac support for .NET 7 previews isn’t available yet but is coming soon.

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

.NET MAUI is the future of cross-platform native UI with .NET and will be a part of .NET 7. On Tuesday, we released .NET MAUI Preview 13. We’re currently focused on shipping .NET MAUI support for .NET 6 and we expect to ship a release candidate (RC) soon. After we have an RC available, we will focus on shipping additional RCs until we reach the quality desired for general availability (GA). After .NET MAUI GA has shipped for .NET 6, we’ll include it in .NET 7 and look at improving the inner development loop experience, supporting the latest .NET SDK tooling, faster app performance, sharing more code, and an enhanced interop story. Check out the status of .NET MAUI and project roadmap for more information.

Modern cloud: Cloud Native and containers

Cloud native apps are built from the ground up to take advantage of modern, web-based resources such as database services and hosted containers. The cloud native architecture can improve scale in large applications by creating autonomous subsystems (commonly referred to as microservices) that are deployed and scale independently from other areas of the application while lowering costs in the long term. The microservices architecture is a popular approach because it’s flexible and designed to evolve and scale to limits that are difficult to achieve in a monolithic architecture.

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

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

We’ll continue to make investments in Orleans, a .NET cross-platform framework for building distributed applications that has been referred to as “distributed .NET.” We’ll continue to enhance the comprehensive documentation for Orleans and make it easier to use and implement by improving integration of Orleans with existing cloud services like Azure App Services and Azure Container Apps.

Containers are the preferred way to deploy cloud native apps and microservices for many companies today. Relying on containers presents several challenges including managing compliance, building and publishing images, securing images, and streamlining the size and performance of images. We believe that there is an opportunity to create a better experience with .NET containers.

To help customers face these challenges, we plan to make significant improvements to .NET development with containers in .NET 7. For example, we’ll explore building containers directly via MSBuild as a new capability of the SDK. We plan to enhance telemetry to improve the observability of containers. We’ll also focus on making our container images smaller, faster, and more secure while we explore highly requested models such as rootless and distroless.

Modernize: upgrade .NET apps

Since the release of .NET 6, developers have been upgrading their applications to take advantage of new performance gains, productivity features like minimal APIs and hot reload, new runtime and C# language innovations and the availability of a mature ecosystem of libraries and tools. In .NET 7, we’ll continue to enable you to bring your existing .NET apps forward to the latest .NET platforms and technologies. More analyzers, code fixers, and support for additional app types in the .NET Upgrade Assistant will help you confidently upgrade even more of your application portfolio and spend less time on the repetitive tasks involved in upgrading.

We also know that each of the .NET app models (ASP.NET, WinForms, WPF, etc.) have their own unique challenges with modernization and may be lacking functionality that you need as a developer or support in the platform itself. For some of these, like WCF, there may not be a clear direction for you. We’ll focus on offering appropriate guidance, documentation, and tooling to make these .NET app 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’s important to note that the quality of all releases is the same. The only difference between LTS and Current releases is the length of support. For more about .NET support policies, see the .NET and .NET Core official support policy.

Breaking changes

You can find the most recent list of breaking changes in .NET 7 by reading the Breaking changes in .NET 7 document. It lists breaking changes by area and release with links to detailed explanations.

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

Preview 1

The following features are now available in the Preview 1 release.

Nullable annotations for Microsoft.Extensions

We have been making progress on annotating the Microsoft.Extensions.* libraries for nullability. 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 on annotating all the Microsoft.Extensions.* libraries for nullability. You can see the remaining libraries, and follow the progress at dotnet/runtime#43605.

A huge thank you to @maxkoshevoi who has been contributing the bulk of this effort. Without @maxkoshevoi’s help, we wouldn’t be nearly as far as we are.

Observability

Continue improving the tracing APIs:

Adding the overload to ActivityContext.TryParse allows parsing and creating an ActivityContext object including if the activity context was propagated from a remote parent (related issue).
Adding the method Activity.IsStopped() to indicate whether the Activity object is stopped(related issue).

CodeGen

Community PRs (many thanks to JIT community contributors!!)

From @am11

Convert some old style intrinsics to NamedIntrinsic runtime#62271

From @anthonycanino

Add additional binary operations into the RangeCheck analysis. runtime#61662

From @SeanWoo

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

From @SingleAccretion

Tune floating-point CSEs live across a call better runtime#63903
Update hash of the new CSE when resizing runtime#61984
Rewrite selection for fields and always normalize SIMD types in VN runtime#61370
Add documentation on how VN numbers memory runtime#60476
Improve value numbering for casts runtime#59841
Address-expose locals under complex local addresses in block morphing runtime#63100
Handle embedded assignments in copy propagation runtime#63447
Exception sets: debug checker & fixes runtime#63539
Implement the “moffset” encoding size optimization in emitOutputAM runtime#62896
Compress operand kinds array and optimize OperIsLocal runtime#63253
Make gtHasRef pay attention to LCL_FLD nodes runtime#62568
Enable global constant propagation for GT_LCL_FLD runtime#61209
Enable global constant propagation for small types runtime#57726
Properly type primary selectors in fgMemoryVNForLoopSideEffects runtime#60505

From @RalfKornmannEnvision

CoreRT support for ARM64&Unix runtime#41023

From @weilinwa

Optimize FMA codegen base on the overwritten runtime#58196

Dynamic PGO

OSR support for Arm64
JIT: support OSR for synchronized methods
JIT: handle interaction of OSR, PGO, and tail calls
Add 2009 Jit Architecture Plan (excerpts)
JIT: limited version of forward substitution for some relops
JIT: save generics context for late devirtualization

Arm64

Arm64: Memory barrier improvements

Use SIMD operations in InitBlkUnroll/CopyBlkUnroll and increase unroll limit up to 128 bytes
[Arm64] Keep unrolling InitBlock and CopyBlock up to 128 bytes
‘cmeq’ and ‘fcmeq’ Vector64.Zero/Vector128.Zero ARM64 containment optimizations
[arm64] JIT: X % 2 == 0 -> X & 1 == 0
[arm64] JIT: Add with sign/zero extend
[arm64] JIT: Enable CSE/hoisting for “arrayBase + elementOffset”
[arm64] JIT: Fold “A * B + C” to MADD/MSUB

Loop Optimizations

Generalize loop pre-header creation and loop hoisting
Loop refactoring and commenting 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 the registers when passing them as argument/returning values
Enable support for nint/nuint for Vector64/128/256
Adding support for X86Base.Pause() and ArmBase.Yield()
Use preferred region from PAL for JIT reloc hints
Support fast tailcalls in R2R
Allow contained indirections in tailcalls on x64
Optimize indirection cell call sequences more generally
Avoid additional local created for delegate invocations

Interop: p/Invoke code generation

We integrated the p/invoke source generator that was prototyped in .NET 6 into dotnet/runtime and have been converting the runtime libraries to use it. This means the converted p/invokes are AOT-compatible and no longer require an IL stub to be generated at runtime.

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

New APIs in System.Text.Json

System.Text.Json ships with a couple of minor quality-of-life enhancements:

Developers now have access to the default JsonSerializerOptions singleton used internally by System.Text.Json (related issue).
Add a JsonWriterOptions.MaxDepth property and ensure this value flows from the equivalent JsonSerializerOptions.MaxDepth property on serialization (related issue).
Add Patch methods 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 that captures 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 in dotnet/runtime#57365

Targeting .NET 7

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

<TargetFramework>net7.0</TargetFramework>

The full set of .NET 7 TFMs, including operating-specific ones follows.

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

We expect that upgrading from .NET 6 to .NET 7 should be straightforward. Please report any breaking changes that you discover in the process of testing existing apps with .NET 7.

Closing

A global and diverse team of engineers at Microsoft in collaboration with a highly engaged community of developers are building .NET 7. The broad .NET community, including everyone from students and hobbyists to open-source contributors and enterprise customers, are at the heart of .NET. They propose new ideas, contribute code regularly, and drive the .NET ecosystem forward. We appreciate and thank you for your support, contributions and insights.

Welcome to .NET 7.

The post Announcing .NET 7 Preview 1 appeared first on .NET Blog.

Leave a Reply

Your email address will not be published.