-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Error Handling, Serialization
-
None
This ticket is a continuation of the ticket CSHARP-2991.
Now users can configure serialization in this way:
BsonClassMap.RegisterClassMap<Model>(cm => { cm.AutoMap(); cm.MapProperty(c => c.MyDictionary) // MyDictionary is Dictionary<TKey,TValue> .SetSerializer( new DictionaryInterfaceImplementerSerializer<Dictionary<long, Guid>>( DictionaryRepresentation.ArrayOfDocuments)); });
This DictionaryInterfaceImplementerSerializer<TDictionary> using is wrong here since this way is designed to work only with non generic types, like Hashtable and not with Dictionary<TKey,TValue> itself. But this configuration will not trigger any errors and we will see error only in serialization steps which will be not really userfriendly and helpful.
It will be more userfriendly to have a clear error message when they configure custom serialization with DictionaryInterfaceImplementerSerializer before actual deserialization steps.
The message can be like:
For dictionary classes that implement IDictionary<TKey, TValue> use DictionaryInterfaceImplementerSerializer<TDictionary, TKey, TValue> instead of DictionaryInterfaceImplementerSerializer<TDictionary>.
- is related to
-
CSHARP-2991 Regression of CSHARP-1521. ElemMatch requires IBsonArraySerializer for DictionaryInterfaceImplementerSerializer
- Closed