[CSHARP-2889] BsonClassMap.LookupClassMap supports private constructors inconsistently Created: 31/Dec/19  Updated: 28/Oct/23  Resolved: 17/Jan/20

Status: Closed
Project: C# Driver
Component/s: Serialization
Affects Version/s: 2.10.0
Fix Version/s: 2.10.2

Type: Bug Priority: Major - P3
Reporter: Gennady Andreev Assignee: Dmitry Lukyanov (Inactive)
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File Program.cs    
Issue Links:
Duplicate
is duplicated by CSHARP-1559 Impossible to create BsonClassMap for... Closed
Related
is related to CSHARP-3108 Deserialization throws No matching cr... Closed
is related to CSHARP-3175 Regression in v2.10.2 - No matching c... Closed
Backwards Compatibility: Minor Change

 Description   

For a derived type with private parameterless constructor, BsonClassMap.LookupClassMap works fine if it introduces new properties, but throws an exception if it does not (example in the attachment). It seems to me the method should work fine in both cases.



 Comments   
Comment by Robert Stam [ 17/Jun/20 ]

As part of fixing this issue we now correctly identify some immutable classes that we didn't use to correctly identify as immutable.

Because immutable classes are deserialized differently than mutable classes (specifically: immutable classes will only be instantiated by calling a constructor) the changes in this ticket can result in slightly different behavior from before when deserializing documents that are missing fields.

See CSHARP-3108 for details.

Comment by Githook User [ 17/Jan/20 ]

Author:

{'username': 'DmitryLukyanov', 'name': 'DmitryLukyanov', 'email': 'dmitry.lukyanov@mongodb.com'}

Message: CSHARP-2889: BsonClassMap.LookupClassMap supports private constructors inconsistently.
Branch: v2.10.x
https://github.com/mongodb/mongo-csharp-driver/commit/f8d38a869e1ec36cf2cd1bdcf26c9d279b006553

Comment by Githook User [ 17/Jan/20 ]

Author:

{'name': 'DmitryLukyanov', 'email': 'dmitry.lukyanov@mongodb.com', 'username': 'DmitryLukyanov'}

Message: CSHARP-2889: BsonClassMap.LookupClassMap supports private constructors inconsistently.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/2a716e19b631592c31ab4d55e4d03366c65d6be0

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