This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +21
-0
lines changed
tests/ServiceStack.Text.Tests/Issues Expand file tree Collapse file tree 5 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ public static void Refresh()
72
72
return ;
73
73
74
74
ReadFn = JsonReader . Instance . GetParseStringSpanFn < T > ( ) ;
75
+ JsConfig . AddUniqueType ( typeof ( T ) ) ;
75
76
}
76
77
77
78
public static ParseStringDelegate GetParseFn ( ) => ReadFn != null
Original file line number Diff line number Diff line change @@ -167,6 +167,7 @@ public static void Refresh()
167
167
CacheFn = typeof ( T ) == typeof ( object )
168
168
? JsonWriter . WriteLateBoundObject
169
169
: JsonWriter . Instance . GetWriteFn < T > ( ) ;
170
+ JsConfig . AddUniqueType ( typeof ( T ) ) ;
170
171
}
171
172
172
173
public static WriteObjectDelegate WriteFn ( )
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ public static void Refresh()
70
70
return ;
71
71
72
72
ReadFn = JsvReader . Instance . GetParseStringSpanFn < T > ( ) ;
73
+ JsConfig . AddUniqueType ( typeof ( T ) ) ;
73
74
}
74
75
75
76
public static ParseStringDelegate GetParseFn ( ) => ReadFn != null
Original file line number Diff line number Diff line change @@ -124,6 +124,7 @@ public static void Refresh()
124
124
CacheFn = typeof ( T ) == typeof ( object )
125
125
? JsvWriter . WriteLateBoundObject
126
126
: JsvWriter . Instance . GetWriteFn < T > ( ) ;
127
+ JsConfig . AddUniqueType ( typeof ( T ) ) ;
127
128
}
128
129
129
130
public static WriteObjectDelegate WriteFn ( )
Original file line number Diff line number Diff line change @@ -22,6 +22,11 @@ public CustomFormatType(int value)
22
22
{
23
23
_value = value ;
24
24
}
25
+
26
+ public override string ToString ( )
27
+ {
28
+ return _value . ToString ( ) ;
29
+ }
25
30
}
26
31
27
32
class Dto
@@ -44,6 +49,18 @@ public void CallReset_AfterSerializingOnce_WithCustomSerializationForProperty_Do
44
49
45
50
TestRoundTripValue ( dto ) ;
46
51
}
52
+
53
+ [ Test ]
54
+ public void CallReset_AfterSerializingOnce_WithCustomSerializationForProperty_MustClearCustomSerialization ( )
55
+ {
56
+ var dto = new Dto { CustomFormatTypeProperty = new CustomFormatType ( 12345 ) } ;
57
+ JsConfig < CustomFormatType > . DeSerializeFn = str =>
58
+ new CustomFormatType ( int . Parse ( str ) ) ;
59
+ var json = dto . ToJson ( ) ;
60
+ JsConfig . Reset ( ) ;
61
+ var fromJson = json . FromJson < Dto > ( ) ;
62
+ Assert . That ( fromJson . CustomFormatTypeProperty . Value , Is . EqualTo ( 0 ) ) ;
63
+ }
47
64
48
65
private static void ConfigureCustomFormatType ( )
49
66
{
You can’t perform that action at this time.
0 commit comments