question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firestore - ValueDeserializer fails with NullReferenceException

See original GitHub issue

I have found an issue when using Firestore (currently 1.0.0-beta08) in my C# project. Calling ConvertTo<T>() from a document snapshot fails when T has a property with FirestorePropertyAttribute that has a non-public setter.

The exception is System.NullReferenceException: 'Object reference not set to an instance of an object.' System.Reflection.PropertyInfo.GetSetMethod(...) returned null. It is coming from ValueDeserializer.DeserializeMap() from the linq query targetType.GetTypeInfo().DeclaredProperties.Where(p => p.CanWrite && p.GetSetMethod().IsPublic && !p.GetSetMethod().IsStatic).

My main concern is actually the design. The API is intentionally looking for a public setter. That does not seem to be the best approach when it comes to mapping/converting persistent data to/from POCO classes. It is natural for domain entities in many cases to have non-public setters in order to provide non-anemic domain entities while maintaining compatibility with ORMs and other mappers.

I believe the behavior should be at least configurable.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

0reactions
jskeetcommented, Nov 21, 2018

Enums should just work, unless I neglected them accidentally. If so, please file a new issue as we’re now a very long way from this original issue.

On Wed, 21 Nov 2018, 17:21 Morten Andersen <notifications@github.com wrote:

Ok, I got it working except for enums. Is there another attribute for enums? FirestoreData is for class only.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/googleapis/google-cloud-dotnet/issues/2477#issuecomment-440725631, or mute the thread https://github.com/notifications/unsubscribe-auth/AABCc-SVzBSmAM2u4yw4u1H1zLhEOgpTks5uxX2PgaJpZM4Wb6E2 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Null value error" in firestore simulator - firebase
The problem is that there's no actual document at /cities/moscow.
Read more >
Firebase.Firestore.DocumentReference Class Reference
The path to the collection, relative to this document. Must not be null , and must contain an odd number of slash-separated path...
Read more >
Securely query data | Firestore - Firebase - Google
The query fails even if the current user actually is the author of every story document. The reason for this behavior is that...
Read more >
Getting data | Firestore
There are three ways to retrieve data stored in Firestore. Any of these methods can be used with documents, collections of documents, or...
Read more >
NullReferenceException: Object reference not set to an ...
It does not upload it to the database and it appears in console this Error NullReferenceException: Object reference not set to an instance...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found