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
- Overhaul reflection access for attributed types - Move most of the reflection-based logic to a new type (FirestoreDataAttributedType) - Cache instances of the new type (removing a couple of TODOs) - ... — committed to jskeet/google-cloud-dotnet by jskeet 6 years ago
- Overhaul reflection access for attributed types - Move most of the reflection-based logic to a new type (FirestoreDataAttributedType) - Cache instances of the new type (removing a couple of TODOs) - ... — committed to jskeet/google-cloud-dotnet by jskeet 6 years ago
- Overhaul reflection access for attributed types - Move most of the reflection-based logic to a new type (FirestoreDataAttributedType) - Cache instances of the new type (removing a couple of TODOs) - ... — committed to jskeet/google-cloud-dotnet by jskeet 6 years ago
- Overhaul reflection access for attributed types - Move most of the reflection-based logic to a new type (FirestoreDataAttributedType) - Cache instances of the new type (removing a couple of TODOs) - ... — committed to jskeet/google-cloud-dotnet by jskeet 6 years ago
- Overhaul reflection access for attributed types - Move most of the reflection-based logic to a new type (FirestoreDataAttributedType) - Cache instances of the new type (removing a couple of TODOs) - ... — committed to googleapis/google-cloud-dotnet by jskeet 6 years ago
And also this: http://googleapis.github.io/google-cloud-dotnet/docs/Google.Cloud.Firestore/datamodel.html