[CSHARP-582] Allow [BsonDefaultValue] on member fields as well as properties Created: 27/Sep/12  Updated: 20/Mar/14  Resolved: 11/Oct/12

Status: Closed
Project: C# Driver
Component/s: Feature Request
Affects Version/s: 1.6
Fix Version/s: 1.6.1

Type: New Feature Priority: Minor - P4
Reporter: Zaid Masud Assignee: Unassigned
Resolution: Done Votes: 0
Labels: driver, serialization
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

[BsonDefaultValue] is only valid on properties.

However, since fields can be serialized using [BsonElement], it would make sense to allow [BsonDefaultValue] on fields as well, and use the specified default value in deserialization when none is available.



 Comments   
Comment by Craig Wilson [ 11/Oct/12 ]

this has been fixed and incorporated into master.

Comment by Craig Wilson [ 28/Sep/12 ]

Yep, looks like an oversight. You could do ISupportInitialize or you could create your own attribute and copy the contents from the current BsonDefaultValueAttribute class in. We'll pick up that attribute if it implements IBsonMemberMapModifier.

Comment by Zaid Masud [ 27/Sep/12 ]

I suppose the interim workaround for this is implementing ISupportInitialize, unless anyone has a better suggestion?

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