possix
possix
CC#
Created by possix on 6/12/2024 in #help
deserialize non-nullable
but reflection and NullabilityInfoContext can see the ?, yes? Hence my confusion..
15 replies
CC#
Created by possix on 6/12/2024 in #help
deserialize non-nullable
yes according to the docs (https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/required-properties)
There are three ways to mark a property or field as required for JSON deserialization: By adding the required modifier, which is new in C# 11. By annotating it with JsonRequiredAttribute, which is new in .NET 7. By modifying the JsonPropertyInfo.IsRequired property of the contract model, which is new in .NET 7.
15 replies
CC#
Created by possix on 6/12/2024 in #help
deserialize non-nullable
Ok, got it. Just curious, what led the C# team to this decision where one c# feature (required, also new keyword) throws and the other (nullable reference type) does not?
15 replies