Expose default implementation of CosmosSerializer #1813
Labels
API_REVIEW
customer-reported
Issue created by a customer
discussion-wanted
Need a discussion on an area
Is your feature request related to a problem? Please describe.
The
CosmosSerializer
class in ComsosDb is currently abstract and all its implementation such as CosmosJsonDotNetSerializer or CosmosTextJsonSerializer areinternal
sealed
. This makes it impossible to extend these serializers in our code. More often than not, we have a need to implementCosmosSerializer
in our code. Since there is no default implementation ofCosmosSerializer
we end up duplicating the ComsosDb SDK internal serializer in our own class.For example, currently, the only way to supply Newtonsoft
JsonSerializerSettings
is to implementCosmosSerializer
while our only intention is to add customJsonConverter
and initialize properties such asTypeNameHandling
,ConstructorHandling
, etc.In addition to this, a default implementation of
CosmosSerializer
where it gives access to rawJObject
/Stream
in derived class can be very useful. In my current project, our custom implementation ofCosmosSerializer
enables us to do the following things:From my experience, CosmosDb does not have a great story to tell when it comes to schema migration/ change on rehydration from CosmosDb. A default implementation of CosmosSerializer may just open the door to achieve equivalent to RavenDb events in future.
ttl
(while running tests) before saving it to Cosmos.Describe the solution you'd like
Expose default implementation of CosmosSerializer for
Newtonsoft.Json
andSystem.Text.Json
.Here is one example of how we could benefit from the default implementation of CosmosSerializer while creating ComsosClient:
Describe alternatives you've considered
Create our own custom implementation of CosmosSerializer inspired by
CosmosJsonDotNetSerializer
orCosmosTextJsonSerializer
The text was updated successfully, but these errors were encountered: