Skip to content

Commit 5af705f

Browse files
CopilotBillWagner
andcommitted
Add Preview 6 content to .NET 10 what's new pages for libraries, runtime, and SDK
Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
1 parent cf785b3 commit 5af705f

File tree

3 files changed

+123
-1
lines changed

3 files changed

+123
-1
lines changed

docs/core/whats-new/dotnet-10/libraries.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ using (MLKem key = MLKem.GenerateKey(MLKemAlgorithm.MLKem768))
9595

9696
These algorithms all continue with the pattern of having a static `IsSupported` property to indicate if the algorithm is supported on the current system.
9797

98-
Currently, the PQC algorithms are only available on systems where the system cryptographic libraries are OpenSSL 3.5 (or newer). Windows CNG support will be added soon. Also, the new classes are all marked as [`[Experimental]`](../../../fundamentals/syslib-diagnostics/experimental-overview.md) under diagnostic `SYSLIB5006` until development is complete.
98+
.NET 10 includes Windows CNG support for post-quantum cryptography, making these algorithms available on Windows systems with PQC support. The PQC algorithms are available on systems where the system cryptographic libraries are OpenSSL 3.5 (or newer) or Windows CNG with PQC support. Also, the new classes are all marked as [`[Experimental]`](../../../fundamentals/syslib-diagnostics/experimental-overview.md) under diagnostic `SYSLIB5006` until development is complete.
9999

100100
## Globalization and date/time
101101

@@ -165,13 +165,49 @@ This new API is already used in <xref:System.Json.JsonObject> and improves the p
165165
## Serialization
166166

167167
- [Allow specifying ReferenceHandler in `JsonSourceGenerationOptions`](#allow-specifying-referencehandler-in-jsonsourcegenerationoptions)
168+
- [Option to disallow duplicate JSON properties](#option-to-disallow-duplicate-json-properties)
169+
- [Strict JSON serialization options](#strict-json-serialization-options)
168170

169171
### Allow specifying ReferenceHandler in `JsonSourceGenerationOptions`
170172

171173
When you use [source generators for JSON serialization](../../../standard/serialization/system-text-json/source-generation.md), the generated context throws when cycles are serialized or deserialized. Now you can customize this behavior by specifying the <xref:System.Text.Json.Serialization.ReferenceHandler> in the <xref:System.Text.Json.Serialization.JsonSourceGenerationOptionsAttribute>. Here's an example using `JsonKnownReferenceHandler.Preserve`:
172174

173175
:::code language="csharp" source="../snippets/dotnet-10/csharp/snippets.cs" id="snippet_selfReference":::
174176

177+
### Option to disallow duplicate JSON properties
178+
179+
The JSON specification doesn't specify how to handle duplicate properties when deserializing a JSON payload. This can lead to unexpected results and security vulnerabilities. .NET 10 introduces the `AllowDuplicateProperties` option to disallow duplicate JSON properties:
180+
181+
```csharp
182+
string json = """{ "Value": 1, "Value": -1 }""";
183+
Console.WriteLine(JsonSerializer.Deserialize<MyRecord>(json).Value); // -1
184+
185+
JsonSerializerOptions options = new() { AllowDuplicateProperties = false };
186+
JsonSerializer.Deserialize<MyRecord>(json, options); // throws JsonException
187+
JsonSerializer.Deserialize<JsonObject>(json, options); // throws JsonException
188+
JsonSerializer.Deserialize<Dictionary<string, int>>(json, options); // throws JsonException
189+
190+
JsonDocumentOptions docOptions = new() { AllowDuplicateProperties = false };
191+
JsonDocument.Parse(json, docOptions); // throws JsonException
192+
193+
record MyRecord(int Value);
194+
```
195+
196+
Duplicate detection works by checking if a value is assigned multiple times during deserialization, so it works as expected with other options like case-sensitivity and naming policy.
197+
198+
### Strict JSON serialization options
199+
200+
The JSON serializer accepts many options to customize serialization and deserialization, but the defaults may be too relaxed for some applications. .NET 10 adds a new `JsonSerializationOptions.Strict` preset that follows best practices by including the following options:
201+
202+
- Applies the `JsonUnmappedMemberHandling.Disallow` policy
203+
- Disables `AllowDuplicateProperties`
204+
- Preserves case sensitive property binding
205+
- Enables both `RespectNullableAnnotations` and `RespectRequiredConstructorParameters` settings
206+
207+
These options are read-compatible with `JsonSerializationOptions.Default` - an object serialized with `JsonSerializationOptions.Default` can be deserialized with `JsonSerializationOptions.Strict`.
208+
209+
For more information about JSON serialization, see [System.Text.Json overview](/dotnet/standard/serialization/system-text-json/overview).
210+
175211
## System.Numerics
176212

177213
- [More left-handed matrix transformation methods](#more-left-handed-matrix-transformation-methods)

docs/core/whats-new/dotnet-10/runtime.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ ai-usage: ai-assisted
1010

1111
This article describes new features and performance improvements in the .NET runtime for .NET 10.
1212

13+
## JIT compiler improvements
14+
15+
The JIT compiler in .NET 10 includes significant enhancements that improve performance through better code generation and optimization strategies.
16+
17+
### Improved code generation for struct arguments
18+
19+
.NET's JIT compiler is capable of an optimization called physical promotion, where the members of a struct are placed in registers rather than on the stack, eliminating memory accesses. This optimization is particularly useful when passing a struct to a method, and the calling convention requires the struct members to be passed in registers.
20+
21+
.NET 10 improves the JIT compiler's internal representation to handle values that share a register. Previously, when struct members needed to be packed into a single register, the JIT would store values to memory first and then load them into a register. Now, the JIT compiler can place the promoted members of struct arguments into shared registers directly, eliminating unnecessary memory operations.
22+
23+
For example, consider a struct with two `int` members. On x64, since `int` values are four bytes wide and registers are eight bytes wide, both members can be packed into one register. The improved code generation eliminates the need for intermediate memory storage, resulting in more efficient assembly code.
24+
25+
### Improved loop inversion
26+
27+
The JIT compiler can hoist the condition of a `while` loop and transform the loop body into a `do-while` loop, improving code layout by removing the need to branch to the top of the loop to test the condition. This transformation is called loop inversion, and it enables numerous other optimizations like loop cloning, loop unrolling, and induction variable optimizations.
28+
29+
.NET 10 enhances loop inversion by switching from a lexical analysis implementation to a graph-based loop recognition implementation. This change brings improved precision by considering all natural loops (loops with a single entry point) and ignoring false positives that were previously considered. This translates into higher optimization potential for .NET programs with `for` and `while` statements.
30+
1331
## Array interface method devirtualization
1432

1533
One of the [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 expanded to cover array interface methods.

docs/core/whats-new/dotnet-10/sdk.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,74 @@ ai-usage: ai-assisted
1111

1212
This article describes new features and enhancements in the .NET SDK for .NET 10.
1313

14+
## .NET tools enhancements
15+
16+
### Platform-specific .NET tools
17+
18+
.NET tools can now be published with support for multiple RuntimeIdentifiers (RIDs) in a single package. Tool authors can bundle binaries for all supported platforms, and the .NET CLI will select the correct one at install or run time. This makes cross-platform tool authoring and distribution much easier.
19+
20+
These enhanced tools support various packaging variations:
21+
22+
- **Framework-dependent, platform-agnostic** (classic mode, runs anywhere with .NET 10 installed)
23+
- **Framework-dependent, platform-specific** (smaller, optimized for each platform)
24+
- **Self-contained, platform-specific** (includes the runtime, no .NET installation required)
25+
- **Trimmed, platform-specific** (smaller, trims unused code)
26+
- **AOT-compiled, platform-specific** (maximum performance and smallest deployment)
27+
28+
These new tools work much like normal published applications, so any publishing options you can use with applications (self-contained, trimmed, AOT, etc.) can apply to tools as well.
29+
30+
### One-shot tool execution
31+
32+
You can now use the `dotnet tool exec` command to execute a .NET tool without installing it globally or locally. This is especially valuable for CI/CD or ephemeral usage.
33+
34+
```bash
35+
dotnet tool exec --source ./artifacts/package/ toolsay "Hello, World!"
36+
```
37+
38+
This downloads and runs the specified tool package in one command. By default, users are prompted to confirm the download if the tool doesn't already exist locally. The latest version of the chosen tool package is used unless an explicit version is specified.
39+
40+
One-shot tool execution works seamlessly with local tool manifests. If you run a tool from a location containing a `.config/dotnet-tools.json` nearby, the version of the tool in that configuration will be used instead of the latest version available.
41+
42+
### The new `dnx` tool execution script
43+
44+
The `dnx` script provides a streamlined way to execute tools. It forwards all arguments to the `dotnet` CLI for processing, making tool usage as simple as possible:
45+
46+
```bash
47+
dnx toolsay "Hello, World!"
48+
```
49+
50+
The actual implementation of the `dnx` command is in the `dotnet` CLI itself, allowing its behavior to evolve over time.
51+
52+
For more information about managing .NET tools, see [Manage .NET tools](/dotnet/core/tools/global-tools).
53+
54+
### CLI introspection with `--cli-schema`
55+
56+
A new `--cli-schema` option is available on all CLI commands. When used, it outputs a JSON representation of the CLI command tree for the invoked command or subcommand. This is useful for tool authors, shell integration, and advanced scripting.
57+
58+
```bash
59+
dotnet clean --cli-schema
60+
```
61+
62+
The output provides a structured, machine-readable description of the command's arguments, options, and subcommands.
63+
64+
## File-based apps enhancements
65+
66+
.NET 10 brings significant updates to the file-based apps experience, including publish support and native AOT capabilities.
67+
68+
### Enhanced file-based apps with publish support and native AOT
69+
70+
File-based apps now support being published to native executables via the `dotnet publish app.cs` command, making it easier to create simple apps that you can redistribute as native executables. All file-based apps now target native AOT by default. If you need to use packages or features that are incompatible with native AOT, you can disable this using the `#:property PublishAot=false` directive in your .cs file.
71+
72+
File-based apps also include enhanced features:
73+
74+
- **Project referencing**: Support for referencing projects via the `#:project` directive
75+
- **Runtime path access**: App file and directory paths are available at runtime via `System.AppContext.GetData`
76+
- **Enhanced shebang support**: Direct shell execution with improved shebang handling, including support for extensionless files
77+
78+
These enhancements make file-based apps more powerful while maintaining their simplicity for quick scripting and prototyping scenarios.
79+
80+
For more information about native AOT, see [.NET native AOT](/dotnet/core/deploying/native-aot/).
81+
1482
## Pruning of framework-provided package references
1583

1684
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 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.

0 commit comments

Comments
 (0)