[CSHARP-98] Deserialization Fails on 2nd object read Created: 15/Nov/10 Updated: 02/Apr/15 Resolved: 15/Nov/10 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 0.9 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Ed Rooth | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Win XP. .NET 3.5 |
||
| Backwards Compatibility: | Major Change |
| Description |
|
Sometime between 11/5 and now this broke. Did a pull and got the latest code now the deserialization is broken. Steps to reproduce: 1. Create two classes, one that derives from another. (ie class B: A) This fails at the deserialization stage on the 2nd type B document. Seems to be an issue with the bsonReader's buffer index not getting updated properly b/c it is set to EndOfDocument when it tries to deserialize the 2nd document causing a the actualType to default to the nominalType and therefore causes failure when deserializing. I stepped through the code a bit and this is the beginning of where everything goes bad: // BsonClassMapSerializer.cs line 57 The actualType comes back the same as the nominalType (A) when it should come back as B. Since the data stored in the db is of type B, the properties cant get set and an exception gets thrown. Stack Trace: at MongoDB.Bson.DefaultSerializer.BsonClassMapSerializer.Deserialize(BsonReader bsonReader, Type nominalType) in C:\DEVELOPMENT\trunk\Beast\mongo-csharp-driver\Bson\DefaultSerializer\BsonClassMapSerializer.cs:line 91 |
| Comments |
| Comment by Robert Stam [ 15/Nov/10 ] |
|
Thanks for the detailed information in the bug report. Made it really easy to reproduce and fix. |