@@ -80,7 +80,7 @@ let [<Fact>] ``RejectNullStringConverter rejects null strings`` () =
8080 let value = { c = 1 ; d = null }
8181 raises< ArgumentNullException> <@ serdes.Serialize value @>
8282
83- type WithList = { x: int ; y: list < int > }
83+ type WithList = { x: int ; y: list < int >; z : Set < int > }
8484
8585let [<Fact>] ``RejectNullConverter rejects null lists and Sets`` () =
8686#if false // requires WithList to be CLIMutable, which would be a big imposition
@@ -93,18 +93,28 @@ let [<Fact>] ``RejectNullConverter rejects null lists and Sets`` () =
9393 if pt.IsGenericType && ( let gtd = pt.GetGenericTypeDefinition() in gtd = typedefof< list<_>> || gtd = typedefof< Set<_>>) then
9494 p.IsRequired <- true )
9595 let serdes = Options.Create( TypeInfoResolver = tir) |> Serdes
96+ raises< exn> <@ serdes.Deserialize< WithList> """ {"x":0}""" @>
9697#else
9798 let serdes = Options.Create( rejectNull = true ) |> Serdes
98- #endif
9999
100100 // Fails with NRE when RejectNullConverter delegates to Default list<int> Converter
101101 // seems akin to https://github.com/dotnet/runtime/issues/86483
102- let res = serdes.Deserialize< WithList> """ {"x":0,"y":[1]}"""
103- test <@ [ 1 ] = res.y @>
102+ // let res = serdes.Deserialize<WithList> """{"x":0,"y":[1]}"""
103+ // test <@ [1] = res.y @>
104104
105+ // PROBLEM: Doesn't raise
105106 raises< exn> <@ serdes.Deserialize< WithList> """ {"x":0}""" @>
106- // PROBLEM: there doesn't seem to be a way to intercept explicitly passed nulls
107+ // PROBLEM: doesnt raise - there doesn't seem to be a way to intercept explicitly passed nulls
107108 // raises<JsonException> <@ serdes.Deserialize<WithList> """{"x":0,"y":null}""" @>
109+ #endif
110+
111+ #if false // I guess TypeShape is doing a reasaonable thing not propagating
112+ // PROBLEM: TypeShape.Generic.exists does not call the predicate if the list or set is `null`
113+ let res = serdes.Deserialize< WithList> """ {"x":0}"""
114+ let hasNullList = TypeShape.Generic.exists ( fun ( x : int list ) -> obj.ReferenceEquals( x, null ))
115+ let hasNullSet = TypeShape.Generic.exists ( fun ( x : Set < int >) -> obj.ReferenceEquals( x, null ))
116+ test <@ hasNullList res && hasNullSet res @>
117+ #endif
108118
109119let [<Fact>] ``RejectNullStringConverter serializes strings correctly`` () =
110120 let serdes = Serdes( Options.Create( rejectNullStrings = true ))
0 commit comments