File tree 1 file changed +23
-0
lines changed
src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,18 @@ public void DeserializerSetsMissingPropertiesToDefaultValue_OrdinalKey()
84
84
Assert . Null ( instance . Prop2 ) ;
85
85
}
86
86
87
+ [ Fact ]
88
+ public void CtorParameterAndPropertySetterExists ( )
89
+ {
90
+ var m1 = new ClassWithPropertySetterAndDummyCtor ( 999 ) { MyProperty = 100 } ;
91
+ byte [ ] bin = MessagePackSerializer . Serialize ( m1 ) ;
92
+ var m2 = MessagePackSerializer . Deserialize < ClassWithPropertySetterAndDummyCtor > ( bin ) ;
93
+
94
+ // In this version of the deserializer, we expect the property setter to be invoked
95
+ // and reaffirm the value already passed to the constructor.
96
+ Assert . Equal ( m1 . MyProperty , m2 . MyProperty ) ;
97
+ }
98
+
87
99
/// <summary>
88
100
/// Verifies that virtual and overridden properties do not cause the dynamic resolver to malfunction.
89
101
/// </summary>
@@ -357,6 +369,17 @@ public class DerivedClass : BaseClass
357
369
[ DataMember ]
358
370
public string Name { get ; set ; }
359
371
}
372
+
373
+ [ MessagePackObject ( true ) ]
374
+ public class ClassWithPropertySetterAndDummyCtor
375
+ {
376
+ public int MyProperty { get ; set ; }
377
+
378
+ public ClassWithPropertySetterAndDummyCtor ( int myProperty )
379
+ {
380
+ // This constructor intentionally left blank.
381
+ }
382
+ }
360
383
}
361
384
}
362
385
You can’t perform that action at this time.
0 commit comments