[CSHARP-310] Problems using NeverSerializeDefaultValueConvention Created: 24/Aug/11  Updated: 02/Apr/15  Resolved: 18/Oct/11

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.1
Fix Version/s: 1.3

Type: Bug Priority: Minor - P4
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File Program.cs    

 Description   

The attached program should have worked. At the very least there is a usability concern about how to correctly use NeverSerializeDefaultValueConvention, but I think there are also one or more minor bugs lurking (in particular, setting the default value forces SerializeDefaultValue to true overriding the value provided by the convention).

See also: https://groups.google.com/group/mongodb-user/browse_thread/thread/8ee0a96225e22c4b#



 Comments   
Comment by Robert Stam [ 18/Oct/11 ]

Incorporated Brian Knight's fix with minor changes. Thanks Brian!

Comment by Brian Knight [ 16/Sep/11 ]

I have submitted a pull request that resolves the bug. I made a very simple change to BsonClassMap. I changed the AutoMapMember method to use the overloaded BsonMemberMap.SetDefaultValue method, passing in a Boolean for serializeDefaultValue based on the convention value already set in the member map. Previously, the other SetDefaultValue method was used, which set the SerializeDefaultValue property of the map to true in all cases. A unit test is included in the BsonUnitTests.Jira namespace. All tests pass.

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