I recently upgraded a project's FSharpLu dependency from 0.10.31 to 0.11.7. In this project, we use an eventstore and have years of existing serialised events. I found that upgrading FSharpLu broke deserialisation of specific tuple types. I tracked down a specific repro below. I've fixed the issue for now by changing references from BackwardCompatable to Compact.Legacy in the project (AndrewIOM/global-pollen-project/issues/30). It wasn't clear from the docs whether this is expected behaviour or not, so opening a bug in case!
... and FSI output:
> type Url = Url of string
- type Test = (string * Url option) option
-
- let testItem = """{ "Item1": "\"Reisen in Europa, Asien und Afrika 1:\", 161, 1847" }"""
- ;;
type Url = | Url of string
type Test = (string * Url option) option
val testItem: string =
"{ "Item1": "\"Reisen in Europa, Asien und Afrika 1:\", 161, 1847" }"
> let works = Compact.Legacy.deserialize<Test> testItem
- ;;
val works: Test =
Some (""Reisen in Europa, Asien und Afrika 1:", 161, 1847", None)
> let doesntWork = Compact.deserialize<Test> testItem
- ;;
Newtonsoft.Json.JsonReaderException: Cannot parse legacy tuple value: {
"Item1": "\"Reisen in Europa, Asien und Afrika 1:\", 161, 1847"
}. Missing property: Item2
at <StartupCode$Microsoft-FSharpLu-Json>.$Compact.failreadwith@168-1.Invoke(String s)
at Microsoft.FSharp.Collections.Internal.IEnumerator.map@75.DoMoveNext(b& curr) in D:\a\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 81
at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System.Collections.IEnumerator.MoveNext() in D:\a\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 68
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at Microsoft.FSharp.Collections.SeqModule.ToArray[T](IEnumerable`1 source)
at Microsoft.FSharp.Collections.ArrayModule.OfSeq[T](IEnumerable`1 source) in D:\a\_work\1\s\src\fsharp\FSharp.Core\array.fs:line 1059
at Microsoft.FSharpLu.Json.CompactUnionJsonConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.Serialization.JsonSerializerProxy.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
at <StartupCode$Microsoft-FSharpLu-Json>.$Compact.ReadJson$cont@172(JsonSerializer serializer, JsonReader reader, Type objectType, FSharpTypeFunc failreadwithf, Unit unitVar)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Microsoft.FSharpLu.Json.Compact.deserialize[T](String json)
at <StartupCode$FSI_0016>.$FSI_0016.main@()
Stopped due to error
>
I recently upgraded a project's FSharpLu dependency from 0.10.31 to 0.11.7. In this project, we use an eventstore and have years of existing serialised events. I found that upgrading FSharpLu broke deserialisation of specific tuple types. I tracked down a specific repro below. I've fixed the issue for now by changing references from BackwardCompatable to Compact.Legacy in the project (AndrewIOM/global-pollen-project/issues/30). It wasn't clear from the docs whether this is expected behaviour or not, so opening a bug in case!
Edit: some of the earlier events may have been serialised with Newtonsoft, which may explain issues with these events. Later events have a format as follows:
"""Some ("Novosti Sist. Vyssh. Rast., 41: 93, 2009", None) }"""... and FSI output: