-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
Labels
area-System.Text.JsonenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionspartner-impactThis issue impacts a partner who needs to be kept updatedThis issue impacts a partner who needs to be kept updated
Milestone
Description
Thanks, this looks like a real bug. FWIW it's not specific to primary constructors or records, this fails too:
using System.Text.Json.Serialization; using System.Text.Json; var singleUserJson = """{"Username":"Filip","PhoneNumbers":["123456"]}"""; var userFromJson = JsonSerializer.Deserialize<User>(singleUserJson); Console.WriteLine(userFromJson.PhoneNumbers.Count); // 0 public class User { public User(string name) => Name = name; public string Name { get; } [JsonObjectCreationHandling(JsonObjectCreationHandling.Populate)] public List<string> PhoneNumbers { get; } = new(); }
Originally posted by @eiriktsarpalis in dotnet/docs#37329 (comment)
Tyrrrz, rog1039, xshaheen, andrei-davidovich, vgorbenko-bsh and 1 more
Metadata
Metadata
Assignees
Labels
area-System.Text.JsonenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionspartner-impactThis issue impacts a partner who needs to be kept updatedThis issue impacts a partner who needs to be kept updated