Skip to content

Support for nested Dictionary #526

@barrysohl

Description

@barrysohl

In Xamarin, using the f-miyu nuget, we were able to read/write a Dictionary that contained objects of type Dictionary as in the following example:

[FirestoreProperty("Foo")] public Dictionary<string, Dictionary<string, int>> Foo { get; set; }

However, Plugin.Firebase throws an exception when trying to update this field. The exception message and stack trace are below.

We have a huge amount of legacy data in Firestore and need to be able to read/write the existing data structure. Is there any way that support for nested Dictionary can be added to Plugin.Firebase?

Exception:

Couldnt put object of type System.Collections.Generic.Dictionary 2[System.String,System.Int32] into NSDictionary

Stack trace:

at Plugin.Firebase.Firestore.Platforms.iOS.Extensions.DictionaryExtensions.PutIntoNSDictionary(KeyValuePair`2 pair, NSMutableDictionary`2& nsDictionary)
at Plugin.Firebase.Firestore.Platforms.iOS.Extensions.DictionaryExtensions.ToNSDictionaryFromNonGeneric(IDictionary dictionary)
at Plugin.Firebase.Firestore.Platforms.iOS.Extensions.NSObjectExtensions.ToNSObject(Object this)
at Plugin.Firebase.Firestore.Platforms.iOS.Extensions.DictionaryExtensions.ToDictionary(Object this)
at Plugin.Firebase.Firestore.Platforms.iOS.Extensions.NSObjectExtensions.ToNSObject(IFirestoreObject this)
at Plugin.Firebase.Firestore.Platforms.iOS.Extensions.NSObjectExtensions.ToNSObject(Object this)
at Plugin.Firebase.Firestore.Platforms.iOS.Extensions.DictionaryExtensions.<>c.<ToNSObjectDictionary>b__5_1(KeyValuePair`2 x)
at System.Linq.Enumerable.ToDictionary[KeyValuePair`2,Object,Object](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.Enumerable.ToDictionary[KeyValuePair`2,Object,Object](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
at Plugin.Firebase.Firestore.Platforms.iOS.Extensions.DictionaryExtensions.ToNSObjectDictionary(Dictionary`2 this)
at Plugin.Firebase.Firestore.Platforms.iOS.DocumentReferenceWrapper.UpdateDataAsync(Dictionary`2 data)
at DXLib.Data.Model.DXModel.Update(Dictionary`2 data) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions