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)
One less-known feature of the UnsafeAccessorAttribute is that it also allows you to access auto-generated backing fields of auto-properties – fields with unspeakable names. The way to access them is very similar to accesing fields, the only difference being the member name pattern, which looks like this: Let’s take the following class as an example:…
Interceptors are an experimental compiler feature introduced in .NET 8, meaning it may change or be removed in a future release of the framework. To see what else is new in .NET 8, check out our What’s new in .NET 8 page. To enable the feature, you’ll need to turn on a feature flag by…
This exception is thrown when you are building an identity DbContext without providing the user and role stores using AddUserStore and AddRoleStore. You can provide both configurations with a single call to AddEntityFrameworkStores like in the example below: The full exception for reference: System.AggregateException: ‘Some services are not able to be constructed (Error while validating…
Similar to serializing into non-public members, you can deserialize into non-public members by providing a constructor with parameters matching the non-public member names and by annotating the non-public members with the JsonInclude attribute. Let’s jump straight to an example: Note how we haven’t annotated PublicProperty in any way and we haven’t included it in the…
When using dotnet script you can pass arguments by specifying them after — (two dashes). You can the access the arguments in the script using the Args collection. Let’s take an example. Assume we have the following myScript.csx script file: We can pass parameter to this script as follows:
Starting with .NET 8 you can deserialize into properties which do not have a set accessor. You can opt-in for this behavior using JsonSerializerOptions, or on a per-type basis using the JsonObjectCreationHandling attribute. Using JsonObjectCreationHandling attribute You can annotate your type with the System.Text.Json.Serialization.JsonObjectCreationHandling attribute, passing your option as a parameter. Using JsonSerializerOptions You can…