@@ -80,7 +80,7 @@ let [<Fact>] ``RejectNullStringConverter rejects null strings`` () =
80
80
let value = { c = 1 ; d = null }
81
81
raises< ArgumentNullException> <@ serdes.Serialize value @>
82
82
83
- type WithList = { x: int ; y: list < int > }
83
+ type WithList = { x: int ; y: list < int >; z : Set < int > }
84
84
85
85
let [<Fact>] ``RejectNullConverter rejects null lists and Sets`` () =
86
86
#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`` () =
93
93
if pt.IsGenericType && ( let gtd = pt.GetGenericTypeDefinition() in gtd = typedefof< list<_>> || gtd = typedefof< Set<_>>) then
94
94
p.IsRequired <- true )
95
95
let serdes = Options.Create( TypeInfoResolver = tir) |> Serdes
96
+ raises< exn> <@ serdes.Deserialize< WithList> """ {"x":0}""" @>
96
97
#else
97
98
let serdes = Options.Create( rejectNull = true ) |> Serdes
98
- #endif
99
99
100
100
// Fails with NRE when RejectNullConverter delegates to Default list<int> Converter
101
101
// 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 @>
104
104
105
+ // PROBLEM: Doesn't raise
105
106
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
107
108
// 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
108
118
109
119
let [<Fact>] ``RejectNullStringConverter serializes strings correctly`` () =
110
120
let serdes = Serdes( Options.Create( rejectNullStrings = true ))
0 commit comments