Details
-
Improvement
-
Resolution: Won't Fix
-
Minor - P4
-
None
-
None
-
None
-
None
-
MongoDB Driver 2.5
-
Fully Compatible
Description
Right now, if I register the same BsonSerializer twice, I'll get an exception saying that a BsonSerializer has already been registered for that type.
I'm running my tests using XUnit, and a few of them pass through the part of my project that registers a couple of custom serializers. Even though each only passes through this code once, when ran together, the static nature of BsonSerializer somehow causes them to interfere with each other, throwing the "There is already a serializer registered for type ..." exception (thrown here).
It seems that the API would be more developer friendly if this method would allow the same serializer to be registered twice. A potential fix would be to, if failing to add it to the dictionary, check if it already exists in the dictionary, and, if so, do nothing (instead of throwing).
I'm happy to do a pull request if necessary.