-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Description
The [JsonExtensionData] attribute is not supported and silently fails.
Expect that the parser detects that attribute and passes that information\metadata to the serializer (best long-term), or we generate a design-time error (to help scope V6).
Repro:
using System.Text.Json;
using System.Text.Json.Serialization;
using Test;
POCO? poco = JsonSerializer.Deserialize("{\"Hello\":42}", MyContext.Default.POCO);
// Non-source gen works:
// POCO? poco = JsonSerializer.Deserialize<POCO>("{\"Hello\":42}");
// Throws since Overflow is null
Console.WriteLine(poco.Overflow["Hello"]);
namespace Test
{
[JsonSerializable(typeof(POCO))]
public partial class MyContext : JsonSerializerContext
{
}
public partial class POCO
{
[JsonExtensionData]
public Dictionary<string, JsonElement> Overflow { get; set; }
}
}samsosa