This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
.NET 7 was the successor to.NET 6 and focused on being unified, modern, simple, andfast. .NET 7 was a standard-term support (STS) release (previously known as acurrent release).
This article lists the new features of .NET 7 and provides links to more detailed information on each.
Performance is a key focus of .NET 7, and all of its features are designed with performance in mind. In addition, .NET 7 includes the following enhancements aimed purely at performance:
<TieredPGO>true</TieredPGO> to your project file). PGO can also instrument and optimize additional things, such as delegates.For a detailed look at many of the performance-focused features that make .NET 7 so fast, see thePerformance improvements in .NET 7 blog post.
.NET 7 includes improvements to System.Text.Json serialization in the following areas:
For information about these and other updates, see theWhat's new in System.Text.Json in .NET 7 blog post.
.NET 7 and C# 11 include innovations that allow you to perform mathematical operations generically—that is, without having to know the exact type you're working with. For example, if you wanted to write a method that adds two numbers, previously you had to add an overload of the method for each type. Now you can write a single, generic method, where the type parameter is constrained to be a number-like type. For more information, see theGeneric math article and theGeneric math blog post.
.NET'sregular expression library has seen significant functional and performance improvements in .NET 7:
The new optionRegexOptions.NonBacktracking enables matching using an approach that avoids backtracking and guarantees linear-time processing in the length of the input. The nonbacktracking engine can't be used in a right-to-left search and has a few other restrictions, but is fast for all regular expressions and inputs. For more information, seeNonbacktracking mode.
Regular expression source generators are new. Source generators build an engine that's optimized foryour pattern at compile time, providing throughput performance benefits. The source that's emitted is part of your project, so you can view and debug it. In addition, a new source-generator diagnosticSYSLIB1045 alerts you to places you useRegex that could be converted to the source generator. For more information, see.NET regular expression source generators.
For case-insensitive searches, .NET 7 includes large performance gains. The gains come because specifyingRegexOptions.IgnoreCase no longer callsToLower on each character in the pattern and on each character in the input. Instead, all casing-related work is done when theRegex is constructed.
Regex now supports spans for some APIs. The following new methods have been added as part of this support:
For more information about these and other improvements, see theRegular expression improvements in .NET 7 blog post.
Many improvements have been made to .NET library APIs. Some are mentioned in other, dedicated sections of this article. Some others are summarized in the following table.
| Description | APIs | Further information |
|---|---|---|
| Support for microseconds and nanoseconds inTimeSpan,TimeOnly,DateTime, andDateTimeOffset types | -DateTime.Microsecond -DateTime.Nanosecond -DateTime.AddMicroseconds(Double) - NewDateTime constructor overloads -DateTimeOffset.Microsecond -DateTimeOffset.Nanosecond -DateTimeOffset.AddMicroseconds(Double) - NewDateTimeOffset constructor overloads -TimeOnly.Microsecond -TimeOnly.Nanosecond -TimeSpan.Microseconds -TimeSpan.Nanoseconds -TimeSpan.FromMicroseconds(Double) - And others... | These APIs mean you no longer have to perform computations on the "tick" value to determine microsecond and nanosecond values. For more information, see the.NET 7 Preview 4 blog post. |
| APIs for reading, writing, archiving, and extracting Tar archives | System.Formats.Tar | For more information, see the.NET 7 Preview 4 and.NET 7 Preview 6 blog posts. |
| Rate limiting APIs to protect a resource by keeping traffic at a safe level | RateLimiter and others in the System.Threading.RateLimitingNuGet package | For more information, seeRate limit an HTTP handler in .NET andAnnouncing rate limiting for .NET. |
| APIs to readall the data from aStream | -Stream.ReadExactly -Stream.ReadAtLeast | Stream.Read may return less data than what's available in the stream. The newReadExactly methods readexactly the number of bytes requested, and the newReadAtLeast methods readat least the number of bytes requested. For more information, see the.NET 7 Preview 5 blog post. |
New type converters forDateOnly,TimeOnly,Int128,UInt128, andHalf | In theSystem.ComponentModel namespace: -DateOnlyConverter -TimeOnlyConverter -Int128Converter -UInt128Converter -HalfConverter | Type converters are often used to convert value types to and from a string. These new APIs add type converters for types that were added more recently. |
| Metrics support forIMemoryCache | -MemoryCacheStatistics -MemoryCache.GetCurrentStatistics() | GetCurrentStatistics() lets you use event counters or metrics APIs to track statistics for one or more memory caches. For more information, see the.NET 7 Preview 4 blog post. |
| APIs to get and set Unix file permissions | -System.IO.UnixFileMode enum -File.GetUnixFileMode -File.SetUnixFileMode -FileSystemInfo.UnixFileMode -Directory.CreateDirectory(String, UnixFileMode) -FileStreamOptions.UnixCreateMode | For more information, see the.NET 7 Preview 7 blog post. |
| Attribute to indicate what kind of syntax is expected in a string | StringSyntaxAttribute | For example, you can specify that astring parameter expects a regular expression by attributing the parameter with[StringSyntax(StringSyntaxAttribute.Regex)]. |
| APIs to interop with JavaScript when running in the browser or other WebAssembly architectures | System.Runtime.InteropServices.JavaScript | JavaScript apps can use the expanded WebAssembly support in .NET 7 to reuse .NET libraries from JavaScript. For more information, seeUse .NET from any JavaScript app in .NET 7. |
.NET 7 makes improvements toobservability. Observability helps you understand the state of your app as it scales and as the technical complexity increases. .NET's observability implementation is primarily built aroundOpenTelemetry. Improvements include:
For more information, see the.NET 7 Preview 4 blog post.
The .NET 7SDK improves the CLI template experience. It also enables publishing to containers, and central package management with NuGet.
Some welcome improvements have been made to thedotnet new command and to template authoring.
Thedotnet new CLI command, which creates a new project, configuration file, or solution based on a template, now supportstab completion for exploring:
In addition, for better conformity, theinstall,uninstall,search,list, andupdate subcommands no longer have the-- prefix.
Templateconstraints, a new concept for .NET 7, let you define the context in which your templates are allowed. Constraints help the template engine determine which templates it should show in commands likedotnet new list. You can constrain your template to an operating system, a template engine host (for example, the .NET CLI or New Project dialog in Visual Studio), and an installed workload. You define constraints in your template's configuration file.
Also in the template configuration file, you can now annotate a template parameter as allowing multiple values. For example, theweb template allows multiple forms of authentication.
For more information, see the.NET 7 Preview 6 blog post.
Containers are one of the easiest ways to distribute and run a wide variety of applications and services in the cloud. Container images are now a supported output type of the .NET SDK, and you can create containerized versions of your applications usingdotnet publish. For more information about the feature, seeAnnouncing built-in container support for the .NET SDK. For a tutorial, seeContainerize a .NET app with dotnet publish.
You can now manage common dependencies in your projects from one location using NuGet's central package management (CPM) feature. To enable it, you add aDirectory.Packages.props file to the root of your repository. In this file, set the MSBuild propertyManagePackageVersionsCentrally totrue and add versions for common package dependency usingPackageVersion items. Then, in the individual project files, you can omitVersion attributes from anyPackageReference items that refer to centrally managed packages.
For more information, seeCentral package management.
.NET 7 introduces a source generator for platform invokes (P/Invokes) in C#. The source generator looks forLibraryImportAttribute onstatic,partial methods to trigger compile-time source generation of marshalling code. By generating the marshalling code at compile time, no IL stub needs to be generated at run time, as it does when usingDllImportAttribute. The source generator improves application performance and also allows the app to be ahead-of-time (AOT) compiled. For more information, seeSource generation for platform invokes andUse custom marshallers in source-generated P/Invokes.
This section contains information about related products that have releases that coincide with the .NET 7 release.
For more information, seeWhat's new in Visual Studio 2022.
C# 11 includes support forgeneric math, raw string literals, file-scoped types, and other new features. For more information, seeWhat's new in C# 11.
F# 7 continues the journey to make the language simpler and improve performance and interop with new C# features. For more information, seeAnnouncing F# 7.
.NET Multi-platform App UI (.NET MAUI) is a cross-platform framework for creating native mobile and desktop apps with C# and XAML. It unifies Android, iOS, macOS, and Windows APIs into a single API. For information about the latest updates, seeWhat's new in .NET MAUI for .NET 7.
ASP.NET Core 7.0 includes rate-limiting middleware, improvements to minimal APIs, and gRPC JSON transcoding. For information about all the updates, seeWhat's new in ASP.NET Core 7.
Entity Framework Core 7.0 includes provider-agnostic support for JSON columns, improved performance for saving changes, and custom reverse engineering templates. For information about all the updates, seeWhat's new in EF Core 7.0.
Much work has gone into Windows Forms for .NET 7. Improvements have been made in the following areas:
For more information, seeWhat's new in Windows Forms in .NET 7.
WPF in .NET 7 includes numerous bug fixes as well as performance and accessibility improvements. For more information, see theWhat's new for WPF in .NET 7 blog post.
Orleans is a cross-platform framework for building robust, scalable distributed applications. For information about the latest updates for Orleans, seeMigrate from Orleans 3.x to 7.0.
ML.NET now includes a text classification API that makes it easy to train custom text classification models using the latest state-of-the-art deep learning techniques. For more information, see theWhat's new with AutoML and tooling andIntroducing the ML.NET Text Classification API blog posts.
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?