Firestore - DocumentSnapshot.ConvertTo fails with ArgumentException
See original GitHub issueI have found an interesting issue when using Firestore (currently 1.0.0-beta08) in my C# project. Calling ConvertTo<T>()
from a document snapshot fails when T does not contain properties to accommodate all document’s fields. An ArgumentException is thrown in this case.
This is how the issue can be reproduced:
Given the following POCO class:
[FirestoreData()]
private class MyDocument
{
[FirestoreProperty()]
public string Name { get; set; }
}
And the following Firestore document:
{
"Name": "Some Name",
"LastName": "Some Last Name"
}
An ArgumentException is thrown when calling:
var myDocument = documentSnapshot.ConvertTo<MyDocument>();
If this behavior has been intentionally implemented, it should be at least configurable (either by passing an argument to ConvertTo<T>() or by providing parameters to FirestoreDataAttribute). It completely breaks the flexibility of a document database, since adding new fields to the documents forcibly requires changing the code base. Backwards compatibility becomes then a hard task if not impossible.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7
@mikenlanggio: It looks like that isn’t using the Google.Cloud.Firestore library which is in this repo, but Firebase.Firestore, which is a separate codebase, supported by the Firebase team. I suggest you follow the steps in the Firebase support page - I’m afraid there are too many possibility for a Unity-specific or Firebase.Firestore-specific problem for me to help here.
Thank you for your quick reply. Have a nice day ^^