workflow-core
workflow-core copied to clipboard
DataObjectSerializer serialize DateTimeOffset(as sub Document) gives Object Reference error with camelCase Serialization
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);