[CSHARP-263] Deserialization of array that was serialized with nominalType object fails due to lack of type information Created: 07/Jul/11 Updated: 02/Apr/15 Resolved: 09/Aug/11 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.1 |
| Fix Version/s: | 1.2 |
| Type: | Bug | 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 |
|
Can reproduce using this class: public class C { public ObjectId Id; public object Obj; }and this code: collection.RemoveAll(); }; var r = collection.FindOneAs<C>(); // fails |
| Comments |
| Comment by Robert Stam [ 09/Aug/11 ] |
|
Created a new issue |
| Comment by Robert Stam [ 08/Jul/11 ] |
|
Running the above code results in the following document being inserted into the database: > db.test.find() { "_id" : ObjectId("4e170e44e447ad78a009cf75"), "Obj" : [ 1, 2, 3 ] }> The question is, what could this be serialized as? Perhaps: > db.test.find() } Not very cross platform... (includes .NET type name). A very similar problem occurs with Dictionaries: var c = new C { Obj = new Dictionary<string, int> { { "a", 1 }, { "b", 2 }, { "c", 3 } } }; which serializes as: > db.test.find() } And also can't be deserialized due to the lack of type information. Another question is whether you should get back an instance of the exact same type as you started with. If not, these two examples could simply be deserialized as a BsonArray and a BsonDocument, but that's different than what you started with (an Int32[] and a Dictionary<string, int>). |