TobiasBuchholz / Plugin.Firebase

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

Access JsonSerializationOptions? #348

Closed barrysohl closed 1 month ago

barrysohl commented 1 month ago

We have a really large Xamarin project that we are moving to MAUI. Data persistence is entirely based on Firestore. We were previously using f-miyu/Plugin.CloudFirestore, which worked well for us. We are having a hard time migrating to Plugin.Firebase.Firestore.

Our latest issue is System.Text.JsonException: A possible object cycle was detected exceptions, which we did not receive before. We understand that we can configure the handling of this using JsonSerializationOptions.ReferenceHandler. But we can't figure out how to pass those options into Plugin.Firebase.Firestore. Is there a way to configure this option? Thanks in advance!

AdamEssenmacher commented 1 month ago

A stack trace and/or repro gist or project would be helpful.

barrysohl commented 1 month ago

We were able to workaround/resolve this one. Rather than rely on JsonSerializationOptions.ReferenceHandler, we used [JsonIgnore] to break the cycle. We initially hit a snag when our IDE added a 'using' for the attribute from NewtonSoft rather than System.Text, which did NOT work. I am not entirely sure why Firebase.Firestore is worried about serializing the entire object rather than just [FirestoreProperty] properties, but at least it's working now.

Now we're left with our other two show-stopper issues (tickets posted). Thanks for looking at this one!