[CSHARP-555] BsonDocument object model methods should throw ArgumentNullException instead of ignoring C# null Created: 06/Sep/12 Updated: 22/May/15 Resolved: 21/Apr/14 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.8 |
| Fix Version/s: | 2.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Robert Stam | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Description |
|
The BsonDocument object model has a tricky way of ignoring C# null values sometimes, which allows constructs like the following:
The intent was to facilitate construction of documents with optional elements, but in practice users have been confused and/or surprised by this. So we are going to change the Add method (which the above code implicitly calls) to throw an ArgumentNullException in this case. You can easily achieve the same result just by adding an explicit test:
The following is the complete list of methods that will be changed in this way: BsonArray.Create (multiple overloads) |
| Comments |
| Comment by Githook User [ 21/Apr/14 ] |
|
Author: {u'name': u'rstam', u'email': u'robert@10gen.com'}Message: |
| Comment by Githook User [ 21/Apr/14 ] |
|
Author: {u'name': u'rstam', u'email': u'robert@10gen.com'}Message: |
| Comment by Robert Stam [ 21/Apr/14 ] |
|
Part of this work was already done while working on https://github.com/mongodb/mongo-csharp-driver/commit/8cad37b22079abde35b3dbdfbe6cd6e023d0fa5e |
| Comment by Robert Stam [ 24/Feb/13 ] |
|
This work was prototyped on the experimental x2.0 branch. This ticket is being reopened for eventual porting to the official 2.0 branch. |
| Comment by Robert Stam [ 07/Sep/12 ] |
|
Pushed to x2.0 branch. |
| Comment by Robert Stam [ 07/Sep/12 ] |
|
In code review. |
| Comment by auto [ 07/Sep/12 ] |
|
Author: {u'date': u'2012-09-06T22:29:19-07:00', u'name': u'rstam', u'email': u'robert@10gen.com'}Message: |