Firestore - ValueDeserializer fails with NullReferenceException
See original GitHub issueI 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:
- Created 5 years ago
- Comments:17 (1 by maintainers)
And also this: http://googleapis.github.io/google-cloud-dotnet/docs/Google.Cloud.Firestore/datamodel.html
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: