Firestore : System.ArgumentException: Do not know how to marshal object of type 'Plugin.Firebase.Firestore.FieldValue' to an NSObject
See original GitHub issueHi @TobiasBuchholz , I am currently doing some tests about your Firestore “Update” methods, so that I can just “patch” specific fields instead of completely overwriting my object on Firestore.
While this methods works great : myDocumentReference.UpdateDataAsync(updates);
, it doesn’t work anymore in a transaction context for some types like IEnumerable, FieldValue, … The error says it cannot “marshal” to an NSObject.
await CrossFirebaseFirestore.Current.RunTransactionAsync(transaction =>
{
transaction.UpdateData(myDocumentReference, updates);
return true;
});
.....
.....
var batch = CrossFirebaseFirestore.Current.CreateBatch();
batch.UpdateData(myDocumentReference, updates);
await batch.CommitAsync();
StackTrace
System.ArgumentException: Do not know how to marshal object of type 'Plugin.Firebase.Firestore.FieldValue' to an NSObject
at Foundation.NSArray.From[T] (T[] items, System.Int64 count) [0x0005c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/15.12.0.2/src/Xamarin.iOS/Foundation/NSArray.cs:153
at Foundation.NSArray.FromObjects (System.nint count, System.Object[] items) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/15.12.0.2/src/Xamarin.iOS/Foundation/NSArray.cs:136
at Foundation.NSDictionary`2[TKey,TValue].FromObjectsAndKeys (System.Object[] objects, System.Object[] keys, System.nint count) [0x00068] in /Library/Frameworks/Xamarin.iOS.framework/Versions/15.12.0.2/src/Xamarin.iOS/Foundation/NSDictionary_2.cs:235
at Firebase.CloudFirestore.WriteBatch.UpdateData (System.Collections.Generic.Dictionary`2[TKey,TValue] fields, Firebase.CloudFirestore.DocumentReference document) [0x0002a] in <6138d74f602843c4a14bce9b56ce2700>:0
at Plugin.Firebase.iOS.Firestore.WriteBatchWrapper.UpdateData (Plugin.Firebase.Firestore.IDocumentReference document, System.ValueTuple`2[System.String,System.Object][] data) [0x00012] in <af590805f88345db8c9a66cd819c17d8>:0
Setup
Visual Studio Community 2022 for Mac (17.3) Xamarin.iOS (15.12.0.2) Xamarin.Forms (5.0.0.2478) Plugin.Firebase V1.1.2
Note : I didn’t try on Android yet.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How do you deserialise Firestore FieldValues in Android?
I have a Kotlin data class that effortlessly adds a Firestore server upload timestamp to an object when it's saved as a document...
Read more >Add data to Cloud Firestore - Firebase - Google
There are several ways to write data to Cloud Firestore: Set the data of a document within a collection, explicitly specifying a document...
Read more >The secrets of Firestore's FieldValue.serverTimestamp()
Everything you need to know about Firestore server timestamps, including writes, queries, security rules, and time travel safety tips.
Read more >Adding data | Firestore
There are several ways to write data to Firestore: Set the data of a document within a collection, explicitly specifying a document identifier....
Read more >Cloud Firestore
Firestore is a flexible, scalable NoSQL cloud database to store and sync data. It keeps your data in sync across client apps through...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @Kapusch, there was indeed a problem, on android as well. I’ve created a fix for that issue and committed it to the development branch, so it will be available in the next version.
@Kapusch I’ve created a new version 1.1.5 which should fix that issue.