Deserialisation in the ToWorkflowInstance() duplicates List items due to not set ObjectCreationHandling = ObjectCreationHandling.Replace in the JsonSerializerSettings #1270
Hello. I was trying out the Workflow Core library recently and found a bug in the deserialisation in the ToWorkflowInstance() method when using SqlServer as the persistence (which uses the EntityFrameworkPersistenceProvider under the hood).
is duplicating List items due a JsonSerializerSetting, ObjectCreationHandling = ObjectCreationHandling.Replace not set. This in turn, causes all workflow steps to duplicate the items in lists.
More about the ObjectCreationHandling setting here and it's the same problem as described here.
then go into ToWorkflowInstance() and before deserialising assign instance.Data some sample json which contains a list with items, you can use mine, ex.
Step over and you will see the duplicated items in lists. If you use the json I provided above, the expected count for the ApprovedBy is 1 and RequiredApprovers 2, however the counts are getting doubled each time the ToWorkflowInstance() is being called.
I believe the fix is to simply set the ObjectCreationHandling = ObjectCreationHandling.Replace like this:
but as I have a very limited knowledge and understanding of this library I kindly ask for your assistance in evaluating the impacts and/or possible side effects this might have on the rest of the library.
I'm happy to create a pull request for this "bugfix" and cross reference with this thread this afternoon.
Hello. I was trying out the Workflow Core library recently and found a bug in the deserialisation in the ToWorkflowInstance() method when using SqlServer as the persistence (which uses the EntityFrameworkPersistenceProvider under the hood).
Basically,
result.Data = JsonConvert.DeserializeObject(instance.Data, SerializerSettings);
is duplicating List items due a
JsonSerializerSetting
,ObjectCreationHandling = ObjectCreationHandling.Replace
not set. This in turn, causes all workflow steps to duplicate the items in lists.More about the
ObjectCreationHandling
setting here and it's the same problem as described here.To reproduce:
instance.Data
some sample json which contains a list with items, you can use mine, ex.ToWorkflowInstance()
is being called.I believe the fix is to simply set the
ObjectCreationHandling = ObjectCreationHandling.Replace
like this:but as I have a very limited knowledge and understanding of this library I kindly ask for your assistance in evaluating the impacts and/or possible side effects this might have on the rest of the library.
I'm happy to create a pull request for this "bugfix" and cross reference with this thread this afternoon.