Liversage / OneOf.Serialization.SystemTextJson

System.Text.Json serialization support for OneOf types.
MIT License
4 stars 0 forks source link

Cannot return as T1 as result is T0 #1

Open JarrodJ83 opened 6 months ago

JarrodJ83 commented 6 months ago

Trying out your package and getting the following error. Not sure why it is trying to serialize as T1 because the object is T0:

image
   at OneOf.OneOf`2.get_AsT1()
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
   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)

Any help would be appreciated! Thanks!

Liversage commented 6 months ago

@JarrodJ83 Can you provide more information? I need to be able to reproduce the issue to investigate it. Stack traces are useful but I in the one provided here I don't see any code from this library.