TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
210 stars 48 forks source link

Firestore, issue when reading an Integer Dictionary field #319

Open cagriy opened 2 months ago

cagriy commented 2 months ago

I've got a custom User class one of its properties is:

    [FirestoreProperty(nameof(StatsThisMonth))] 
    public Dictionary<string, object> StatsThisMonth { get; set; }

When I add a string,int pair to this dictionary, and write to FireStore, there are no problems, and I can see both the string and integer value on FireStore web UI. However, when I read the object back from FireStore, the dictionary items are populated as string,null instead of string,object.

When I do the same with string, string everything works as expect, the dictionary is written to and retrieved from Firestore as expected.

Below is how I am reading the User from the FireStore in case it is relevant:

            var snapshot = await CrossFirebaseFirestore.Current.GetCollection("Users")
                .WhereEqualsTo(nameof(UserModel.UserId), _firebaseAuth.CurrentUser.Uid)
                .GetDocumentsAsync<UserModel>();

Am I doing something wrong? Or could this be a bug?

Many thanks

AdamEssenmacher commented 2 months ago

Sounds like a bug. Is it the same on both platforms?