dotnet new api -aot: ‘-aot’ is not a valid option
The correct syntax for generating a project with AOT is --aot
(with 2 hyphens). In this particular case, the correct command would be:
dotnet new api --aot
Code language: Bash (bash)
The correct syntax for generating a project with AOT is --aot
(with 2 hyphens). In this particular case, the correct command would be:
dotnet new api --aot
Code language: Bash (bash)
.NET 8 brings some neat performance for existing APIs that handle type information. One such API that has seen a significant improvement is GetGenericTypeDefinition. In my benchmarks, the .NET 8 implementation is almost 10 times faster compared to the .NET 7 version. You can run this benchmark yourself if you’d like using BenchmarkDotNet: Or if…
Starting with .NET 8, the JsonSerializerOptions class features a new TypeInfoResolverChain property in addition to the existing TypeInfoResolver property. With this new property, you are no longer required to specify all the resolvers in the same place, instead, you can add them later as needed. Let’s look at an example: Besides adding new type resolvers…
The ref readonly modifier enables a more transparent way of passing read-only references to a method. Passing of readonly references was already possible in C# by using the in modifier ever since version 7.2, but that syntax had some limitations, or rather too little constraints. So how does the new modifier work? Let’s assume the…
Part of .NET 8, JsonNode and JsonArray get a few new additions to their API. We’ve already covered deep copy and deep equality in an earlier article, but there’s more. GetValueKind Returns the JsonValueKind of the current instance. GetPropertyName Returns property name of the current node from the parent object. Throws an InvalidOperationException if the…
System.Text.Json brings out of the box support for additional types: Let’s look at an example:
Starting with .NET 8 you can mark JsonSerializerOptions instances as read-only, preventing further changes to the instance. To freeze the instance, simply call MakeReadOnly on the options instance. Let’s take an example: Furthermore, you can check if an instance was frozen or not by checking the IsReadOnly property. Attempting to modify a JsonSerializerOptions instance after…