[CSHARP-1949] BsonSerializer RegisterSerializer should validate serializer argument Created: 21/Mar/17  Updated: 05/Feb/18  Resolved: 05/Feb/18

Status: Closed
Project: C# Driver
Component/s: Serialization
Affects Version/s: 2.4.3
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Robert Stam Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CSHARP-2150 RegisterSerializer should check that ... Backlog
Related
related to CSHARP-1948 LINQ translation error when RegisterS... Closed
Backwards Compatibility: Fully Compatible

 Description   

The untyped overloads of RegisterSerializer can't catch type mismatches at compile time. They are currently not being caught at runtime either, and mismatches result in difficult to diagnose errors later on when the driver attempts to use the mismatched serializer.

For example, the following should be a runtime error:

var xserializer = new XSerializer();
BsonSerializer.RegisterSerializer(typeof(Y), xserializer);


Generated at Wed Feb 07 21:41:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.