workflow-core icon indicating copy to clipboard operation
workflow-core copied to clipboard

DataObjectSerializer serialize DateTimeOffset(as sub Document) gives Object Reference error with camelCase Serialization

Open ajeyaprakash148 opened this issue 3 years ago • 0 comments

Describe the bug DataObjectSerializer serialize DateTimeOffset values. The Property is defined as Document.

To Reproduce Add a CamelCase Servialize Behaviour in startup like below. var conventionPack = new ConventionPack { new CamelCaseElementNameConvention() }; #region MongoDb Registrations BsonSerializer.RegisterSerializer(typeof(DateTimeOffset), new DateTimeOffsetSerializer(MongoDB.Bson.BsonType.Document));

ConventionRegistry.Register("camelCase", conventionPack, t => true); ConventionRegistry.Register("IgnoreIfNull", new ConventionPack { new IgnoreIfNullConvention(true) }, t => true); ConventionRegistry.Register("IgnoreExtra", new ConventionPack { new IgnoreExtraElementsConvention(true) }, t => true);

Expected behavior With camelCasing DataObjectSerializer gives object reference error. var doc = element.Value.AsBsonDocument; doc.Remove("_t"); doc.InsertAt(0, new BsonElement("_t", GetTypeNameFromXPath(value, elementXPath)));

Additional context error is coming in the below line since it is not able to identitfy the camelcased property, because The class property is CreatedDate (as Document), but the serializer considers as "createdDate". var propInfo = value.GetType().GetProperty(subPath); value = propInfo.GetValue(value);

ajeyaprakash148 avatar Sep 20 '21 12:09 ajeyaprakash148