You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[System.Text.Json] Deserializing object without parameterless ctor results in null-ref #29490
I'm not sure if there are plans to support objects without parameterless ctors. However, attempting to deserialize an object without one results in a null ref rather than a meaningful error:
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at System.Text.Json.Serialization.JsonSerializer.HandleStartObject(JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& state)
@ahsonkhan could we improve the error message for the current release? Seeing a null ref doesn't help the user understand that the scenario isn't supported.
Activity
ahsonkhan commentedon May 9, 2019
I don't think custom ctors is supported atm. cc @steveharter
pranavkm commentedon May 9, 2019
@ahsonkhan could we improve the error message for the current release? Seeing a null ref doesn't help the user understand that the scenario isn't supported.
ahsonkhan commentedon May 9, 2019
Agreed. I am sure we can improve the error messaging for non-supported scenarios, overall. I'll let @steveharter chime-in regarding that.
vcsjones commentedon May 9, 2019
Wrote dotnet/corefx#37545 to track improving error messaging.