google-cloud-dotnet: Firestore - ValueDeserializer fails with NullReferenceException

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.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (1 by maintainers)

Commits related to this issue

Most upvoted comments