A new version of the mongodb driver for .NET was released under the minor version 2.19. This breaking change affects our MongoDB persistence and our customers. We have deliberately left the nuget range a bit more open because we hoped for SemVer compliance Anyway that’s not the topic I would like to discuss.
I was wondering why it is required to register a serializer mapping when there is already a BsonClassMap concept? Currently the breaking change guidance states the following:
var objectSerializer = new ObjectSerializer(type => ObjectSerializer.DefaultAllowedTypes(type) || type.FullName.StartsWith("MyNamespace"));
but for us since parts of the serialization is done “by our framework” we cannot override the default serializer like that. So we need to register basically an object serializer per type we are aware of to not interfere with the user defined types because they will also have to configure things for all the types they allow. That being said the driver also has support for
BsonClassMap which we are also using. For example we do the following for the types we discovered
foreach (var sagaMetadata in sagaMetadataCollection)
var classMap = new BsonClassMap(sagaMetadata.SagaEntityType);
which to me means we are already by definition making the driver “aware of the types we allow and want to map”. So why is the extra step necessary for users that already define mappings?