Closed stevewgh closed 5 years ago
Hi Steve,
Thanks for this, the PR looks good! I've appended some changes to your PR to update the docs, and also change the existing when_initializing_all_expected_resources_are_created test. It looks like Cosmos is now adding additional exclude paths when creating collections to ignore the etag field, which then breaks the count assertions. Therefore, I've just tweaked the assertion to take this into account.
Any methods that use
JObject.FromObject
orJObject.ToObject
can now use aJsonSerializer
which is constructed from aJsonSerializationSettings
instance, allowing custom serialization rules to be applied transparently without the event store being aware.The
JsonSerializationSettings
instance is injected from theAzureDocumentDbStorageEngineBuilder
. This allows custom serialization converters (and other Json.Net extensions) to be provided to theAzureDocumentDbStorageEngine
and allows control over how the events are serialized.I tried to avoid this change by providing the
JsonSerializationSettings
instance to theDocumentClient
, but the use ofJObject.FromObject
andJObject.ToObject
used their ownJsonSerializationSettings
which ignored the converters.An alternative to this PR is to change the type of the
DocumentDbStorageEvent.Body
property to object instead of JObject which would force the DocumentClient to perform the body serialization, however, this may break existing stores due to the contract change.Some use cases for this level of event serialization