Files
dotnet-runtime/src/libraries/System.ObjectModel
Justin Van Patten 0495b6ff25 Allow Json.NET deserialization of ObservableCollection (dotnet/corefx#21322)
Json.NET serializes the collection by enumerating it, without taking
into account any of its fields like the binary serializer does, and
deserializes it by adding the items back to the collection, without
initializing the fields. However, it does still call the
`OnSerializing`/`OnSerialized`/`OnDeserializing`/`OnDeserialized`
methods.

When it calls `OnDeserialized`, a NullRef exception is thrown when we
try to access the `_monitor` field because the field has not been
initialized, unlike with binary deserialization, where the field would
have been initialized from the serialized binary data.

A workaround is to simply check `if (_monitor != null)` before accessing
it in `OnDeserialized`.

Commit migrated from https://github.com/dotnet/corefx/commit/a3b8dc33644933c74aa1e58fb07f69df18301e09
2017-06-21 22:51:18 -07:00
..
2017-05-16 14:12:16 -07:00