From e43a4c363d78eca4ea8cc6998880a0abe68d07a6 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Wed, 12 Feb 2025 22:43:57 +0000 Subject: [PATCH 01/24] initial commit --- docs/core/whats-new/dotnet-10/libraries.md | 11 ++++ docs/core/whats-new/dotnet-10/overview.md | 59 ++++++++++++++++++++++ docs/core/whats-new/dotnet-10/runtime.md | 10 ++++ docs/core/whats-new/dotnet-10/sdk.md | 11 ++++ docs/whats-new/index.yml | 22 +++----- docs/whats-new/toc.yml | 11 ++++ 6 files changed, 108 insertions(+), 16 deletions(-) create mode 100644 docs/core/whats-new/dotnet-10/libraries.md create mode 100644 docs/core/whats-new/dotnet-10/overview.md create mode 100644 docs/core/whats-new/dotnet-10/runtime.md create mode 100644 docs/core/whats-new/dotnet-10/sdk.md diff --git a/docs/core/whats-new/dotnet-10/libraries.md b/docs/core/whats-new/dotnet-10/libraries.md new file mode 100644 index 0000000000000..3d0939c28299f --- /dev/null +++ b/docs/core/whats-new/dotnet-10/libraries.md @@ -0,0 +1,11 @@ +--- +title: What's new in .NET libraries for .NET 10 +description: Learn about the new .NET libraries features introduced in .NET 10. +titleSuffix: "" +ms.date: 02/12/2025 +ms.topic: whats-new +--- + +# What's new in .NET libraries for .NET 10 + +This article describes new features in the .NET libraries for .NET 10. diff --git a/docs/core/whats-new/dotnet-10/overview.md b/docs/core/whats-new/dotnet-10/overview.md new file mode 100644 index 0000000000000..48cfab8a50206 --- /dev/null +++ b/docs/core/whats-new/dotnet-10/overview.md @@ -0,0 +1,59 @@ +--- +title: What's new in .NET 10 +description: Learn about the new .NET features introduced in .NET 10 for the runtime, libraries, and SDK. Also find links to what's new in other areas, such as ASP.NET Core. +titleSuffix: "" +ms.date: 02/12/2025 +ms.topic: whats-new +--- + +# What's new in .NET 10 + +Learn about the new features in .NET 10 and find links to further documentation. + +TODO - Add a brief overview of the new features in .NET 10. + +## .NET runtime + +TODO - Add a brief overview of the new features in the .NET 10 runtime. + +For more information, see [What's new in the .NET 10 runtime](runtime.md). + +## .NET libraries + +TODO - Add a brief overview of the new features in the .NET 10 libraries. + +For more information, see [What's new in the .NET 10 libraries](libraries.md). + +## .NET SDK + +TODO - Add a brief overview of the new features in the .NET 10 SDK. + +For more information, see [What's new in the SDK for .NET 10](sdk.md). + +## .NET Aspire + +TODO - Add a brief overview of the new features in .NET Aspire. + +## ASP.NET Core + +TODO - Add a brief overview of the new features in ASP.NET Core for .NET 10. + +## .NET MAUI + +TODO - Add a brief overview of the new features in .NET MAUI for .NET 10. + +## EF Core + +TODO - Add a brief overview of the new features in EF Core for .NET 10. + +## C# 14 + +TODO - Add a brief overview of the new features in C# 14. + +## Windows Forms + +TODO - Add a brief overview of the new features in Windows Forms for .NET 10. + +## See also + +TODO - Add links to other "What's new" articles for .NET 10. diff --git a/docs/core/whats-new/dotnet-10/runtime.md b/docs/core/whats-new/dotnet-10/runtime.md new file mode 100644 index 0000000000000..84d146beb0943 --- /dev/null +++ b/docs/core/whats-new/dotnet-10/runtime.md @@ -0,0 +1,10 @@ +--- +title: What's new in .NET 10 runtime +description: Learn about the new .NET features introduced in the .NET 10 runtime. +titleSuffix: "" +ms.date: 02/12/2025 +ms.topic: whats-new +--- +# What's new in the .NET 10 runtime + +This article describes new features and performance improvements in the .NET runtime for .NET 10. diff --git a/docs/core/whats-new/dotnet-10/sdk.md b/docs/core/whats-new/dotnet-10/sdk.md new file mode 100644 index 0000000000000..e0dbd8d11e673 --- /dev/null +++ b/docs/core/whats-new/dotnet-10/sdk.md @@ -0,0 +1,11 @@ +--- +title: What's new in the SDK and tooling for .NET 10 +description: Learn about the new .NET SDK features introduced in .NET 10. +titleSuffix: "" +ms.date: 02/12/2025 +ms.topic: whats-new +--- + +# What's new in the SDK and tooling for .NET 10 + +This article describes new features in the .NET SDK and tooling for .NET 10. diff --git a/docs/whats-new/index.yml b/docs/whats-new/index.yml index 77740c2ee93ae..39118a02b0eea 100644 --- a/docs/whats-new/index.yml +++ b/docs/whats-new/index.yml @@ -8,6 +8,12 @@ metadata: ms.date: 02/01/2025 ms.topic: landing-page landingContent: +- title: .NET 9 release updates + linkLists: + - linkListType: whats-new + links: + - text: .NET 10 + url: ../core/whats-new/dotnet-10/overview.md - title: .NET 9 release updates linkLists: - linkListType: whats-new @@ -22,22 +28,6 @@ landingContent: url: /ef/core/what-is-new/ef-core-9.0/whatsnew - text: Documentation updates url: dotnet-9-release.md -- title: .NET 8 release updates - linkLists: - - linkListType: whats-new - links: - - text: .NET 8 - url: ../core/whats-new/dotnet-8/overview.md - - text: ASP.NET Core 8.0 - url: /aspnet/core/release-notes/aspnetcore-8.0 - - text: .NET MAUI 8 - url: /dotnet/maui/whats-new/dotnet-8 - - text: EF Core 8 - url: /ef/core/what-is-new/ef-core-8.0/whatsnew - - text: Windows Forms (.NET 8) - url: /dotnet/desktop/winforms/whats-new/net80 - - text: WPF (.NET 8) - url: /dotnet/desktop/wpf/whats-new/net80 - title: Latest documentation updates linkLists: - linkListType: whats-new diff --git a/docs/whats-new/toc.yml b/docs/whats-new/toc.yml index 99164b8e424be..59cc4a9ccba66 100644 --- a/docs/whats-new/toc.yml +++ b/docs/whats-new/toc.yml @@ -14,6 +14,17 @@ items: href: dotnet-docs-mod2.md - name: Product updates items: + - name: .NET 10 + expanded: true + items: + - name: .NET 10 + href: ../core/whats-new/dotnet-10/overview.md?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json + - name: ASP.NET Core 10.0 + href: /aspnet/core/release-notes?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json + - name: .NET MAUI 10 + href: /dotnet/maui/whats-new?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json + - name: EF Core 10 + href: /ef/core/what-is-new?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json - name: .NET 9 expanded: true items: From 7556b3e31288f98e59d31fa05cef79471104e0b3 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Wed, 12 Feb 2025 22:59:22 +0000 Subject: [PATCH 02/24] additions --- docs/fundamentals/index.yml | 2 ++ docs/fundamentals/toc.yml | 13 +++++++++++++ docs/whats-new/index.yml | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/fundamentals/index.yml b/docs/fundamentals/index.yml index edb34a5dbee28..fbb1df078346c 100644 --- a/docs/fundamentals/index.yml +++ b/docs/fundamentals/index.yml @@ -37,6 +37,8 @@ landingContent: url: https://dotnet.microsoft.com/platform/support/policy/dotnet-core - linkListType: whats-new links: + - text: What's new in .NET 10 + url: ../core/whats-new/dotnet-10/overview.md - text: What's new in .NET 9 url: ../core/whats-new/dotnet-9/overview.md - text: What's new in .NET 8 diff --git a/docs/fundamentals/toc.yml b/docs/fundamentals/toc.yml index e4b4e1dffbc8d..a8bd7da598986 100644 --- a/docs/fundamentals/toc.yml +++ b/docs/fundamentals/toc.yml @@ -137,6 +137,19 @@ items: href: ../core/tutorials/index.md - name: What's new in .NET items: + - name: .NET 10 + items: + - name: What's new + items: + - name: Overview + href: ../core/whats-new/dotnet-10/overview.md + displayName: whats new, what's new + - name: Runtime + href: ../core/whats-new/dotnet-10/runtime.md + - name: Libraries + href: ../core/whats-new/dotnet-10/libraries.md + - name: SDK + href: ../core/whats-new/dotnet-10/sdk.md - name: .NET 9 items: - name: What's new diff --git a/docs/whats-new/index.yml b/docs/whats-new/index.yml index 39118a02b0eea..97c45fef64934 100644 --- a/docs/whats-new/index.yml +++ b/docs/whats-new/index.yml @@ -5,10 +5,10 @@ summary: Welcome to what's new in .NET and .NET docs. Use this page to navigate metadata: title: .NET what's new? description: Learn about new .NET features and new and updated content in .NET docs. - ms.date: 02/01/2025 + ms.date: 02/12/2025 ms.topic: landing-page landingContent: -- title: .NET 9 release updates +- title: .NET 10 release updates linkLists: - linkListType: whats-new links: From c00c0f07fafbeed97cce59ef64691c79c91d23bc Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Wed, 12 Feb 2025 23:14:41 +0000 Subject: [PATCH 03/24] couple more tweaks --- .openpublishing.redirection.core.json | 7 ++++++- docs/fundamentals/toc.yml | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.openpublishing.redirection.core.json b/.openpublishing.redirection.core.json index ec4d89a56b5a9..c09ae5f5183ce 100644 --- a/.openpublishing.redirection.core.json +++ b/.openpublishing.redirection.core.json @@ -1330,8 +1330,13 @@ "redirect_document_id": true }, { - "source_path_from_root": "/docs/core/whats-new/index.md", + "source_path_from_root": "/docs/core/whats-new/dotnet-9.md", "redirect_url": "/dotnet/core/whats-new/dotnet-9/overview", + "redirect_document_id": true + }, + { + "source_path_from_root": "/docs/core/whats-new/index.md", + "redirect_url": "/dotnet/core/whats-new/dotnet-10/overview", "ms.custom": "updateeachrelease" }, { diff --git a/docs/fundamentals/toc.yml b/docs/fundamentals/toc.yml index a8bd7da598986..c77d2e574589d 100644 --- a/docs/fundamentals/toc.yml +++ b/docs/fundamentals/toc.yml @@ -149,7 +149,9 @@ items: - name: Libraries href: ../core/whats-new/dotnet-10/libraries.md - name: SDK - href: ../core/whats-new/dotnet-10/sdk.md + href: ../core/whats-new/dotnet-10/sdk. + - name: Breaking changes + href: ../core/compatibility/10.0.md?toc=/dotnet/fundamentals/toc.json&bc=/dotnet/breadcrumb/toc.json - name: .NET 9 items: - name: What's new From b8d0b329811062d5b57c13fc821ecf2cd393eb7b Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Wed, 12 Feb 2025 23:18:04 +0000 Subject: [PATCH 04/24] whoops --- docs/fundamentals/toc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/toc.yml b/docs/fundamentals/toc.yml index c77d2e574589d..71084eba562c4 100644 --- a/docs/fundamentals/toc.yml +++ b/docs/fundamentals/toc.yml @@ -149,7 +149,7 @@ items: - name: Libraries href: ../core/whats-new/dotnet-10/libraries.md - name: SDK - href: ../core/whats-new/dotnet-10/sdk. + href: ../core/whats-new/dotnet-10/sdk.md - name: Breaking changes href: ../core/compatibility/10.0.md?toc=/dotnet/fundamentals/toc.json&bc=/dotnet/breadcrumb/toc.json - name: .NET 9 From 2a4fc61fbca3feab18a9d23712651eb3ea2ce9c6 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Thu, 13 Feb 2025 16:18:05 -0600 Subject: [PATCH 05/24] Apply suggestions from code review Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- docs/core/whats-new/dotnet-10/libraries.md | 2 +- docs/core/whats-new/dotnet-10/overview.md | 4 ++-- docs/core/whats-new/dotnet-10/runtime.md | 2 +- docs/core/whats-new/dotnet-10/sdk.md | 2 +- docs/whats-new/toc.yml | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/core/whats-new/dotnet-10/libraries.md b/docs/core/whats-new/dotnet-10/libraries.md index 3d0939c28299f..b4bb6d23cdc7b 100644 --- a/docs/core/whats-new/dotnet-10/libraries.md +++ b/docs/core/whats-new/dotnet-10/libraries.md @@ -8,4 +8,4 @@ ms.topic: whats-new # What's new in .NET libraries for .NET 10 -This article describes new features in the .NET libraries for .NET 10. +This article describes new features in the .NET libraries for .NET 10. It has been updated for Preview 1. diff --git a/docs/core/whats-new/dotnet-10/overview.md b/docs/core/whats-new/dotnet-10/overview.md index 48cfab8a50206..e4b2e88f012fc 100644 --- a/docs/core/whats-new/dotnet-10/overview.md +++ b/docs/core/whats-new/dotnet-10/overview.md @@ -1,6 +1,6 @@ --- title: What's new in .NET 10 -description: Learn about the new .NET features introduced in .NET 10 for the runtime, libraries, and SDK. Also find links to what's new in other areas, such as ASP.NET Core. +description: Learn about the new features introduced in .NET 10 for the runtime, libraries, and SDK. Also find links to what's new in other areas, such as ASP.NET Core. titleSuffix: "" ms.date: 02/12/2025 ms.topic: whats-new @@ -8,7 +8,7 @@ ms.topic: whats-new # What's new in .NET 10 -Learn about the new features in .NET 10 and find links to further documentation. +Learn about the new features in .NET 10 and find links to further documentation. This page has been updated for Preview 1. TODO - Add a brief overview of the new features in .NET 10. diff --git a/docs/core/whats-new/dotnet-10/runtime.md b/docs/core/whats-new/dotnet-10/runtime.md index 84d146beb0943..5ff2e4431fc8c 100644 --- a/docs/core/whats-new/dotnet-10/runtime.md +++ b/docs/core/whats-new/dotnet-10/runtime.md @@ -7,4 +7,4 @@ ms.topic: whats-new --- # What's new in the .NET 10 runtime -This article describes new features and performance improvements in the .NET runtime for .NET 10. +This article describes new features and performance improvements in the .NET runtime for .NET 10. It has been updated for Preview 1. diff --git a/docs/core/whats-new/dotnet-10/sdk.md b/docs/core/whats-new/dotnet-10/sdk.md index e0dbd8d11e673..7ecada8100ea1 100644 --- a/docs/core/whats-new/dotnet-10/sdk.md +++ b/docs/core/whats-new/dotnet-10/sdk.md @@ -8,4 +8,4 @@ ms.topic: whats-new # What's new in the SDK and tooling for .NET 10 -This article describes new features in the .NET SDK and tooling for .NET 10. +This article describes new features in the .NET SDK and tooling for .NET 10. It has been updated for Preview 1. diff --git a/docs/whats-new/toc.yml b/docs/whats-new/toc.yml index 59cc4a9ccba66..bade277f0f552 100644 --- a/docs/whats-new/toc.yml +++ b/docs/whats-new/toc.yml @@ -26,7 +26,6 @@ items: - name: EF Core 10 href: /ef/core/what-is-new?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json - name: .NET 9 - expanded: true items: - name: .NET 9 href: ../core/whats-new/dotnet-9/overview.md?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json From ccc905c865ea82a608853df5079d41290d1b5448 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Tue, 18 Feb 2025 16:46:26 -0600 Subject: [PATCH 06/24] Update .openpublishing.redirection.core.json Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- .openpublishing.redirection.core.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.openpublishing.redirection.core.json b/.openpublishing.redirection.core.json index c09ae5f5183ce..3d9f2115d7a79 100644 --- a/.openpublishing.redirection.core.json +++ b/.openpublishing.redirection.core.json @@ -1329,11 +1329,6 @@ "redirect_url": "/dotnet/core/whats-new/dotnet-8/overview", "redirect_document_id": true }, - { - "source_path_from_root": "/docs/core/whats-new/dotnet-9.md", - "redirect_url": "/dotnet/core/whats-new/dotnet-9/overview", - "redirect_document_id": true - }, { "source_path_from_root": "/docs/core/whats-new/index.md", "redirect_url": "/dotnet/core/whats-new/dotnet-10/overview", From 2ed3a1f4ba2266b26a9a7b98d31fc1a417c802c7 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Tue, 18 Feb 2025 23:42:57 +0000 Subject: [PATCH 07/24] Added SDK --- docs/core/whats-new/dotnet-10/sdk.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/core/whats-new/dotnet-10/sdk.md b/docs/core/whats-new/dotnet-10/sdk.md index 7ecada8100ea1..74b4c5de4f572 100644 --- a/docs/core/whats-new/dotnet-10/sdk.md +++ b/docs/core/whats-new/dotnet-10/sdk.md @@ -8,4 +8,16 @@ ms.topic: whats-new # What's new in the SDK and tooling for .NET 10 -This article describes new features in the .NET SDK and tooling for .NET 10. It has been updated for Preview 1. +This article describes new features and enhancements in the .NET SDK for .NET 10. It has been updated for Preview 1. + +## New features and enhancements + +- [Pruning of Framework-provided Package References](#pruning-of-framework-provided-package-references) + +## Pruning of Framework-provided Package References + +Starting in .NET 10, the [NuGet Audit][https://learn.microsoft.com/nuget/concepts/auditing-packages] feature can now [prune framework-provided package references][https://github.com/NuGet/Home/blob/451c27180d14214bca60483caee57f0dc737b8cf/accepted/2024/prune-package-reference.md] that are not used by the project. This feature will be enabled by default for all .NET TargetFrameworks (e.g. `net8.0`, `net10.0`) and .NET Standard 2.0 and greater TargetFrameworks. This change will help reduce the number of packages that are restored and analyzed during the build process, which can lead to faster build times and reduced disk space usage. It also can lead to a reduction in false positives from NuGet Audit and other dependency-scanning mechanisms. + +When this feature is enabled, you should see a marked reduction in the contents of your applications' generated `.deps.json` files - any PackageReferences you may have had that are actually being supplied by the .NET Runtime you use will be automatically removed from the generated dependency file. + +While this feature is enabled by default for the TFMs listed above, you can disable it by setting the `RestoreEnablePackagePruning` property to `false` in your project file or Directory.Build.props file. From a58fe7c65252671cfb590d9aa0b1ab89ad36efa1 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Tue, 18 Feb 2025 23:45:47 +0000 Subject: [PATCH 08/24] whoopsie --- docs/core/whats-new/dotnet-10/sdk.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/whats-new/dotnet-10/sdk.md b/docs/core/whats-new/dotnet-10/sdk.md index 74b4c5de4f572..dc7aca9fed143 100644 --- a/docs/core/whats-new/dotnet-10/sdk.md +++ b/docs/core/whats-new/dotnet-10/sdk.md @@ -16,7 +16,7 @@ This article describes new features and enhancements in the .NET SDK for .NET 10 ## Pruning of Framework-provided Package References -Starting in .NET 10, the [NuGet Audit][https://learn.microsoft.com/nuget/concepts/auditing-packages] feature can now [prune framework-provided package references][https://github.com/NuGet/Home/blob/451c27180d14214bca60483caee57f0dc737b8cf/accepted/2024/prune-package-reference.md] that are not used by the project. This feature will be enabled by default for all .NET TargetFrameworks (e.g. `net8.0`, `net10.0`) and .NET Standard 2.0 and greater TargetFrameworks. This change will help reduce the number of packages that are restored and analyzed during the build process, which can lead to faster build times and reduced disk space usage. It also can lead to a reduction in false positives from NuGet Audit and other dependency-scanning mechanisms. +Starting in .NET 10, the [NuGet Audit](https://learn.microsoft.com/nuget/concepts/auditing-packages) feature can now [prune framework-provided package references](https://github.com/NuGet/Home/blob/451c27180d14214bca60483caee57f0dc737b8cf/accepted/2024/prune-package-reference.md) that are not used by the project. This feature will be enabled by default for all .NET TargetFrameworks (e.g. `net8.0`, `net10.0`) and .NET Standard 2.0 and greater TargetFrameworks. This change will help reduce the number of packages that are restored and analyzed during the build process, which can lead to faster build times and reduced disk space usage. It also can lead to a reduction in false positives from NuGet Audit and other dependency-scanning mechanisms. When this feature is enabled, you should see a marked reduction in the contents of your applications' generated `.deps.json` files - any PackageReferences you may have had that are actually being supplied by the .NET Runtime you use will be automatically removed from the generated dependency file. From 6e2d257f68d7dcf8b9f877b4467f2117433d8037 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Wed, 19 Feb 2025 20:03:52 +0000 Subject: [PATCH 09/24] Added some more content --- docs/core/whats-new/dotnet-10/libraries.md | 258 ++++++++++++++++++++- docs/core/whats-new/dotnet-10/overview.md | 46 +++- docs/core/whats-new/dotnet-10/runtime.md | 72 +++++- docs/core/whats-new/dotnet-10/sdk.md | 8 +- 4 files changed, 369 insertions(+), 15 deletions(-) diff --git a/docs/core/whats-new/dotnet-10/libraries.md b/docs/core/whats-new/dotnet-10/libraries.md index b4bb6d23cdc7b..6b66cd3254aa7 100644 --- a/docs/core/whats-new/dotnet-10/libraries.md +++ b/docs/core/whats-new/dotnet-10/libraries.md @@ -2,10 +2,266 @@ title: What's new in .NET libraries for .NET 10 description: Learn about the new .NET libraries features introduced in .NET 10. titleSuffix: "" -ms.date: 02/12/2025 +ms.date: 02/20/2025 ms.topic: whats-new --- # What's new in .NET libraries for .NET 10 This article describes new features in the .NET libraries for .NET 10. It has been updated for Preview 1. + +## Finding certificates by thumbprints other than SHA-1 + +Finding certificates uniquely by thumbprint is a fairly common operation, but the `X509Certificate2Collection.Find` method (for the `FindByThumbprint` mode) only searches for the SHA-1 Thumbprint value. + +Since SHA-2-256 ("SHA256") and SHA-3-256 have the same lengths, we decided that making the Find method find any vaguely matching thumbprints was not the best option. + +Instead, we introduced a new method that accepts the name of the hash algorithm that you want to use for matching. + +```C# +X509Certificate2Collection coll = store.Certificates.FindByThumbprint(HashAlgorithmName.SHA256, thumbprint); +Debug.Assert(coll.Count < 2, "Collection has too many matches, has SHA-2 been broken?"); +return coll.SingleOrDefault(); +``` + +## Finding PEM-encoded Data in ASCII/UTF-8 + +The PEM encoding (originally "Privacy Enhanced Mail", but now used widely outside of email) is defined for "text", which means that the `PemEncoding` class was designed to run on `System.String` and `ReadOnlySpan`. However, it's quite common (especially on Linux) to have something like a certificate written in a file that uses the ASCII (string) encoding. Historically, that meant you needed to open the file, convert the bytes to chars (or a string), and then you can use PemEncoding. + +Taking advantage of the fact that PEM is only defined for 7-bit ASCII characters, and that 7-bit ASCII has a perfect overlap with single-byte UTF-8 values, you can now skip the UTF-8/ASCII to char conversion and read the file directly. + +```diff +byte[] fileContents = File.ReadAllBytes(path); +-char[] text = Encoding.ASCII.GetString(fileContents); +-PemFields pemFields = PemEncoding.Find(text); ++PemFields pemFields = PemEncoding.FindUtf8(fileContents); + +-byte[] contents = Base64.DecodeFromChars(text.AsSpan()[pemFields.Base64Data]); ++byte[] contents = Base64.DecodeFromUtf8(fileContents.AsSpan()[pemFields.Base64Data]); +``` + +## New method overloads in ISOWeek for DateOnly type + +The ISOWeek class was originally designed to work exclusively with DateTime, as it was introduced before the DateOnly type existed. Now that DateOnly is available, it makes sense for ISOWeek to support it as well. + +```C# + public static class ISOWeek + { + // New overloads + public static int GetWeekOfYear(DateOnly date); + public static int GetYear(DateOnly date); + public static DateOnly ToDateOnly(int year, int week, DayOfWeek dayOfWeek); + } +``` + +## String normalization APIs to work with span of characters + +Unicode string normalization has been supported for a long time, but existing APIs have only worked with the string type. This means that callers with data stored in different forms, such as character arrays or spans, must allocate a new string to use these APIs. Additionally, APIs that return a normalized string always allocate a new string to represent the normalized output. + +The change introduces new APIs that work with spans of characters, expanding normalization beyond string types and helping to avoid unnecessary allocations. + +```C# + public static class StringNormalizationExtensions + { + public static int GetNormalizedLength(this ReadOnlySpan source, NormalizationForm normalizationForm = NormalizationForm.FormC); + public static bool IsNormalized(this ReadOnlySpan source, NormalizationForm normalizationForm = NormalizationForm.FormC); + public static bool TryNormalize(this ReadOnlySpan source, Span destination, out int charsWritten, NormalizationForm normalizationForm = NormalizationForm.FormC); + } +``` + +## Numeric ordering for string comparison + +Numerical string comparison is a highly requested feature () for comparing strings numerically instead of lexicographically. For example, `2` is less than `10`, so `"2"` should appear before `"10"` when ordered numerically. Similarly, `"2"` and `"02"` are equal numerically. With the new `CompareOptions.NumericOrdering` option, it is now possible to do these types of comparisons: + +```cs +StringComparer numericStringComparer = StringComparer.Create(CultureInfo.CurrentCulture, CompareOptions.NumericOrdering); + +Console.WriteLine(numericStringComparer.Equals("02", "2")); +// Output: True + +foreach (string os in new[] { "Windows 8", "Windows 10", "Windows 11" }.Order(numericStringComparer)) +{ + Console.WriteLine(os); +} + +// Output: +// Windows 8 +// Windows 10 +// Windows 11 + +HashSet set = new HashSet(numericStringComparer) { "007" }; +Console.WriteLine(set.Contains("7")); +// Output: True +``` + +Note that this option is not valid for the following index based string operations: `IndexOf`, `LastIndexOf`, `StartsWith`, `EndsWith`, `IsPrefix`, and `IsSuffix`. + +## Adding `TimeSpan.FromMilliseconds` overload with a single parameter + +Previously, we introduced the following method without adding an overload that takes a single parameter: + +```C# +public static TimeSpan FromMilliseconds(long milliseconds, long microseconds = 0); +``` + +Although this works since the second parameter is optional, it causes a compilation error when used in a LINQ expression like: + +```C# +Expression a = () => TimeSpan.FromMilliseconds(1000); +``` + +The issue arises because LINQ expressions cannot handle optional parameters. To address this, we are introducing an overload that takes a single parameter and modifying the existing method to make the second parameter mandatory: + +```C# +public readonly struct TimeSpan +{ + public static TimeSpan FromMilliseconds(long milliseconds, long microseconds); // Second parameter is no longer optional + public static TimeSpan FromMilliseconds(long milliseconds); // New overload +} +``` + +## ZipArchive performance and memory improvements + +Two significant PRs have been made by contributor @edwardneal in .NET 10 Preview 1 to improve the performance and memory usage of `ZipArchive`: + +- [dotnet/runtime #102704](https://github.com/dotnet/runtime/pull/102704) optimizes the way entries are written to a `ZipArchive` when in `Update` mode. Previously, all `ZipArchiveEntries` would be loaded into memory and rewritten, which could lead to high memory usage and performance bottlenecks. The optimization reduces memory usage and improves performance by avoiding the need to load all entries into memory. + +Adding a 2GB zip file to an existing archive showed: + +- A 99.8% reduction in execution time. +- A 99.9996% reduction in memory usage. + +### Benchmarks: + +| Method | Job | Runtime | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Gen2 | Allocated | Alloc Ratio | +|-----------|----------|-----------|---------:|-----------:|------------:|------:|--------:|----------:|----------:|----------:|----------:|------------:| +| Benchmark | Baseline | .NET 9.0 | 4.187 s | 83.3751 ms | 177.6792 ms | 1.002 | 0.06 | 1000.0000 | 1000.0000 | 1000.0000 | 2 GB | 1.000 | +| Benchmark | CoreRun | .NET 10.0 | 9.452 ms | 0.1583 ms | 0.1322 ms | 0.002 | 0.00 | - | - | - | 7.01 KB | 0.000 | + +Additional details are provided in [dotnet/runtime #102704](https://github.com/dotnet/runtime/pull/102704#issue-2317941700). + +- [dotnet/runtime #103153](https://github.com/dotnet/runtime/pull/103153) enhances the performance of `ZipArchive` by parallelizing the extraction of entries and optimizing internal data structures for better memory usage. These improvements address issues related to performance bottlenecks and high memory usage, making `ZipArchive` more efficient and faster, especially when dealing with large archives. + +Reading a zip archive showed: + +- An 18% reduction in execution time. +- An 18% reduction in memory usage. + +### Benchmarks: + +| Method | Job | Runtime | NumberOfFiles | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Gen2 | Allocated | Alloc Ratio | +|-----------|----------|-----------|---------------|----------------:|--------------:|--------------:|------:|--------:|----------:|---------:|---------:|-----------:|------------:| +| Benchmark | Baseline | .NET 9.0 | 2 | 1,178.6 ns | 23.23 ns | 22.81 ns | 1.00 | 0.03 | 0.3700 | - | - | 1.52 KB | 1.00 | +| Benchmark | CoreRun | .NET 10.0 | 2 | 821.6 ns | 12.45 ns | 11.65 ns | 0.70 | 0.02 | 0.2899 | - | - | 1.19 KB | 0.78 | +| | | | | | | | | | | | | | | +| Benchmark | Baseline | .NET 9.0 | 10 | 4,205.5 ns | 62.41 ns | 55.33 ns | 1.00 | 0.02 | 1.4954 | - | - | 6.13 KB | 1.00 | +| Benchmark | CoreRun | .NET 10.0 | 10 | 3,467.5 ns | 67.25 ns | 66.05 ns | 0.82 | 0.02 | 1.2054 | - | - | 4.93 KB | 0.80 | +| | | | | | | | | | | | | | | +| Benchmark | Baseline | .NET 9.0 | 25 | 10,201.5 ns | 190.59 ns | 187.18 ns | 1.00 | 0.02 | 3.5095 | - | - | 14.38 KB | 1.00 | +| Benchmark | CoreRun | .NET 10.0 | 25 | 8,210.2 ns | 152.35 ns | 142.51 ns | 0.81 | 0.02 | 2.8229 | - | - | 11.54 KB | 0.80 | +| | | | | | | | | | | | | | | +| Benchmark | Baseline | .NET 9.0 | 50 | 20,152.7 ns | 333.29 ns | 311.76 ns | 1.00 | 0.02 | 7.0496 | - | - | 28.91 KB | 1.00 | +| Benchmark | CoreRun | .NET 10.0 | 50 | 20,109.1 ns | 517.18 ns | 1,500.43 ns | 1.00 | 0.08 | 5.7068 | - | - | 23.34 KB | 0.81 | +| | | | | | | | | | | | | | | +| Benchmark | Baseline | .NET 9.0 | 100 | 46,986.2 ns | 923.08 ns | 1,906.33 ns | 1.00 | 0.06 | 14.2822 | 0.1221 | - | 58.42 KB | 1.00 | +| Benchmark | CoreRun | .NET 10.0 | 100 | 37,767.2 ns | 752.51 ns | 1,554.06 ns | 0.81 | 0.05 | 11.5967 | 0.0610 | - | 47.38 KB | 0.81 | +| | | | | | | | | | | | | | | +| Benchmark | Baseline | .NET 9.0 | 250 | 115,159.8 ns | 2,211.52 ns | 2,271.07 ns | 1.00 | 0.03 | 34.5459 | 0.1221 | - | 141.42 KB | 1.00 | +| Benchmark | CoreRun | .NET 10.0 | 250 | 94,148.7 ns | 1,842.33 ns | 3,414.87 ns | 0.82 | 0.03 | 27.8320 | 0.3662 | - | 113.97 KB | 0.81 | +| | | | | | | | | | | | | | | +| Benchmark | Baseline | .NET 9.0 | 500 | 241,338.5 ns | 4,726.33 ns | 7,896.64 ns | 1.00 | 0.05 | 69.8242 | 0.4883 | - | 285.86 KB | 1.00 | +| Benchmark | CoreRun | .NET 10.0 | 500 | 184,869.9 ns | 2,969.04 ns | 4,162.18 ns | 0.77 | 0.03 | 56.1523 | 0.7324 | - | 231.06 KB | 0.81 | +| | | | | | | | | | | | | | | +| Benchmark | Baseline | .NET 9.0 | 1000 | 510,114.6 ns | 10,092.12 ns | 20,386.57 ns | 1.00 | 0.05 | 114.2578 | 72.2656 | - | 577.2 KB | 1.00 | +| Benchmark | CoreRun | .NET 10.0 | 1000 | 404,349.3 ns | 7,289.88 ns | 16,153.88 ns | 0.79 | 0.04 | 93.2617 | 52.7344 | - | 467.72 KB | 0.81 | +| | | | | | | | | | | | | | | +| Benchmark | Baseline | .NET 9.0 | 10000 | 13,950,239.9 ns | 273,372.39 ns | 345,728.57 ns | 1.00 | 0.03 | 1000.0000 | 687.5000 | 218.7500 | 5786.24 KB | 1.00 | +| Benchmark | CoreRun | .NET 10.0 | 10000 | 10,911,298.0 ns | 204,013.47 ns | 226,760.43 ns | 0.78 | 0.02 | 843.7500 | 609.3750 | 250.0000 | 4692.19 KB | 0.81 | + +Creating an archive showed: + +- A 23-35% reduction in execution time. +- A 2% reduction in memory usage. + +Benchmarks: + +| Method | Job | Runtime | NumberOfFiles | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen0 | Gen1 | Allocated | Alloc Ratio | +|-----------|----------|-----------|---------------|----------:|----------:|-----------:|----------:|------:|--------:|--------:|--------:|----------:|------------:| +| Benchmark | Baseline | .NET 9.0 | 2 | 2.729 μs | 0.0538 μs | 0.0449 μs | 2.706 μs | 1.00 | 0.02 | 2.2697 | - | 9.28 KB | 1.00 | +| Benchmark | CoreRun | .NET 10.0 | 2 | 1.665 μs | 0.0256 μs | 0.0239 μs | 1.659 μs | 0.61 | 0.01 | 2.2259 | - | 9.1 KB | 0.98 | +| | | | | | | | | | | | | | | +| Benchmark | Baseline | .NET 9.0 | 10 | 10.341 μs | 0.1988 μs | 0.2289 μs | 10.266 μs | 1.00 | 0.03 | 9.7046 | - | 39.76 KB | 1.00 | +| Benchmark | CoreRun | .NET 10.0 | 10 | 7.937 μs | 0.1514 μs | 0.2487 μs | 7.831 μs | 0.77 | 0.03 | 9.5215 | - | 39.02 KB | 0.98 | +| | | | | | | | | | | | | | | +| Benchmark | Baseline | .NET 9.0 | 25 | 24.677 μs | 0.4903 μs | 0.8842 μs | 24.563 μs | 1.00 | 0.05 | 20.1721 | 3.3569 | 82.92 KB | 1.00 | +| Benchmark | CoreRun | .NET 10.0 | 25 | 18.247 μs | 0.3474 μs | 0.3412 μs | 18.192 μs | 0.74 | 0.03 | 19.7754 | 3.2654 | 81.13 KB | 0.98 | +| | | | | | | | | | | | | | | +| Benchmark | Baseline | .NET 9.0 | 50 | 67.420 μs | 5.7447 μs | 16.9384 μs | 57.185 μs | 1.05 | 0.35 | 40.5273 | 13.4888 | 166.71 KB | 1.00 | +| Benchmark | CoreRun | .NET 10.0 | 50 | 41.443 μs | 0.7212 μs | 0.8306 μs | 41.493 μs | 0.65 | 0.13 | 39.6729 | 0.0610 | 163.16 KB | 0.98 | + +Additional benchmarking details provided [in the PR description](https://github.com/dotnet/runtime/pull/103153#issue-2339713028). + +## Additional `TryAdd` and `TryGetValue` overloads for `OrderedDictionary` + +`OrderedDictionary` provides `TryAdd` and `TryGetValue` for addition and retrieval like any other `IDictionary` implementation. However, there are scenarios where you might want to perform additional operations, so new overloads have been added which return an index to the entry: + +```cs +public class OrderedDictionary +{ + // New overloads + public bool TryAdd(TKey key, TValue value, out int index); + public bool TryGetValue(TKey key, out TValue value, out int index); +} +``` + +This index can then be used with `GetAt`/`SetAt` for fast access to the entry. An example usage of the new `TryAdd` overload is to add or update a key/value pair in the ordered dictionary: + +```cs +public static void IncrementValue(OrderedDictionary orderedDictionary, string key) +{ + // Try to add a new key with value 1. + if (!orderedDictionary.TryAdd(key, 1, out int index)) + { + // Key was present, so increment the existing value instead. + int value = orderedDictionary.GetAt(index).Value; + orderedDictionary.SetAt(index, value + 1); + } +} +``` + +This new API is now being used in `JsonObject` to improve the performance of updating properties by 10-20%. + +## Allow specifying ReferenceHandler in `JsonSourceGenerationOptions` + +When using source generators for JSON serialization, the generated context will throw when cycles are serialized or deserialized. This behavior can now be customized by specifying the `ReferenceHandler` in the `JsonSourceGenerationOptionsAttribute`. Here is an example using `JsonKnownReferenceHandler.Preserve`: + +```cs +SelfReference selfRef = new SelfReference(); +selfRef.Me = selfRef; + +Console.WriteLine(JsonSerializer.Serialize(selfRef, ContextWithPreserveReference.Default.SelfReference)); +// Output: {"$id":"1","Me":{"$ref":"1"}} + +[JsonSourceGenerationOptions(ReferenceHandler = JsonKnownReferenceHandler.Preserve)] +[JsonSerializable(typeof(SelfReference))] +internal partial class ContextWithPreserveReference : JsonSerializerContext +{ +} + +internal class SelfReference +{ + public SelfReference Me { get; set; } +} +``` + +## More left-handed matrix transformation methods + +The remaining APIs for creating left-handed tranformation matrices have been added for billboard and constrained billboard matrices. These can be used like their existing right-handed counterparts when using a left-handed coordinate system instead. + +```cs +public partial struct Matrix4x4 +{ + public static Matrix4x4 CreateBillboardLeftHanded(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3 cameraForwardVector) + public static Matrix4x4 CreateConstrainedBillboardLeftHanded(Vector3 objectPosition, Vector3 cameraPosition, Vector3 rotateAxis, Vector3 cameraForwardVector, Vector3 objectForwardVector) +} +``` \ No newline at end of file diff --git a/docs/core/whats-new/dotnet-10/overview.md b/docs/core/whats-new/dotnet-10/overview.md index e4b2e88f012fc..df493bd3763b4 100644 --- a/docs/core/whats-new/dotnet-10/overview.md +++ b/docs/core/whats-new/dotnet-10/overview.md @@ -2,7 +2,7 @@ title: What's new in .NET 10 description: Learn about the new features introduced in .NET 10 for the runtime, libraries, and SDK. Also find links to what's new in other areas, such as ASP.NET Core. titleSuffix: "" -ms.date: 02/12/2025 +ms.date: 02/20/2025 ms.topic: whats-new --- @@ -10,23 +10,32 @@ ms.topic: whats-new Learn about the new features in .NET 10 and find links to further documentation. This page has been updated for Preview 1. -TODO - Add a brief overview of the new features in .NET 10. - ## .NET runtime -TODO - Add a brief overview of the new features in the .NET 10 runtime. +- [Array interface method devirtualization](runtime.md#array-interface-method-devirtualization) +- [Stack allocation of arrays of value types](runtime.md#stack-allocation-of-arrays-of-value-types) +- [AVX10.2 support](runtime.md#avx102-support) For more information, see [What's new in the .NET 10 runtime](runtime.md). ## .NET libraries -TODO - Add a brief overview of the new features in the .NET 10 libraries. +- [Finding certificates by thumbprints other than SHA-1](libraries.md#finding-certificates-by-thumbprints-other-than-sha-1) +- [Finding PEM-encoded data in ASCII/UTF-8](libraries.md#finding-pem-encoded-data-in-asciiutf-8) +- [New method overloads in ISOWeek for DateOnly type](libraries.md#new-method-overloads-in-isoweek-for-dateonly-type) +- [String normalization APIs to work with span of characters](libraries.md#string-normalization-apis-to-work-with-span-of-characters) +- [Numeric ordering for string comparison](libraries.md#numeric-ordering-for-string-comparison) +- [Adding TimeSpan.FromMilliseconds overload with a single parameter](libraries.md#adding-timespanfrommilliseconds-overload-with-a-single-parameter) +- [ZipArchive performance and memory improvements](libraries.md#ziparchive-performance-and-memory-improvements) +- [Additional TryAdd and TryGetValue overloads for OrderedDictionary](libraries.md#additional-tryadd-and-trygetvalue-overloads-for-ordereddictionarytkey-tvalue) +- [Allow specifying ReferenceHandler in JsonSourceGenerationOptions](libraries.md#allow-specifying-referencehandler-in-jsonsourcegenerationoptions) +- [More left-handed matrix transformation methods](libraries.md#more-left-handed-matrix-transformation-methods) For more information, see [What's new in the .NET 10 libraries](libraries.md). ## .NET SDK -TODO - Add a brief overview of the new features in the .NET 10 SDK. +- [Pruning of Framework-provided Package References](sdk.md#pruning-of-framework-provided-package-references) For more information, see [What's new in the SDK for .NET 10](sdk.md). @@ -36,7 +45,16 @@ TODO - Add a brief overview of the new features in .NET Aspire. ## ASP.NET Core -TODO - Add a brief overview of the new features in ASP.NET Core for .NET 10. +- [OpenAPI 3.1 support](/aspnet/core/release-notes/aspnetcore-10.0#openapi-31-support) +- [Generate OpenAPI documents in YAML format](/aspnet/core/release-notes/aspnetcore-10.0?view=aspnetcore-9.0#openapi-in-yaml) +- [Response description on `ProducesResponseType`](/aspnet/core/release-notes/aspnetcore-10.0#response-description-on-producesresponsetype) +- [Detect if URL is local using `RedirectHttpResult.IsLocalUrl`](/aspnet/core/release-notes/aspnetcore-10.0#detect-if-url-is-local-using-redirecthttpresultislocalurl) +- [Improvements to integration testing of apps with top-level statements](/aspnet/core/release-notes/aspnetcore-10.0?view=aspnetcore-9.0#better-support-for-testing-apps-with-top-level-statements) +- [QuickGrid `RowClass` parameter](/aspnet/core/release-notes/aspnetcore-10.0#quickgrid-rowclass-parameter) +- [Blazor script as a static web asset](/aspnet/core/release-notes/aspnetcore-10.0?view=aspnetcore-9.0#blazor-script) +- [Route syntax highlighting for Blazor `RouteAttribute`](/aspnet/core/release-notes/aspnetcore-10.0#route-syntax-highlighting-for-blazor-routeattribute) + +For more information, see [What's new in ASP.NET Core for .NET 10](/aspnet/core/release-notes/aspnetcore-10.0). ## .NET MAUI @@ -44,11 +62,21 @@ TODO - Add a brief overview of the new features in .NET MAUI for .NET 10. ## EF Core -TODO - Add a brief overview of the new features in EF Core for .NET 10. +- [Support for the .NET 10 LeftJoin operator](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/efcore.md#support-for-the-net-10-leftjoin-operator) +- [ExecuteUpdateAsync now accepts a regular, non-expression lambda](/ef/core/what-is-new/ef-core-10.0/whatsnew#executeupdateasync-now-accepts-a-regular-non-expression-lambda) +- [Several small improvements](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/efcore.md#small-improvements) + +For more information, see [What's new in EF Core for .NET 10](/ef/core/what-is-new/ef-core-10.0/whatsnew). ## C# 14 -TODO - Add a brief overview of the new features in C# 14. +- [`nameof` in unbound generics](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/csharp.md#unbound-generic-support-for-nameof) +- [Implicit span conversions](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/csharp.md#implicit-span-conversions) +- [`field` backed properties](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/csharp.md#field-backed-properties) +- [Modifiers on simple lambda parameters](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/csharp.md#modifiers-on-simple-lambda-parameters) +- [Experimental feature - String literals in data section](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/csharp.md#preview-feature-string-literals-in-data-section) + +For more information, see [What's new in C# 14](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/csharp.md). ## Windows Forms diff --git a/docs/core/whats-new/dotnet-10/runtime.md b/docs/core/whats-new/dotnet-10/runtime.md index 5ff2e4431fc8c..2791a960d3ee7 100644 --- a/docs/core/whats-new/dotnet-10/runtime.md +++ b/docs/core/whats-new/dotnet-10/runtime.md @@ -2,9 +2,79 @@ title: What's new in .NET 10 runtime description: Learn about the new .NET features introduced in the .NET 10 runtime. titleSuffix: "" -ms.date: 02/12/2025 +ms.date: 02/20/2025 ms.topic: whats-new --- # What's new in the .NET 10 runtime This article describes new features and performance improvements in the .NET runtime for .NET 10. It has been updated for Preview 1. + +## Array interface method devirtualization + +Reducing the abstraction overhead of popular language features is one of the code generation team's [focus areas](https://github.com/dotnet/runtime/issues/108988) for .NET 10. In pursuit of this goal, we have expanded the JIT's ability to devirtualize method calls to cover array interface methods. + +Consider the typical approach of looping over an array: + +```csharp +static int Sum(int[] array) +{ + int sum = 0; + for (int i = 0; i < array.Length; i++) + { + sum += array[i]; + } + return sum; +} +``` + +This code shape is easy for the JIT to optimize, mainly because there aren't any virtual calls to reason about. Instead, the JIT can focus on removing bounds checks on the array access, and applying the loop optimizations we added in .NET 9. Let's tweak the above example to add some virtual calls: + +```csharp +static int Sum(int[] array) +{ + int sum = 0; + IEnumerable temp = array; + + foreach (var num in temp) + { + sum += num; + } + return sum; +} +``` + +The type of the underlying collection is clear, and the JIT should be able to transform this snippet into the first one. However, array interfaces are implemented differently from "normal" interfaces, such that the JIT does not know how to devirtualize them. This means the enumerator calls in the for-each loop remain virtual, blocking multiple optimizations: inlining, stack allocation, and others. + +The JIT can now devirtualize and inline array interface methods, thanks to work in [dotnet/runtime #108153](https://github.com/dotnet/runtime/pull/108153) and [dotnet/runtime #109209](https://github.com/dotnet/runtime/pull/109209). This is the first of many steps we will be taking to achieve performance parity between the above implementations, as detailed in our [de-abstraction plans](https://github.com/dotnet/runtime/issues/108913) for .NET 10. + +## Stack allocation of arrays of value types + +In .NET 9, the JIT gained the ability to allocate objects on the stack, when the object is guaranteed to not outlive its parent method. Not only does stack allocation reduce the number of objects the GC has to track, but it also unlocks other optimizations: For example, after an object has been stack-allocated, the JIT can consider replacing it entirely with its scalar values. Because of this, stack allocation is key to reducing the abstraction penalty of reference types. + +Thanks to [dotnet/runtime #104906](https://github.com/dotnet/runtime/pull/104906) (credit: [@hez2010](https://github.com/hez2010)), the JIT will now stack-allocate small, fixed-sized arrays of value types that don't contain GC pointers when it can make the same lifetime guarantees described above. Consider the following example: + +```csharp +static void Sum() +{ + int[] numbers = {1, 2, 3}; + int sum = 0; + + for (int i = 0; i < numbers.Length; i++) + { + sum += numbers[i]; + } + + Console.WriteLine(sum); +} + +``` + +Because the JIT knows `numbers` is an array of only three integers at compile-time, and it does not outlive a call to `Sum`, it will now allocate it on the stack. + +Among other [stack allocation enhancements](https://github.com/dotnet/runtime/issues/104936), we plan to expand this ability to arrays of reference types in the coming previews. + +## AVX10.2 support + +[dotnet/runtime #111209](https://github.com/dotnet/runtime/pull/111209) (credit: [@khushal1996](https://github.com/khushal1996)) enables support for the Advanced Vector Extensions (AVX) 10.2 for x64-based processors. The new intrinsics available in the `System.Runtime.Intrinsics.X86.Avx10v2` class can be tested once capable hardware is available. In the next several previews, we plan to further incorporate AVX10.2 support into the JIT's emitter to take full advantage of the instruction set's features. + +Because AVX10.2-enabled hardware is not yet available, the JIT's support for AVX10.2 is disabled by default for now. We plan to enable it once we have thoroughly tested it. \ No newline at end of file diff --git a/docs/core/whats-new/dotnet-10/sdk.md b/docs/core/whats-new/dotnet-10/sdk.md index dc7aca9fed143..8b83c4091c946 100644 --- a/docs/core/whats-new/dotnet-10/sdk.md +++ b/docs/core/whats-new/dotnet-10/sdk.md @@ -2,7 +2,7 @@ title: What's new in the SDK and tooling for .NET 10 description: Learn about the new .NET SDK features introduced in .NET 10. titleSuffix: "" -ms.date: 02/12/2025 +ms.date: 02/20/2025 ms.topic: whats-new --- @@ -14,10 +14,10 @@ This article describes new features and enhancements in the .NET SDK for .NET 10 - [Pruning of Framework-provided Package References](#pruning-of-framework-provided-package-references) -## Pruning of Framework-provided Package References +## Pruning of framework-provided package references Starting in .NET 10, the [NuGet Audit](https://learn.microsoft.com/nuget/concepts/auditing-packages) feature can now [prune framework-provided package references](https://github.com/NuGet/Home/blob/451c27180d14214bca60483caee57f0dc737b8cf/accepted/2024/prune-package-reference.md) that are not used by the project. This feature will be enabled by default for all .NET TargetFrameworks (e.g. `net8.0`, `net10.0`) and .NET Standard 2.0 and greater TargetFrameworks. This change will help reduce the number of packages that are restored and analyzed during the build process, which can lead to faster build times and reduced disk space usage. It also can lead to a reduction in false positives from NuGet Audit and other dependency-scanning mechanisms. -When this feature is enabled, you should see a marked reduction in the contents of your applications' generated `.deps.json` files - any PackageReferences you may have had that are actually being supplied by the .NET Runtime you use will be automatically removed from the generated dependency file. +When this feature is enabled, you should see a marked reduction in the contents of your applications' generated *.deps.json* files - any PackageReferences you may have had that are actually being supplied by the .NET Runtime you use will be automatically removed from the generated dependency file. -While this feature is enabled by default for the TFMs listed above, you can disable it by setting the `RestoreEnablePackagePruning` property to `false` in your project file or Directory.Build.props file. +While this feature is enabled by default for the TFMs listed above, you can disable it by setting the `RestoreEnablePackagePruning` property to `false` in your project file or *Directory.Build.props* file. From 3844a83607c64b0d39241242cc9800a6c8f24662 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Wed, 19 Feb 2025 20:09:05 +0000 Subject: [PATCH 10/24] more links --- docs/core/whats-new/dotnet-10/overview.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/core/whats-new/dotnet-10/overview.md b/docs/core/whats-new/dotnet-10/overview.md index df493bd3763b4..9754a5b836f86 100644 --- a/docs/core/whats-new/dotnet-10/overview.md +++ b/docs/core/whats-new/dotnet-10/overview.md @@ -80,8 +80,14 @@ For more information, see [What's new in C# 14](https://github.com/dotnet/core/b ## Windows Forms -TODO - Add a brief overview of the new features in Windows Forms for .NET 10. +- [Clipboard related serialization and deserialization changes](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/winforms.md#clipboard-related-serialization-and-deserialization-changes) +- [Obsoleted Clipboard APIs](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/winforms.md#obsoleted-clipboard-apis) +- [New Clipboard related APIs](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/winforms.md#new-clipboard-related-apis) + +For more information, see [What's new in Windows Forms for .NET 10](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/winforms.md). ## See also -TODO - Add links to other "What's new" articles for .NET 10. +- [.NET 10 Preview 1 container image updates](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/containers.md) +- [F# updates in .NET 10 Preview 1](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/fsharp.md) +- [Visual Basic updates in .NET 10 Preview 1](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/visualbasic.md) \ No newline at end of file From afdd7c7f298b50e37c45e4df5738891712a7cb6b Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Wed, 19 Feb 2025 20:17:13 +0000 Subject: [PATCH 11/24] lint --- docs/core/whats-new/dotnet-10/libraries.md | 2 +- docs/core/whats-new/dotnet-10/overview.md | 2 +- docs/core/whats-new/dotnet-10/runtime.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/core/whats-new/dotnet-10/libraries.md b/docs/core/whats-new/dotnet-10/libraries.md index 6b66cd3254aa7..fd1e261aba0d5 100644 --- a/docs/core/whats-new/dotnet-10/libraries.md +++ b/docs/core/whats-new/dotnet-10/libraries.md @@ -264,4 +264,4 @@ public partial struct Matrix4x4 public static Matrix4x4 CreateBillboardLeftHanded(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3 cameraForwardVector) public static Matrix4x4 CreateConstrainedBillboardLeftHanded(Vector3 objectPosition, Vector3 cameraPosition, Vector3 rotateAxis, Vector3 cameraForwardVector, Vector3 objectForwardVector) } -``` \ No newline at end of file +``` diff --git a/docs/core/whats-new/dotnet-10/overview.md b/docs/core/whats-new/dotnet-10/overview.md index 9754a5b836f86..243b097262512 100644 --- a/docs/core/whats-new/dotnet-10/overview.md +++ b/docs/core/whats-new/dotnet-10/overview.md @@ -90,4 +90,4 @@ For more information, see [What's new in Windows Forms for .NET 10](https://gith - [.NET 10 Preview 1 container image updates](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/containers.md) - [F# updates in .NET 10 Preview 1](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/fsharp.md) -- [Visual Basic updates in .NET 10 Preview 1](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/visualbasic.md) \ No newline at end of file +- [Visual Basic updates in .NET 10 Preview 1](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/visualbasic.md) diff --git a/docs/core/whats-new/dotnet-10/runtime.md b/docs/core/whats-new/dotnet-10/runtime.md index 2791a960d3ee7..69bec4fa06b3e 100644 --- a/docs/core/whats-new/dotnet-10/runtime.md +++ b/docs/core/whats-new/dotnet-10/runtime.md @@ -77,4 +77,4 @@ Among other [stack allocation enhancements](https://github.com/dotnet/runtime/is [dotnet/runtime #111209](https://github.com/dotnet/runtime/pull/111209) (credit: [@khushal1996](https://github.com/khushal1996)) enables support for the Advanced Vector Extensions (AVX) 10.2 for x64-based processors. The new intrinsics available in the `System.Runtime.Intrinsics.X86.Avx10v2` class can be tested once capable hardware is available. In the next several previews, we plan to further incorporate AVX10.2 support into the JIT's emitter to take full advantage of the instruction set's features. -Because AVX10.2-enabled hardware is not yet available, the JIT's support for AVX10.2 is disabled by default for now. We plan to enable it once we have thoroughly tested it. \ No newline at end of file +Because AVX10.2-enabled hardware is not yet available, the JIT's support for AVX10.2 is disabled by default for now. We plan to enable it once we have thoroughly tested it. From 8bbc6b533fa0369aefbffd3e7ddcde794c53cb59 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Wed, 19 Feb 2025 16:13:57 -0600 Subject: [PATCH 12/24] Apply suggestions from code review Thank you @gewarren! Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- docs/core/whats-new/dotnet-10/overview.md | 2 +- docs/core/whats-new/dotnet-10/runtime.md | 18 +++++++++--------- docs/core/whats-new/dotnet-10/sdk.md | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/core/whats-new/dotnet-10/overview.md b/docs/core/whats-new/dotnet-10/overview.md index 243b097262512..3003acd5392c6 100644 --- a/docs/core/whats-new/dotnet-10/overview.md +++ b/docs/core/whats-new/dotnet-10/overview.md @@ -41,7 +41,7 @@ For more information, see [What's new in the SDK for .NET 10](sdk.md). ## .NET Aspire -TODO - Add a brief overview of the new features in .NET Aspire. + ## ASP.NET Core diff --git a/docs/core/whats-new/dotnet-10/runtime.md b/docs/core/whats-new/dotnet-10/runtime.md index 69bec4fa06b3e..5faf1cd98a632 100644 --- a/docs/core/whats-new/dotnet-10/runtime.md +++ b/docs/core/whats-new/dotnet-10/runtime.md @@ -11,7 +11,7 @@ This article describes new features and performance improvements in the .NET run ## Array interface method devirtualization -Reducing the abstraction overhead of popular language features is one of the code generation team's [focus areas](https://github.com/dotnet/runtime/issues/108988) for .NET 10. In pursuit of this goal, we have expanded the JIT's ability to devirtualize method calls to cover array interface methods. +One of the code generation team's [focus areas](https://github.com/dotnet/runtime/issues/108988) for .NET 10 is to reduce the abstraction overhead of popular language features. In pursuit of this goal, the JIT's ability to devirtualize method calls has been expanded to cover array interface methods. Consider the typical approach of looping over an array: @@ -27,7 +27,7 @@ static int Sum(int[] array) } ``` -This code shape is easy for the JIT to optimize, mainly because there aren't any virtual calls to reason about. Instead, the JIT can focus on removing bounds checks on the array access, and applying the loop optimizations we added in .NET 9. Let's tweak the above example to add some virtual calls: +This code shape is easy for the JIT to optimize, mainly because there aren't any virtual calls to reason about. Instead, the JIT can focus on removing bounds checks on the array access and applying the [loop optimizations that were added in .NET 9](../add/link/to/file/here.md#heading). The following example adds some virtual calls: ```csharp static int Sum(int[] array) @@ -43,15 +43,15 @@ static int Sum(int[] array) } ``` -The type of the underlying collection is clear, and the JIT should be able to transform this snippet into the first one. However, array interfaces are implemented differently from "normal" interfaces, such that the JIT does not know how to devirtualize them. This means the enumerator calls in the for-each loop remain virtual, blocking multiple optimizations: inlining, stack allocation, and others. +The type of the underlying collection is clear, and the JIT should be able to transform this snippet into the first one. However, array interfaces are implemented differently from "normal" interfaces, such that the JIT does not know how to devirtualize them. This means the enumerator calls in the `for-each` loop remain virtual, blocking multiple optimizations such as inlining and stack allocation. -The JIT can now devirtualize and inline array interface methods, thanks to work in [dotnet/runtime #108153](https://github.com/dotnet/runtime/pull/108153) and [dotnet/runtime #109209](https://github.com/dotnet/runtime/pull/109209). This is the first of many steps we will be taking to achieve performance parity between the above implementations, as detailed in our [de-abstraction plans](https://github.com/dotnet/runtime/issues/108913) for .NET 10. +Starting in .NET 10, the JIT can devirtualize and inline array interface methods. This is the first of many steps to achieve performance parity between the implementations, as detailed in the [.NET 10 de-abstraction plans](https://github.com/dotnet/runtime/issues/108913). ## Stack allocation of arrays of value types -In .NET 9, the JIT gained the ability to allocate objects on the stack, when the object is guaranteed to not outlive its parent method. Not only does stack allocation reduce the number of objects the GC has to track, but it also unlocks other optimizations: For example, after an object has been stack-allocated, the JIT can consider replacing it entirely with its scalar values. Because of this, stack allocation is key to reducing the abstraction penalty of reference types. +In .NET 9, the JIT gained the ability to allocate objects on the stack, when the object is guaranteed to not outlive its parent method. Not only does stack allocation reduce the number of objects the GC has to track, but it also unlocks other optimizations. For example, after an object has been stack-allocated, the JIT can consider replacing it entirely with its scalar values. Because of this, stack allocation is key to reducing the abstraction penalty of reference types. -Thanks to [dotnet/runtime #104906](https://github.com/dotnet/runtime/pull/104906) (credit: [@hez2010](https://github.com/hez2010)), the JIT will now stack-allocate small, fixed-sized arrays of value types that don't contain GC pointers when it can make the same lifetime guarantees described above. Consider the following example: +In .NET 10, the JIT now stack-allocates small, fixed-sized arrays of value types that don't contain GC pointers when it can make the same lifetime guarantees described previously. Consider the following example: ```csharp static void Sum() @@ -69,12 +69,12 @@ static void Sum() ``` -Because the JIT knows `numbers` is an array of only three integers at compile-time, and it does not outlive a call to `Sum`, it will now allocate it on the stack. +Because the JIT knows `numbers` is an array of only three integers at compile time, and it doesn't outlive a call to `Sum`, it allocates it on the stack. Among other [stack allocation enhancements](https://github.com/dotnet/runtime/issues/104936), we plan to expand this ability to arrays of reference types in the coming previews. ## AVX10.2 support -[dotnet/runtime #111209](https://github.com/dotnet/runtime/pull/111209) (credit: [@khushal1996](https://github.com/khushal1996)) enables support for the Advanced Vector Extensions (AVX) 10.2 for x64-based processors. The new intrinsics available in the `System.Runtime.Intrinsics.X86.Avx10v2` class can be tested once capable hardware is available. In the next several previews, we plan to further incorporate AVX10.2 support into the JIT's emitter to take full advantage of the instruction set's features. +.NET 10 introduces support for the Advanced Vector Extensions (AVX) 10.2 for x64-based processors. The new intrinsics available in the `System.Runtime.Intrinsics.X86.Avx10v2` class can be tested once capable hardware is available. -Because AVX10.2-enabled hardware is not yet available, the JIT's support for AVX10.2 is disabled by default for now. We plan to enable it once we have thoroughly tested it. +Because AVX10.2-enabled hardware is not yet available, the JIT's support for AVX10.2 is currently disabled by default. diff --git a/docs/core/whats-new/dotnet-10/sdk.md b/docs/core/whats-new/dotnet-10/sdk.md index 8b83c4091c946..e3601c55dc66f 100644 --- a/docs/core/whats-new/dotnet-10/sdk.md +++ b/docs/core/whats-new/dotnet-10/sdk.md @@ -12,12 +12,12 @@ This article describes new features and enhancements in the .NET SDK for .NET 10 ## New features and enhancements -- [Pruning of Framework-provided Package References](#pruning-of-framework-provided-package-references) +- [Pruning of framework-provided package references](#pruning-of-framework-provided-package-references) ## Pruning of framework-provided package references -Starting in .NET 10, the [NuGet Audit](https://learn.microsoft.com/nuget/concepts/auditing-packages) feature can now [prune framework-provided package references](https://github.com/NuGet/Home/blob/451c27180d14214bca60483caee57f0dc737b8cf/accepted/2024/prune-package-reference.md) that are not used by the project. This feature will be enabled by default for all .NET TargetFrameworks (e.g. `net8.0`, `net10.0`) and .NET Standard 2.0 and greater TargetFrameworks. This change will help reduce the number of packages that are restored and analyzed during the build process, which can lead to faster build times and reduced disk space usage. It also can lead to a reduction in false positives from NuGet Audit and other dependency-scanning mechanisms. +Starting in .NET 10, the [NuGet Audit](/nuget/concepts/auditing-packages) feature can now [prune framework-provided package references](https://github.com/NuGet/Home/blob/451c27180d14214bca60483caee57f0dc737b8cf/accepted/2024/prune-package-reference.md) that aren't used by the project. This feature is enabled by default for all `net` target frameworks (for example, `net8.0` and `net10.0`) and .NET Standard 2.0 and greater target frameworks. This change helps to reduce the number of packages that are restored and analyzed during the build process, which can lead to faster build times and reduced disk space usage. It also can lead to a reduction in false positives from NuGet Audit and other dependency-scanning mechanisms. -When this feature is enabled, you should see a marked reduction in the contents of your applications' generated *.deps.json* files - any PackageReferences you may have had that are actually being supplied by the .NET Runtime you use will be automatically removed from the generated dependency file. +When this feature is enabled, you should see a marked reduction in the contents of your applications' generated *.deps.json* files. Any package references you might have had that are actually supplied by the .NET runtime you use are automatically removed from the generated dependency file. -While this feature is enabled by default for the TFMs listed above, you can disable it by setting the `RestoreEnablePackagePruning` property to `false` in your project file or *Directory.Build.props* file. +While this feature is enabled by default for the listed TFMs, you can disable it by setting the `RestoreEnablePackagePruning` property to `false` in your project file or *Directory.Build.props* file. From 38427a00e1c6cbcd12bc3c2b0ae1a0f595118ca5 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Wed, 19 Feb 2025 23:47:32 +0000 Subject: [PATCH 13/24] tweaks --- docs/core/whats-new/dotnet-10/libraries.md | 52 +++++++++---------- .../snippets/dotnet-10/csharp/Program.cs | 2 + .../snippets/dotnet-10/csharp/Project.csproj | 11 ++++ docs/whats-new/toc.yml | 6 +-- 4 files changed, 39 insertions(+), 32 deletions(-) create mode 100644 docs/core/whats-new/snippets/dotnet-10/csharp/Program.cs create mode 100644 docs/core/whats-new/snippets/dotnet-10/csharp/Project.csproj diff --git a/docs/core/whats-new/dotnet-10/libraries.md b/docs/core/whats-new/dotnet-10/libraries.md index fd1e261aba0d5..00b508554758a 100644 --- a/docs/core/whats-new/dotnet-10/libraries.md +++ b/docs/core/whats-new/dotnet-10/libraries.md @@ -10,13 +10,13 @@ ms.topic: whats-new This article describes new features in the .NET libraries for .NET 10. It has been updated for Preview 1. -## Finding certificates by thumbprints other than SHA-1 +## Find certificates by thumbprints other than SHA-1 -Finding certificates uniquely by thumbprint is a fairly common operation, but the `X509Certificate2Collection.Find` method (for the `FindByThumbprint` mode) only searches for the SHA-1 Thumbprint value. +Finding certificates uniquely by thumbprint is a fairly common operation, but the method (for the mode) only searches for the SHA-1 Thumbprint value. -Since SHA-2-256 ("SHA256") and SHA-3-256 have the same lengths, we decided that making the Find method find any vaguely matching thumbprints was not the best option. +Since SHA-2-256 ("SHA256") and SHA-3-256 have the same lengths, it doesn't make sense to implement the `Find` method to find any *vaguely* matching thumbprints. -Instead, we introduced a new method that accepts the name of the hash algorithm that you want to use for matching. +Instead, .NET 10 introduces a new method that accepts the name of the hash algorithm to use for matching. ```C# X509Certificate2Collection coll = store.Certificates.FindByThumbprint(HashAlgorithmName.SHA256, thumbprint); @@ -24,11 +24,11 @@ Debug.Assert(coll.Count < 2, "Collection has too many matches, has SHA-2 been br return coll.SingleOrDefault(); ``` -## Finding PEM-encoded Data in ASCII/UTF-8 +## Find PEM-encoded Data in ASCII/UTF-8 -The PEM encoding (originally "Privacy Enhanced Mail", but now used widely outside of email) is defined for "text", which means that the `PemEncoding` class was designed to run on `System.String` and `ReadOnlySpan`. However, it's quite common (especially on Linux) to have something like a certificate written in a file that uses the ASCII (string) encoding. Historically, that meant you needed to open the file, convert the bytes to chars (or a string), and then you can use PemEncoding. +The PEM encoding (originally "Privacy Enhanced Mail", but now used widely outside of email) is defined for "text", which means that the class was designed to run on and `ReadOnlySpan`. However, it's quite common (especially on Linux) to have something like a certificate written in a file that uses the ASCII (string) encoding. Historically, that meant you needed to open the file and convert the bytes to chars (or a string) before you could use `PemEncoding`. -Taking advantage of the fact that PEM is only defined for 7-bit ASCII characters, and that 7-bit ASCII has a perfect overlap with single-byte UTF-8 values, you can now skip the UTF-8/ASCII to char conversion and read the file directly. +Taking advantage of the fact that PEM is only defined for 7-bit ASCII characters, and that 7-bit ASCII has a perfect overlap with single-byte UTF-8 values, you can now skip the UTF-8/ASCII-to-char conversion and read the file directly. ```diff byte[] fileContents = File.ReadAllBytes(path); @@ -42,7 +42,7 @@ byte[] fileContents = File.ReadAllBytes(path); ## New method overloads in ISOWeek for DateOnly type -The ISOWeek class was originally designed to work exclusively with DateTime, as it was introduced before the DateOnly type existed. Now that DateOnly is available, it makes sense for ISOWeek to support it as well. +The class was originally designed to work exclusively with , as it was introduced before the type existed. Now that `DateOnly` is available, it makes sense for `ISOWeek` to support it as well. ```C# public static class ISOWeek @@ -58,7 +58,7 @@ The ISOWeek class was originally designed to work exclusively with DateTime, as Unicode string normalization has been supported for a long time, but existing APIs have only worked with the string type. This means that callers with data stored in different forms, such as character arrays or spans, must allocate a new string to use these APIs. Additionally, APIs that return a normalized string always allocate a new string to represent the normalized output. -The change introduces new APIs that work with spans of characters, expanding normalization beyond string types and helping to avoid unnecessary allocations. +.NET 10 introduces new APIs that work with spans of characters, expanding normalization beyond string types and helping to avoid unnecessary allocations. ```C# public static class StringNormalizationExtensions @@ -71,7 +71,7 @@ The change introduces new APIs that work with spans of characters, expanding nor ## Numeric ordering for string comparison -Numerical string comparison is a highly requested feature () for comparing strings numerically instead of lexicographically. For example, `2` is less than `10`, so `"2"` should appear before `"10"` when ordered numerically. Similarly, `"2"` and `"02"` are equal numerically. With the new `CompareOptions.NumericOrdering` option, it is now possible to do these types of comparisons: +Numerical string comparison is a highly requested feature for comparing strings numerically instead of lexicographically. For example, `2` is less than `10`, so `"2"` should appear before `"10"` when ordered numerically. Similarly, `"2"` and `"02"` are equal numerically. With the new `CompareOptions.NumericOrdering` option, it's now possible to do these types of comparisons: ```cs StringComparer numericStringComparer = StringComparer.Create(CultureInfo.CurrentCulture, CompareOptions.NumericOrdering); @@ -94,25 +94,21 @@ Console.WriteLine(set.Contains("7")); // Output: True ``` -Note that this option is not valid for the following index based string operations: `IndexOf`, `LastIndexOf`, `StartsWith`, `EndsWith`, `IsPrefix`, and `IsSuffix`. +Note that this option is not valid for the following index-based string operations: `IndexOf`, `LastIndexOf`, `StartsWith`, `EndsWith`, `IsPrefix`, and `IsSuffix`. -## Adding `TimeSpan.FromMilliseconds` overload with a single parameter +## New `TimeSpan.FromMilliseconds` overload with single parameter -Previously, we introduced the following method without adding an overload that takes a single parameter: - -```C# -public static TimeSpan FromMilliseconds(long milliseconds, long microseconds = 0); -``` +The method was introduced previously without adding an overload that takes a single parameter. Although this works since the second parameter is optional, it causes a compilation error when used in a LINQ expression like: -```C# +```csharp Expression a = () => TimeSpan.FromMilliseconds(1000); ``` -The issue arises because LINQ expressions cannot handle optional parameters. To address this, we are introducing an overload that takes a single parameter and modifying the existing method to make the second parameter mandatory: +The issue arises because LINQ expressions cannot handle optional parameters. To address this, .NET 10 introduces an overload takes a single parameter and modifying the existing method to make the second parameter mandatory: -```C# +```csharp public readonly struct TimeSpan { public static TimeSpan FromMilliseconds(long milliseconds, long microseconds); // Second parameter is no longer optional @@ -128,7 +124,7 @@ Two significant PRs have been made by contributor @edwardneal in .NET 10 Preview Adding a 2GB zip file to an existing archive showed: -- A 99.8% reduction in execution time. +First, the way entries are written to a `ZipArchive` when in `Update` mode has been optimized. Previously, all instances were loaded into memory and rewritten, which could lead to high memory usage and performance bottlenecks. The optimization reduces memory usage and improves performance by avoiding the need to load all entries into memory. - A 99.9996% reduction in memory usage. ### Benchmarks: @@ -203,9 +199,9 @@ Additional benchmarking details provided [in the PR description](https://github. ## Additional `TryAdd` and `TryGetValue` overloads for `OrderedDictionary` -`OrderedDictionary` provides `TryAdd` and `TryGetValue` for addition and retrieval like any other `IDictionary` implementation. However, there are scenarios where you might want to perform additional operations, so new overloads have been added which return an index to the entry: +`OrderedDictionary` provides `TryAdd` and `TryGetValue` for addition and retrieval like any other `IDictionary` implementation. However, there are scenarios where you might want to perform additional operations, so new overloads have been added that return an index to the entry: -```cs +```csharp public class OrderedDictionary { // New overloads @@ -214,7 +210,7 @@ public class OrderedDictionary } ``` -This index can then be used with `GetAt`/`SetAt` for fast access to the entry. An example usage of the new `TryAdd` overload is to add or update a key/value pair in the ordered dictionary: +This index can then be used with / for fast access to the entry. An example usage of the new `TryAdd` overload is to add or update a key/value pair in the ordered dictionary: ```cs public static void IncrementValue(OrderedDictionary orderedDictionary, string key) @@ -233,9 +229,9 @@ This new API is now being used in `JsonObject` to improve the performance of upd ## Allow specifying ReferenceHandler in `JsonSourceGenerationOptions` -When using source generators for JSON serialization, the generated context will throw when cycles are serialized or deserialized. This behavior can now be customized by specifying the `ReferenceHandler` in the `JsonSourceGenerationOptionsAttribute`. Here is an example using `JsonKnownReferenceHandler.Preserve`: +When using source generators for JSON serialization, the generated context will throw when cycles are serialized or deserialized. This behavior can now be customized by specifying the in the . Here is an example using `JsonKnownReferenceHandler.Preserve`: -```cs +```csharp SelfReference selfRef = new SelfReference(); selfRef.Me = selfRef; @@ -256,12 +252,12 @@ internal class SelfReference ## More left-handed matrix transformation methods -The remaining APIs for creating left-handed tranformation matrices have been added for billboard and constrained billboard matrices. These can be used like their existing right-handed counterparts when using a left-handed coordinate system instead. +.NET 10 adds the remaining APIs for creating left-handed transformation matrices for billboard and constrained-billboard matrices. You can use these methods like their existing right-handed counterparts [add xrefs to the existing counterparts] when using a left-handed coordinate system instead. ```cs public partial struct Matrix4x4 { public static Matrix4x4 CreateBillboardLeftHanded(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3 cameraForwardVector) - public static Matrix4x4 CreateConstrainedBillboardLeftHanded(Vector3 objectPosition, Vector3 cameraPosition, Vector3 rotateAxis, Vector3 cameraForwardVector, Vector3 objectForwardVector) +## More left-handed matrix transformation methods } ``` diff --git a/docs/core/whats-new/snippets/dotnet-10/csharp/Program.cs b/docs/core/whats-new/snippets/dotnet-10/csharp/Program.cs new file mode 100644 index 0000000000000..3751555cbd32d --- /dev/null +++ b/docs/core/whats-new/snippets/dotnet-10/csharp/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/docs/core/whats-new/snippets/dotnet-10/csharp/Project.csproj b/docs/core/whats-new/snippets/dotnet-10/csharp/Project.csproj new file mode 100644 index 0000000000000..0b8f8f2bda02b --- /dev/null +++ b/docs/core/whats-new/snippets/dotnet-10/csharp/Project.csproj @@ -0,0 +1,11 @@ + + + + Exe + net10.0 + enable + enable + preview + + + diff --git a/docs/whats-new/toc.yml b/docs/whats-new/toc.yml index bade277f0f552..cfdf0b940c472 100644 --- a/docs/whats-new/toc.yml +++ b/docs/whats-new/toc.yml @@ -20,11 +20,9 @@ items: - name: .NET 10 href: ../core/whats-new/dotnet-10/overview.md?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json - name: ASP.NET Core 10.0 - href: /aspnet/core/release-notes?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json - - name: .NET MAUI 10 - href: /dotnet/maui/whats-new?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json + href: /aspnet/core/release-notes/aspnetcore-10.0?view=aspnetcore-9.0?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json - name: EF Core 10 - href: /ef/core/what-is-new?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json + href: /ef/core/what-is-new/ef-core-10.0/whatsnew?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json - name: .NET 9 items: - name: .NET 9 From 8e45999dd718fc9c92e2e792c4fa9f45fd492063 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Wed, 19 Feb 2025 17:49:30 -0600 Subject: [PATCH 14/24] Apply suggestions from code review Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- docs/core/whats-new/dotnet-10/runtime.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/core/whats-new/dotnet-10/runtime.md b/docs/core/whats-new/dotnet-10/runtime.md index 5faf1cd98a632..240ca3849ad3c 100644 --- a/docs/core/whats-new/dotnet-10/runtime.md +++ b/docs/core/whats-new/dotnet-10/runtime.md @@ -71,8 +71,6 @@ static void Sum() Because the JIT knows `numbers` is an array of only three integers at compile time, and it doesn't outlive a call to `Sum`, it allocates it on the stack. -Among other [stack allocation enhancements](https://github.com/dotnet/runtime/issues/104936), we plan to expand this ability to arrays of reference types in the coming previews. - ## AVX10.2 support .NET 10 introduces support for the Advanced Vector Extensions (AVX) 10.2 for x64-based processors. The new intrinsics available in the `System.Runtime.Intrinsics.X86.Avx10v2` class can be tested once capable hardware is available. From 12d7270736ec32e5bb873b0bf201d297c8f8df6e Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Wed, 19 Feb 2025 23:59:18 +0000 Subject: [PATCH 15/24] updates --- docs/core/whats-new/dotnet-10/libraries.md | 91 +++------------------- 1 file changed, 9 insertions(+), 82 deletions(-) diff --git a/docs/core/whats-new/dotnet-10/libraries.md b/docs/core/whats-new/dotnet-10/libraries.md index 00b508554758a..8b8865e98c79e 100644 --- a/docs/core/whats-new/dotnet-10/libraries.md +++ b/docs/core/whats-new/dotnet-10/libraries.md @@ -118,88 +118,15 @@ public readonly struct TimeSpan ## ZipArchive performance and memory improvements -Two significant PRs have been made by contributor @edwardneal in .NET 10 Preview 1 to improve the performance and memory usage of `ZipArchive`: - -- [dotnet/runtime #102704](https://github.com/dotnet/runtime/pull/102704) optimizes the way entries are written to a `ZipArchive` when in `Update` mode. Previously, all `ZipArchiveEntries` would be loaded into memory and rewritten, which could lead to high memory usage and performance bottlenecks. The optimization reduces memory usage and improves performance by avoiding the need to load all entries into memory. - -Adding a 2GB zip file to an existing archive showed: - -First, the way entries are written to a `ZipArchive` when in `Update` mode has been optimized. Previously, all instances were loaded into memory and rewritten, which could lead to high memory usage and performance bottlenecks. The optimization reduces memory usage and improves performance by avoiding the need to load all entries into memory. -- A 99.9996% reduction in memory usage. - -### Benchmarks: - -| Method | Job | Runtime | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Gen2 | Allocated | Alloc Ratio | -|-----------|----------|-----------|---------:|-----------:|------------:|------:|--------:|----------:|----------:|----------:|----------:|------------:| -| Benchmark | Baseline | .NET 9.0 | 4.187 s | 83.3751 ms | 177.6792 ms | 1.002 | 0.06 | 1000.0000 | 1000.0000 | 1000.0000 | 2 GB | 1.000 | -| Benchmark | CoreRun | .NET 10.0 | 9.452 ms | 0.1583 ms | 0.1322 ms | 0.002 | 0.00 | - | - | - | 7.01 KB | 0.000 | - -Additional details are provided in [dotnet/runtime #102704](https://github.com/dotnet/runtime/pull/102704#issue-2317941700). - -- [dotnet/runtime #103153](https://github.com/dotnet/runtime/pull/103153) enhances the performance of `ZipArchive` by parallelizing the extraction of entries and optimizing internal data structures for better memory usage. These improvements address issues related to performance bottlenecks and high memory usage, making `ZipArchive` more efficient and faster, especially when dealing with large archives. - -Reading a zip archive showed: - -- An 18% reduction in execution time. -- An 18% reduction in memory usage. - -### Benchmarks: - -| Method | Job | Runtime | NumberOfFiles | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Gen2 | Allocated | Alloc Ratio | -|-----------|----------|-----------|---------------|----------------:|--------------:|--------------:|------:|--------:|----------:|---------:|---------:|-----------:|------------:| -| Benchmark | Baseline | .NET 9.0 | 2 | 1,178.6 ns | 23.23 ns | 22.81 ns | 1.00 | 0.03 | 0.3700 | - | - | 1.52 KB | 1.00 | -| Benchmark | CoreRun | .NET 10.0 | 2 | 821.6 ns | 12.45 ns | 11.65 ns | 0.70 | 0.02 | 0.2899 | - | - | 1.19 KB | 0.78 | -| | | | | | | | | | | | | | | -| Benchmark | Baseline | .NET 9.0 | 10 | 4,205.5 ns | 62.41 ns | 55.33 ns | 1.00 | 0.02 | 1.4954 | - | - | 6.13 KB | 1.00 | -| Benchmark | CoreRun | .NET 10.0 | 10 | 3,467.5 ns | 67.25 ns | 66.05 ns | 0.82 | 0.02 | 1.2054 | - | - | 4.93 KB | 0.80 | -| | | | | | | | | | | | | | | -| Benchmark | Baseline | .NET 9.0 | 25 | 10,201.5 ns | 190.59 ns | 187.18 ns | 1.00 | 0.02 | 3.5095 | - | - | 14.38 KB | 1.00 | -| Benchmark | CoreRun | .NET 10.0 | 25 | 8,210.2 ns | 152.35 ns | 142.51 ns | 0.81 | 0.02 | 2.8229 | - | - | 11.54 KB | 0.80 | -| | | | | | | | | | | | | | | -| Benchmark | Baseline | .NET 9.0 | 50 | 20,152.7 ns | 333.29 ns | 311.76 ns | 1.00 | 0.02 | 7.0496 | - | - | 28.91 KB | 1.00 | -| Benchmark | CoreRun | .NET 10.0 | 50 | 20,109.1 ns | 517.18 ns | 1,500.43 ns | 1.00 | 0.08 | 5.7068 | - | - | 23.34 KB | 0.81 | -| | | | | | | | | | | | | | | -| Benchmark | Baseline | .NET 9.0 | 100 | 46,986.2 ns | 923.08 ns | 1,906.33 ns | 1.00 | 0.06 | 14.2822 | 0.1221 | - | 58.42 KB | 1.00 | -| Benchmark | CoreRun | .NET 10.0 | 100 | 37,767.2 ns | 752.51 ns | 1,554.06 ns | 0.81 | 0.05 | 11.5967 | 0.0610 | - | 47.38 KB | 0.81 | -| | | | | | | | | | | | | | | -| Benchmark | Baseline | .NET 9.0 | 250 | 115,159.8 ns | 2,211.52 ns | 2,271.07 ns | 1.00 | 0.03 | 34.5459 | 0.1221 | - | 141.42 KB | 1.00 | -| Benchmark | CoreRun | .NET 10.0 | 250 | 94,148.7 ns | 1,842.33 ns | 3,414.87 ns | 0.82 | 0.03 | 27.8320 | 0.3662 | - | 113.97 KB | 0.81 | -| | | | | | | | | | | | | | | -| Benchmark | Baseline | .NET 9.0 | 500 | 241,338.5 ns | 4,726.33 ns | 7,896.64 ns | 1.00 | 0.05 | 69.8242 | 0.4883 | - | 285.86 KB | 1.00 | -| Benchmark | CoreRun | .NET 10.0 | 500 | 184,869.9 ns | 2,969.04 ns | 4,162.18 ns | 0.77 | 0.03 | 56.1523 | 0.7324 | - | 231.06 KB | 0.81 | -| | | | | | | | | | | | | | | -| Benchmark | Baseline | .NET 9.0 | 1000 | 510,114.6 ns | 10,092.12 ns | 20,386.57 ns | 1.00 | 0.05 | 114.2578 | 72.2656 | - | 577.2 KB | 1.00 | -| Benchmark | CoreRun | .NET 10.0 | 1000 | 404,349.3 ns | 7,289.88 ns | 16,153.88 ns | 0.79 | 0.04 | 93.2617 | 52.7344 | - | 467.72 KB | 0.81 | -| | | | | | | | | | | | | | | -| Benchmark | Baseline | .NET 9.0 | 10000 | 13,950,239.9 ns | 273,372.39 ns | 345,728.57 ns | 1.00 | 0.03 | 1000.0000 | 687.5000 | 218.7500 | 5786.24 KB | 1.00 | -| Benchmark | CoreRun | .NET 10.0 | 10000 | 10,911,298.0 ns | 204,013.47 ns | 226,760.43 ns | 0.78 | 0.02 | 843.7500 | 609.3750 | 250.0000 | 4692.19 KB | 0.81 | - -Creating an archive showed: - -- A 23-35% reduction in execution time. -- A 2% reduction in memory usage. - -Benchmarks: - -| Method | Job | Runtime | NumberOfFiles | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen0 | Gen1 | Allocated | Alloc Ratio | -|-----------|----------|-----------|---------------|----------:|----------:|-----------:|----------:|------:|--------:|--------:|--------:|----------:|------------:| -| Benchmark | Baseline | .NET 9.0 | 2 | 2.729 μs | 0.0538 μs | 0.0449 μs | 2.706 μs | 1.00 | 0.02 | 2.2697 | - | 9.28 KB | 1.00 | -| Benchmark | CoreRun | .NET 10.0 | 2 | 1.665 μs | 0.0256 μs | 0.0239 μs | 1.659 μs | 0.61 | 0.01 | 2.2259 | - | 9.1 KB | 0.98 | -| | | | | | | | | | | | | | | -| Benchmark | Baseline | .NET 9.0 | 10 | 10.341 μs | 0.1988 μs | 0.2289 μs | 10.266 μs | 1.00 | 0.03 | 9.7046 | - | 39.76 KB | 1.00 | -| Benchmark | CoreRun | .NET 10.0 | 10 | 7.937 μs | 0.1514 μs | 0.2487 μs | 7.831 μs | 0.77 | 0.03 | 9.5215 | - | 39.02 KB | 0.98 | -| | | | | | | | | | | | | | | -| Benchmark | Baseline | .NET 9.0 | 25 | 24.677 μs | 0.4903 μs | 0.8842 μs | 24.563 μs | 1.00 | 0.05 | 20.1721 | 3.3569 | 82.92 KB | 1.00 | -| Benchmark | CoreRun | .NET 10.0 | 25 | 18.247 μs | 0.3474 μs | 0.3412 μs | 18.192 μs | 0.74 | 0.03 | 19.7754 | 3.2654 | 81.13 KB | 0.98 | -| | | | | | | | | | | | | | | -| Benchmark | Baseline | .NET 9.0 | 50 | 67.420 μs | 5.7447 μs | 16.9384 μs | 57.185 μs | 1.05 | 0.35 | 40.5273 | 13.4888 | 166.71 KB | 1.00 | -| Benchmark | CoreRun | .NET 10.0 | 50 | 41.443 μs | 0.7212 μs | 0.8306 μs | 41.493 μs | 0.65 | 0.13 | 39.6729 | 0.0610 | 163.16 KB | 0.98 | - -Additional benchmarking details provided [in the PR description](https://github.com/dotnet/runtime/pull/103153#issue-2339713028). +.NET 10 improves the performance and memory usage of . + +First, the way entries are written to a `ZipArchive` when in `Update` mode has been optimized. Previously, all instances were loaded into memory and rewritten, which could lead to high memory usage and performance bottlenecks. The optimization reduces memory usage and improves performance by avoiding the need to load all entries into memory. Details are provided in [dotnet/runtime #102704](https://github.com/dotnet/runtime/pull/102704#issue-2317941700). + +Second, the extraction of entries is now parallelized, and internal data structures are optimized for better memory usage. These improvements address issues related to performance bottlenecks and high memory usage, making `ZipArchive` more efficient and faster, especially when dealing with large archives. Details are provided [dotnet/runtime #103153](https://github.com/dotnet/runtime/pull/103153#issue-2339713028). ## Additional `TryAdd` and `TryGetValue` overloads for `OrderedDictionary` -`OrderedDictionary` provides `TryAdd` and `TryGetValue` for addition and retrieval like any other `IDictionary` implementation. However, there are scenarios where you might want to perform additional operations, so new overloads have been added that return an index to the entry: + provides `TryAdd` and `TryGetValue` for addition and retrieval like any other `IDictionary` implementation. However, there are scenarios where you might want to perform additional operations, so new overloads have been added that return an index to the entry: ```csharp public class OrderedDictionary @@ -212,7 +139,7 @@ public class OrderedDictionary This index can then be used with / for fast access to the entry. An example usage of the new `TryAdd` overload is to add or update a key/value pair in the ordered dictionary: -```cs +```csharp public static void IncrementValue(OrderedDictionary orderedDictionary, string key) { // Try to add a new key with value 1. @@ -225,7 +152,7 @@ public static void IncrementValue(OrderedDictionary orderedDictiona } ``` -This new API is now being used in `JsonObject` to improve the performance of updating properties by 10-20%. +This new API is already used in and improves the performance of updating properties by 10-20%. ## Allow specifying ReferenceHandler in `JsonSourceGenerationOptions` @@ -254,7 +181,7 @@ internal class SelfReference .NET 10 adds the remaining APIs for creating left-handed transformation matrices for billboard and constrained-billboard matrices. You can use these methods like their existing right-handed counterparts [add xrefs to the existing counterparts] when using a left-handed coordinate system instead. -```cs +```csharp public partial struct Matrix4x4 { public static Matrix4x4 CreateBillboardLeftHanded(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3 cameraForwardVector) From 0ae965a24ea3f3fb4e39e29d67576a7116790293 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Thu, 20 Feb 2025 00:01:59 +0000 Subject: [PATCH 16/24] Remove snippets for now --- .../whats-new/snippets/dotnet-10/csharp/Program.cs | 2 -- .../snippets/dotnet-10/csharp/Project.csproj | 11 ----------- 2 files changed, 13 deletions(-) delete mode 100644 docs/core/whats-new/snippets/dotnet-10/csharp/Program.cs delete mode 100644 docs/core/whats-new/snippets/dotnet-10/csharp/Project.csproj diff --git a/docs/core/whats-new/snippets/dotnet-10/csharp/Program.cs b/docs/core/whats-new/snippets/dotnet-10/csharp/Program.cs deleted file mode 100644 index 3751555cbd32d..0000000000000 --- a/docs/core/whats-new/snippets/dotnet-10/csharp/Program.cs +++ /dev/null @@ -1,2 +0,0 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); diff --git a/docs/core/whats-new/snippets/dotnet-10/csharp/Project.csproj b/docs/core/whats-new/snippets/dotnet-10/csharp/Project.csproj deleted file mode 100644 index 0b8f8f2bda02b..0000000000000 --- a/docs/core/whats-new/snippets/dotnet-10/csharp/Project.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net10.0 - enable - enable - preview - - - From 009a29aaba8b7aeef1286c6e09b5089da49de271 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Thu, 20 Feb 2025 00:28:55 +0000 Subject: [PATCH 17/24] Overview updates --- docs/core/whats-new/dotnet-10/overview.md | 66 +++++++++++------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/docs/core/whats-new/dotnet-10/overview.md b/docs/core/whats-new/dotnet-10/overview.md index 3003acd5392c6..97d69fb047e7c 100644 --- a/docs/core/whats-new/dotnet-10/overview.md +++ b/docs/core/whats-new/dotnet-10/overview.md @@ -12,29 +12,24 @@ Learn about the new features in .NET 10 and find links to further documentation. ## .NET runtime -- [Array interface method devirtualization](runtime.md#array-interface-method-devirtualization) -- [Stack allocation of arrays of value types](runtime.md#stack-allocation-of-arrays-of-value-types) -- [AVX10.2 support](runtime.md#avx102-support) +.NET 10, the successor to [.NET 9](../dotnet-9/overview.md), has a special focus on cloud-native apps and performance. It will be [supported for 3 years](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) as a long-term support (LTS) release. You can [download .NET 10 here](https://dotnet.microsoft.com/download/dotnet/10.0). + +Your feedback is important and appreciated. We've created a discussion on [GitHub](https://github.com/dotnet/core/discussions/categories/news) for your questions and comments. For more information, see [What's new in the .NET 10 runtime](runtime.md). ## .NET libraries -- [Finding certificates by thumbprints other than SHA-1](libraries.md#finding-certificates-by-thumbprints-other-than-sha-1) -- [Finding PEM-encoded data in ASCII/UTF-8](libraries.md#finding-pem-encoded-data-in-asciiutf-8) -- [New method overloads in ISOWeek for DateOnly type](libraries.md#new-method-overloads-in-isoweek-for-dateonly-type) -- [String normalization APIs to work with span of characters](libraries.md#string-normalization-apis-to-work-with-span-of-characters) -- [Numeric ordering for string comparison](libraries.md#numeric-ordering-for-string-comparison) -- [Adding TimeSpan.FromMilliseconds overload with a single parameter](libraries.md#adding-timespanfrommilliseconds-overload-with-a-single-parameter) -- [ZipArchive performance and memory improvements](libraries.md#ziparchive-performance-and-memory-improvements) -- [Additional TryAdd and TryGetValue overloads for OrderedDictionary](libraries.md#additional-tryadd-and-trygetvalue-overloads-for-ordereddictionarytkey-tvalue) -- [Allow specifying ReferenceHandler in JsonSourceGenerationOptions](libraries.md#allow-specifying-referencehandler-in-jsonsourcegenerationoptions) -- [More left-handed matrix transformation methods](libraries.md#more-left-handed-matrix-transformation-methods) +The .NET 10 libraries introduce several new features and improvements. A new method `FindByThumbprint` allows finding certificates by thumbprints using hash algorithms other than SHA-1. Additionally, support has been added for reading PEM-encoded data directly from ASCII encoded files. The class now includes new method overloads to support the type. Unicode string normalization APIs have been enhanced to work with spans of characters, and a new `CompareOptions.NumericOrdering` option has been introduced for numerical string comparison. + +Additionally, a new overload that takes a single parameter has been added. The performance and memory usage of [ZipArchive](xref:System.IO.Compression.ZipArchive) have been improved. New `TryAdd` and `TryGetValue` overloads for now return an index to the entry. JSON serialization has been enhanced by allowing the specification of in . Lastly, new APIs have been introduced for creating left-handed transformation matrices for billboard and constrained-billboard matrices. For more information, see [What's new in the .NET 10 libraries](libraries.md). ## .NET SDK +The .NET 10 SDK introduces following new features and enhancements: + - [Pruning of Framework-provided Package References](sdk.md#pruning-of-framework-provided-package-references) For more information, see [What's new in the SDK for .NET 10](sdk.md). @@ -45,44 +40,49 @@ For more information, see [What's new in the SDK for .NET 10](sdk.md). ## ASP.NET Core -- [OpenAPI 3.1 support](/aspnet/core/release-notes/aspnetcore-10.0#openapi-31-support) -- [Generate OpenAPI documents in YAML format](/aspnet/core/release-notes/aspnetcore-10.0?view=aspnetcore-9.0#openapi-in-yaml) -- [Response description on `ProducesResponseType`](/aspnet/core/release-notes/aspnetcore-10.0#response-description-on-producesresponsetype) -- [Detect if URL is local using `RedirectHttpResult.IsLocalUrl`](/aspnet/core/release-notes/aspnetcore-10.0#detect-if-url-is-local-using-redirecthttpresultislocalurl) -- [Improvements to integration testing of apps with top-level statements](/aspnet/core/release-notes/aspnetcore-10.0?view=aspnetcore-9.0#better-support-for-testing-apps-with-top-level-statements) -- [QuickGrid `RowClass` parameter](/aspnet/core/release-notes/aspnetcore-10.0#quickgrid-rowclass-parameter) -- [Blazor script as a static web asset](/aspnet/core/release-notes/aspnetcore-10.0?view=aspnetcore-9.0#blazor-script) -- [Route syntax highlighting for Blazor `RouteAttribute`](/aspnet/core/release-notes/aspnetcore-10.0#route-syntax-highlighting-for-blazor-routeattribute) +Changes in ASP.NET Core 10.0 include: + +- Blazor: Added new features for Blazor, including the QuickGrid RowClass parameter and Blazor script serving as a static web asset. +- SignalR: Added new features for SignalR. +- Minimal APIs: Added new features for minimal APIs. +- OpenAPI: Added support for generating OpenAPI version 3.1 documents and serving the generated OpenAPI document in YAML format. +- Authentication and authorization: Added new features for authentication and authorization. +- Miscellaneous: Added better support for testing apps with top-level statements and a new helper method for detecting local URLs. For more information, see [What's new in ASP.NET Core for .NET 10](/aspnet/core/release-notes/aspnetcore-10.0). ## .NET MAUI -TODO - Add a brief overview of the new features in .NET MAUI for .NET 10. + ## EF Core -- [Support for the .NET 10 LeftJoin operator](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/efcore.md#support-for-the-net-10-leftjoin-operator) -- [ExecuteUpdateAsync now accepts a regular, non-expression lambda](/ef/core/what-is-new/ef-core-10.0/whatsnew#executeupdateasync-now-accepts-a-regular-non-expression-lambda) -- [Several small improvements](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/efcore.md#small-improvements) +Changes for EF Core 10 include: + +- LINQ and SQL translation enhancements. +- ExecuteUpdateAsync now accepts a regular, non-expression lambda. For more information, see [What's new in EF Core for .NET 10](/ef/core/what-is-new/ef-core-10.0/whatsnew). ## C# 14 -- [`nameof` in unbound generics](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/csharp.md#unbound-generic-support-for-nameof) -- [Implicit span conversions](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/csharp.md#implicit-span-conversions) -- [`field` backed properties](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/csharp.md#field-backed-properties) -- [Modifiers on simple lambda parameters](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/csharp.md#modifiers-on-simple-lambda-parameters) -- [Experimental feature - String literals in data section](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/csharp.md#preview-feature-string-literals-in-data-section) +C# 14 introduces several new features and enhancements to improve developer productivity and code quality. Some of the key updates include: + +- `nameof` in unbound generics. +- Implicit span conversions. +- `field` backed properties. +- Modifiers on simple lambda parameters. +- Experimental feature - String literals in data section. For more information, see [What's new in C# 14](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/csharp.md). ## Windows Forms -- [Clipboard related serialization and deserialization changes](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/winforms.md#clipboard-related-serialization-and-deserialization-changes) -- [Obsoleted Clipboard APIs](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/winforms.md#obsoleted-clipboard-apis) -- [New Clipboard related APIs](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/winforms.md#new-clipboard-related-apis) +Changes in Windows Forms for .NET 10 include: + +- Clipboard related serialization and deserialization changes. +- Obsoleted Clipboard APIs. +- New Clipboard related APIs. For more information, see [What's new in Windows Forms for .NET 10](https://github.com/dotnet/core/blob/dotnet10p1/release-notes/10.0/preview/preview1/winforms.md). From eb14355226153b2ced63b4be44cb68666fb25660 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Thu, 20 Feb 2025 00:31:09 +0000 Subject: [PATCH 18/24] Copilot broke my lint --- docs/core/whats-new/dotnet-10/overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/whats-new/dotnet-10/overview.md b/docs/core/whats-new/dotnet-10/overview.md index 97d69fb047e7c..98801e266893d 100644 --- a/docs/core/whats-new/dotnet-10/overview.md +++ b/docs/core/whats-new/dotnet-10/overview.md @@ -40,7 +40,7 @@ For more information, see [What's new in the SDK for .NET 10](sdk.md). ## ASP.NET Core -Changes in ASP.NET Core 10.0 include: +Changes in ASP.NET Core 10.0 include: - Blazor: Added new features for Blazor, including the QuickGrid RowClass parameter and Blazor script serving as a static web asset. - SignalR: Added new features for SignalR. From 44460533f802a009efff1c8247f8406d3d7bf4d8 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Thu, 20 Feb 2025 00:33:33 +0000 Subject: [PATCH 19/24] fix warning --- docs/core/whats-new/dotnet-10/runtime.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/whats-new/dotnet-10/runtime.md b/docs/core/whats-new/dotnet-10/runtime.md index 240ca3849ad3c..04ba553e9f6ed 100644 --- a/docs/core/whats-new/dotnet-10/runtime.md +++ b/docs/core/whats-new/dotnet-10/runtime.md @@ -27,7 +27,7 @@ static int Sum(int[] array) } ``` -This code shape is easy for the JIT to optimize, mainly because there aren't any virtual calls to reason about. Instead, the JIT can focus on removing bounds checks on the array access and applying the [loop optimizations that were added in .NET 9](../add/link/to/file/here.md#heading). The following example adds some virtual calls: +This code shape is easy for the JIT to optimize, mainly because there aren't any virtual calls to reason about. Instead, the JIT can focus on removing bounds checks on the array access and applying the [loop optimizations that were added in .NET 9](https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-9/). The following example adds some virtual calls: ```csharp static int Sum(int[] array) From 3b478fd046789169876c4560fd3c21d7f872addc Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Thu, 20 Feb 2025 00:35:29 +0000 Subject: [PATCH 20/24] download link --- docs/core/whats-new/dotnet-10/overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/whats-new/dotnet-10/overview.md b/docs/core/whats-new/dotnet-10/overview.md index 98801e266893d..51a2cfe3a024b 100644 --- a/docs/core/whats-new/dotnet-10/overview.md +++ b/docs/core/whats-new/dotnet-10/overview.md @@ -12,7 +12,7 @@ Learn about the new features in .NET 10 and find links to further documentation. ## .NET runtime -.NET 10, the successor to [.NET 9](../dotnet-9/overview.md), has a special focus on cloud-native apps and performance. It will be [supported for 3 years](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) as a long-term support (LTS) release. You can [download .NET 10 here](https://dotnet.microsoft.com/download/dotnet/10.0). +.NET 10, the successor to [.NET 9](../dotnet-9/overview.md), has a special focus on cloud-native apps and performance. It will be [supported for 3 years](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) as a long-term support (LTS) release. You can [download .NET 10 here](https://get.dot.net/10). Your feedback is important and appreciated. We've created a discussion on [GitHub](https://github.com/dotnet/core/discussions/categories/news) for your questions and comments. From 8cf37c924ff5ce212a480796f4e05eb7809d8b06 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Thu, 20 Feb 2025 01:23:25 +0000 Subject: [PATCH 21/24] metadata --- docs/core/whats-new/dotnet-10/libraries.md | 9 +++++---- docs/core/whats-new/dotnet-10/overview.md | 1 + docs/core/whats-new/dotnet-10/runtime.md | 1 + docs/core/whats-new/dotnet-10/sdk.md | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/core/whats-new/dotnet-10/libraries.md b/docs/core/whats-new/dotnet-10/libraries.md index 8b8865e98c79e..586e27b0d9651 100644 --- a/docs/core/whats-new/dotnet-10/libraries.md +++ b/docs/core/whats-new/dotnet-10/libraries.md @@ -4,6 +4,7 @@ description: Learn about the new .NET libraries features introduced in .NET 10. titleSuffix: "" ms.date: 02/20/2025 ms.topic: whats-new +ai-usage: ai-assisted --- # What's new in .NET libraries for .NET 10 @@ -18,7 +19,7 @@ Since SHA-2-256 ("SHA256") and SHA-3-256 have the same lengths, it doesn't make Instead, .NET 10 introduces a new method that accepts the name of the hash algorithm to use for matching. -```C# +```csharp X509Certificate2Collection coll = store.Certificates.FindByThumbprint(HashAlgorithmName.SHA256, thumbprint); Debug.Assert(coll.Count < 2, "Collection has too many matches, has SHA-2 been broken?"); return coll.SingleOrDefault(); @@ -44,7 +45,7 @@ byte[] fileContents = File.ReadAllBytes(path); The class was originally designed to work exclusively with , as it was introduced before the type existed. Now that `DateOnly` is available, it makes sense for `ISOWeek` to support it as well. -```C# +```csharp public static class ISOWeek { // New overloads @@ -60,7 +61,7 @@ Unicode string normalization has been supported for a long time, but existing AP .NET 10 introduces new APIs that work with spans of characters, expanding normalization beyond string types and helping to avoid unnecessary allocations. -```C# +```csharp public static class StringNormalizationExtensions { public static int GetNormalizedLength(this ReadOnlySpan source, NormalizationForm normalizationForm = NormalizationForm.FormC); @@ -73,7 +74,7 @@ Unicode string normalization has been supported for a long time, but existing AP Numerical string comparison is a highly requested feature for comparing strings numerically instead of lexicographically. For example, `2` is less than `10`, so `"2"` should appear before `"10"` when ordered numerically. Similarly, `"2"` and `"02"` are equal numerically. With the new `CompareOptions.NumericOrdering` option, it's now possible to do these types of comparisons: -```cs +```csharp StringComparer numericStringComparer = StringComparer.Create(CultureInfo.CurrentCulture, CompareOptions.NumericOrdering); Console.WriteLine(numericStringComparer.Equals("02", "2")); diff --git a/docs/core/whats-new/dotnet-10/overview.md b/docs/core/whats-new/dotnet-10/overview.md index 51a2cfe3a024b..ed08a91116bc0 100644 --- a/docs/core/whats-new/dotnet-10/overview.md +++ b/docs/core/whats-new/dotnet-10/overview.md @@ -4,6 +4,7 @@ description: Learn about the new features introduced in .NET 10 for the runtime, titleSuffix: "" ms.date: 02/20/2025 ms.topic: whats-new +ai-usage: ai-assisted --- # What's new in .NET 10 diff --git a/docs/core/whats-new/dotnet-10/runtime.md b/docs/core/whats-new/dotnet-10/runtime.md index 04ba553e9f6ed..c3c302ff9215f 100644 --- a/docs/core/whats-new/dotnet-10/runtime.md +++ b/docs/core/whats-new/dotnet-10/runtime.md @@ -4,6 +4,7 @@ description: Learn about the new .NET features introduced in the .NET 10 runtime titleSuffix: "" ms.date: 02/20/2025 ms.topic: whats-new +ai-usage: ai-assisted --- # What's new in the .NET 10 runtime diff --git a/docs/core/whats-new/dotnet-10/sdk.md b/docs/core/whats-new/dotnet-10/sdk.md index e3601c55dc66f..0d9366a5ad9c5 100644 --- a/docs/core/whats-new/dotnet-10/sdk.md +++ b/docs/core/whats-new/dotnet-10/sdk.md @@ -4,6 +4,7 @@ description: Learn about the new .NET SDK features introduced in .NET 10. titleSuffix: "" ms.date: 02/20/2025 ms.topic: whats-new +ai-usage: ai-assisted --- # What's new in the SDK and tooling for .NET 10 From 9d49cc2719041ca146b2b860cdc673fb75b50ea2 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Thu, 20 Feb 2025 01:58:18 +0000 Subject: [PATCH 22/24] Added project --- docs/core/whats-new/dotnet-10/libraries.md | 79 ++++--------------- .../snippets/dotnet-10/csharp/Program.cs | 2 + .../snippets/dotnet-10/csharp/Project.csproj | 10 +++ .../snippets/dotnet-10/csharp/snippets.cs | 68 ++++++++++++++++ 4 files changed, 96 insertions(+), 63 deletions(-) create mode 100644 docs/core/whats-new/snippets/dotnet-10/csharp/Program.cs create mode 100644 docs/core/whats-new/snippets/dotnet-10/csharp/Project.csproj create mode 100644 docs/core/whats-new/snippets/dotnet-10/csharp/snippets.cs diff --git a/docs/core/whats-new/dotnet-10/libraries.md b/docs/core/whats-new/dotnet-10/libraries.md index 586e27b0d9651..4f4c879fa839f 100644 --- a/docs/core/whats-new/dotnet-10/libraries.md +++ b/docs/core/whats-new/dotnet-10/libraries.md @@ -46,13 +46,13 @@ byte[] fileContents = File.ReadAllBytes(path); The class was originally designed to work exclusively with , as it was introduced before the type existed. Now that `DateOnly` is available, it makes sense for `ISOWeek` to support it as well. ```csharp - public static class ISOWeek - { - // New overloads - public static int GetWeekOfYear(DateOnly date); - public static int GetYear(DateOnly date); - public static DateOnly ToDateOnly(int year, int week, DayOfWeek dayOfWeek); - } +public static class ISOWeek +{ + // New overloads + public static int GetWeekOfYear(DateOnly date); + public static int GetYear(DateOnly date); + public static DateOnly ToDateOnly(int year, int week, DayOfWeek dayOfWeek); +} ``` ## String normalization APIs to work with span of characters @@ -62,38 +62,19 @@ Unicode string normalization has been supported for a long time, but existing AP .NET 10 introduces new APIs that work with spans of characters, expanding normalization beyond string types and helping to avoid unnecessary allocations. ```csharp - public static class StringNormalizationExtensions - { - public static int GetNormalizedLength(this ReadOnlySpan source, NormalizationForm normalizationForm = NormalizationForm.FormC); - public static bool IsNormalized(this ReadOnlySpan source, NormalizationForm normalizationForm = NormalizationForm.FormC); - public static bool TryNormalize(this ReadOnlySpan source, Span destination, out int charsWritten, NormalizationForm normalizationForm = NormalizationForm.FormC); - } +public static class StringNormalizationExtensions +{ + public static int GetNormalizedLength(this ReadOnlySpan source, NormalizationForm normalizationForm = NormalizationForm.FormC); + public static bool IsNormalized(this ReadOnlySpan source, NormalizationForm normalizationForm = NormalizationForm.FormC); + public static bool TryNormalize(this ReadOnlySpan source, Span destination, out int charsWritten, NormalizationForm normalizationForm = NormalizationForm.FormC); +} ``` ## Numeric ordering for string comparison Numerical string comparison is a highly requested feature for comparing strings numerically instead of lexicographically. For example, `2` is less than `10`, so `"2"` should appear before `"10"` when ordered numerically. Similarly, `"2"` and `"02"` are equal numerically. With the new `CompareOptions.NumericOrdering` option, it's now possible to do these types of comparisons: -```csharp -StringComparer numericStringComparer = StringComparer.Create(CultureInfo.CurrentCulture, CompareOptions.NumericOrdering); - -Console.WriteLine(numericStringComparer.Equals("02", "2")); -// Output: True - -foreach (string os in new[] { "Windows 8", "Windows 10", "Windows 11" }.Order(numericStringComparer)) -{ - Console.WriteLine(os); -} - -// Output: -// Windows 8 -// Windows 10 -// Windows 11 - -HashSet set = new HashSet(numericStringComparer) { "007" }; -Console.WriteLine(set.Contains("7")); -// Output: True -``` +:::code language="csharp" source="../snippets/dotnet-10/csharp/snippets.cs" id="snippet3"::: Note that this option is not valid for the following index-based string operations: `IndexOf`, `LastIndexOf`, `StartsWith`, `EndsWith`, `IsPrefix`, and `IsSuffix`. @@ -140,18 +121,7 @@ public class OrderedDictionary This index can then be used with / for fast access to the entry. An example usage of the new `TryAdd` overload is to add or update a key/value pair in the ordered dictionary: -```csharp -public static void IncrementValue(OrderedDictionary orderedDictionary, string key) -{ - // Try to add a new key with value 1. - if (!orderedDictionary.TryAdd(key, 1, out int index)) - { - // Key was present, so increment the existing value instead. - int value = orderedDictionary.GetAt(index).Value; - orderedDictionary.SetAt(index, value + 1); - } -} -``` +:::code language="csharp" source="../snippets/dotnet-10/csharp/snippets.cs" id="snippet2"::: This new API is already used in and improves the performance of updating properties by 10-20%. @@ -159,24 +129,7 @@ This new API is already used in and improves the p When using source generators for JSON serialization, the generated context will throw when cycles are serialized or deserialized. This behavior can now be customized by specifying the in the . Here is an example using `JsonKnownReferenceHandler.Preserve`: -```csharp -SelfReference selfRef = new SelfReference(); -selfRef.Me = selfRef; - -Console.WriteLine(JsonSerializer.Serialize(selfRef, ContextWithPreserveReference.Default.SelfReference)); -// Output: {"$id":"1","Me":{"$ref":"1"}} - -[JsonSourceGenerationOptions(ReferenceHandler = JsonKnownReferenceHandler.Preserve)] -[JsonSerializable(typeof(SelfReference))] -internal partial class ContextWithPreserveReference : JsonSerializerContext -{ -} - -internal class SelfReference -{ - public SelfReference Me { get; set; } -} -``` +:::code language="csharp" source="../snippets/dotnet-10/csharp/snippets.cs" id="snippet3"::: ## More left-handed matrix transformation methods diff --git a/docs/core/whats-new/snippets/dotnet-10/csharp/Program.cs b/docs/core/whats-new/snippets/dotnet-10/csharp/Program.cs new file mode 100644 index 0000000000000..3751555cbd32d --- /dev/null +++ b/docs/core/whats-new/snippets/dotnet-10/csharp/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/docs/core/whats-new/snippets/dotnet-10/csharp/Project.csproj b/docs/core/whats-new/snippets/dotnet-10/csharp/Project.csproj new file mode 100644 index 0000000000000..ed9781c223ab9 --- /dev/null +++ b/docs/core/whats-new/snippets/dotnet-10/csharp/Project.csproj @@ -0,0 +1,10 @@ + + + + Exe + net10.0 + enable + enable + + + diff --git a/docs/core/whats-new/snippets/dotnet-10/csharp/snippets.cs b/docs/core/whats-new/snippets/dotnet-10/csharp/snippets.cs new file mode 100644 index 0000000000000..03c7c60613cf3 --- /dev/null +++ b/docs/core/whats-new/snippets/dotnet-10/csharp/snippets.cs @@ -0,0 +1,68 @@ +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +public static class Snippets +{ + public static void NumericOrdering() + { + #region snippet1 + StringComparer numericStringComparer = StringComparer.Create(CultureInfo.CurrentCulture, CompareOptions.NumericOrdering); + + Console.WriteLine(numericStringComparer.Equals("02", "2")); + // Output: True + + foreach (string os in new[] { "Windows 8", "Windows 10", "Windows 11" }.Order(numericStringComparer)) + { + Console.WriteLine(os); + } + + // Output: + // Windows 8 + // Windows 10 + // Windows 11 + + HashSet set = new HashSet(numericStringComparer) { "007" }; + Console.WriteLine(set.Contains("7")); + // Output: True + #endregion + } + + public static void IncrementValue(OrderedDictionary orderedDictionary, string key) + { + #region snippet2 + // Try to add a new key with value 1. + if (!orderedDictionary.TryAdd(key, 1, out int index)) + { + // Key was present, so increment the existing value instead. + int value = orderedDictionary.GetAt(index).Value; + orderedDictionary.SetAt(index, value + 1); + } + #endregion + } +} + +public partial class SomeClass +{ + #region snippet3 + public static void MakeSelfRef() + { + SelfReference selfRef = new SelfReference(); + selfRef.Me = selfRef; + + Console.WriteLine(JsonSerializer.Serialize(selfRef, ContextWithPreserveReference.Default.SelfReference)); + // Output: {"$id":"1","Me":{"$ref":"1"}} + } + + [JsonSourceGenerationOptions(ReferenceHandler = JsonKnownReferenceHandler.Preserve)] + [JsonSerializable(typeof(SelfReference))] + internal partial class ContextWithPreserveReference : JsonSerializerContext + { + } + + internal class SelfReference + { + public SelfReference Me { get; set; } = null!; + } + #endregion +} From d8accaa2d7a7500c2a94ad7ebf0fa763ce758d65 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Thu, 20 Feb 2025 02:04:19 +0000 Subject: [PATCH 23/24] fix suggestion --- docs/whats-new/toc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/whats-new/toc.yml b/docs/whats-new/toc.yml index cfdf0b940c472..cef7d87a4e51f 100644 --- a/docs/whats-new/toc.yml +++ b/docs/whats-new/toc.yml @@ -20,7 +20,7 @@ items: - name: .NET 10 href: ../core/whats-new/dotnet-10/overview.md?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json - name: ASP.NET Core 10.0 - href: /aspnet/core/release-notes/aspnetcore-10.0?view=aspnetcore-9.0?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json + href: /aspnet/core/release-notes/aspnetcore-10.0?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json - name: EF Core 10 href: /ef/core/what-is-new/ef-core-10.0/whatsnew?toc=/dotnet/whats-new/toc.json&bc=/dotnet/breadcrumb/toc.json - name: .NET 9 From 8cc0248637911d30b80bb82b53180375b72ca082 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Thu, 20 Feb 2025 02:09:15 +0000 Subject: [PATCH 24/24] Aspire --- docs/core/whats-new/dotnet-10/overview.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/core/whats-new/dotnet-10/overview.md b/docs/core/whats-new/dotnet-10/overview.md index ed08a91116bc0..89339e62f62f2 100644 --- a/docs/core/whats-new/dotnet-10/overview.md +++ b/docs/core/whats-new/dotnet-10/overview.md @@ -37,7 +37,9 @@ For more information, see [What's new in the SDK for .NET 10](sdk.md). ## .NET Aspire - +.NET Aspire releases version 9.1, which focuses on quality of life fixes. + +For more information, see [.NET Aspire — what's new?](/dotnet/aspire/whats-new/). ## ASP.NET Core