@@ -330,6 +330,68 @@ public void Deserialize_Correctly_When_Last_Item_Is_Null_in_Int_array_prop()
330330 var deserialized = TypeSerializer . DeserializeFromString < TestMappedList > ( serialized ) ;
331331 Assert . That ( deserialized . IntArrayProp , Is . EqualTo ( type . IntArrayProp ) ) ;
332332 }
333+
334+
335+ [ Test ]
336+ public void Null_Reference_Exception_On_Inherited_Field_With_No_Setter ( )
337+ {
338+ string testString = null ;
339+ InheritedFieldErrorTest parentClass = new InheritedFieldErrorTest ( ) , parentClassResult = null ;
340+ InheritedFieldErrorTestChild childClass = new InheritedFieldErrorTestChild ( ) , childClassResult = null ;
341+ Assert . DoesNotThrow ( ( ) => { testString = JsonSerializer . SerializeToString ( parentClass ) ; } ) ;
342+ Assert . IsNotNull ( testString ) ;
343+ Assert . IsNotEmpty ( testString ) ;
344+ Assert . DoesNotThrow ( ( ) => { parentClassResult = JsonSerializer . DeserializeFromString < InheritedFieldErrorTest > ( testString ) ; } ) ;
345+ Assert . IsNotNull ( parentClassResult ) ;
346+ Assert . DoesNotThrow ( ( ) => { testString = JsonSerializer . SerializeToString ( childClass ) ; } ) ;
347+ Assert . IsNotNull ( testString ) ;
348+ Assert . IsNotEmpty ( testString ) ;
349+ Assert . DoesNotThrow ( ( ) => { childClassResult = JsonSerializer . DeserializeFromString < InheritedFieldErrorTestChild > ( testString ) ; } ) ;
350+ Assert . IsNotNull ( childClassResult ) ;
351+ }
352+
353+ [ System . Runtime . Serialization . DataContract ]
354+ public class InheritedFieldErrorTest
355+ {
356+ [ System . Runtime . Serialization . DataMember ]
357+ protected bool test = false ;
358+ }
359+
360+ [ System . Runtime . Serialization . DataContract ]
361+ public class InheritedFieldErrorTestChild : InheritedFieldErrorTest
362+ {
363+ }
364+
365+ [ Test ]
366+ public void Null_Reference_Exception_On_Inherited_Property_With_No_Setter ( )
367+ {
368+ string testString = null ;
369+ InheritedPropertyErrorTest parentClass = new InheritedPropertyErrorTest ( ) , parentClassResult = null ;
370+ InheritedPropertyErrorTestChild childClass = new InheritedPropertyErrorTestChild ( ) , childClassResult = null ;
371+ Assert . DoesNotThrow ( ( ) => { testString = JsonSerializer . SerializeToString ( parentClass ) ; } ) ;
372+ Assert . IsNotNull ( testString ) ;
373+ Assert . IsNotEmpty ( testString ) ;
374+ Assert . DoesNotThrow ( ( ) => { parentClassResult = JsonSerializer . DeserializeFromString < InheritedPropertyErrorTest > ( testString ) ; } ) ;
375+ Assert . IsNotNull ( parentClassResult ) ;
376+ Assert . DoesNotThrow ( ( ) => { testString = JsonSerializer . SerializeToString ( childClass ) ; } ) ;
377+ Assert . IsNotNull ( testString ) ;
378+ Assert . IsNotEmpty ( testString ) ;
379+ Assert . DoesNotThrow ( ( ) => { childClassResult = JsonSerializer . DeserializeFromString < InheritedPropertyErrorTestChild > ( testString ) ; } ) ;
380+ Assert . IsNotNull ( childClassResult ) ;
381+ }
382+
383+
384+ [ System . Runtime . Serialization . DataContract ]
385+ public class InheritedPropertyErrorTest
386+ {
387+ [ System . Runtime . Serialization . DataMember ]
388+ protected bool Test { get ; }
389+ }
390+
391+ [ System . Runtime . Serialization . DataContract ]
392+ public class InheritedPropertyErrorTestChild : InheritedPropertyErrorTest
393+ {
394+ }
333395 }
334396
335397 public class TestMappedList
0 commit comments