-
Notifications
You must be signed in to change notification settings - Fork 48
Closed
Description
Repro:
open System
open System.Text.Json
open System.Text.Json.Serialization
type X = { X: X }
let x = { X = Unchecked.defaultof<_> }
let options = JsonSerializerOptions()
options.Converters.Add(JsonFSharpOptions.Default() |> JsonFSharpConverter)
Console.WriteLine(JsonSerializer.Serialize(x, options))On v1.1 this works fine, but on v1.2 this throws:
System.NullReferenceException: Object reference not set to an instance of an object.
at lambda_method2(Closure, Object)
at System.Text.Json.Serialization.JsonRecordConverter`1.WriteRestOfObject(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
at System.Text.Json.Serialization.JsonRecordConverter`1.Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter`1.WriteCoreAsObject(Utf8JsonWriter writer, Object value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.JsonSerializer.WriteCoreAsObject(Utf8JsonWriter writer, Object value, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.Serialization.JsonRecordConverter`1.WriteRestOfObject(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
at System.Text.Json.Serialization.JsonRecordConverter`1.Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.JsonSerializer.WriteCore[TValue](Utf8JsonWriter writer, TValue& value, JsonTypeInfo`1 jsonTypeInfo)
at System.Text.Json.JsonSerializer.WriteString[TValue](TValue& value, JsonTypeInfo`1 jsonTypeInfo)
at System.Text.Json.JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options)
at <StartupCode$Test2>.$Program.main@() in \_\Test2\Test2\Program.fs:line 12
Metadata
Metadata
Assignees
Labels
No labels