[CSHARP-265] Serialization of Dictionary<string, T> fails if any key is not a valid element name Created: 08/Jul/11  Updated: 02/Apr/15  Resolved: 13/Jul/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


 Description   

To reproduce:

public class C {
public ObjectId Id;
public Dictionary<string, int> Data;
}

var c = new C { Data = new Dictionary<string, int> {

{ "a.b", 1 }

} };
collection.Insert(c);



 Comments   
Comment by Robert Stam [ 13/Jul/11 ]

DictionarySerializer and DictionaryGenericSerializer now switch to the alternate array representation when any key value is not a valid element name. The client code can also force use of Array or Document representation using serialization options (perhaps for efficiency reasons to skip scanning the keys for validity as element names).

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