From 2475c251e31a58427486c352ff349f7caa223f34 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Wed, 2 Aug 2023 22:53:54 +0200 Subject: [PATCH] Fix inconsistent input IDs --- .../Services/IdentityGraphService.cs | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/modules/Elsa.Workflows.Core/Services/IdentityGraphService.cs b/src/modules/Elsa.Workflows.Core/Services/IdentityGraphService.cs index 1b5d8584f..4f7571f9b 100644 --- a/src/modules/Elsa.Workflows.Core/Services/IdentityGraphService.cs +++ b/src/modules/Elsa.Workflows.Core/Services/IdentityGraphService.cs @@ -42,8 +42,8 @@ public class IdentityGraphService : IIdentityGraphService { node.Activity.Id = CreateId(node, identityCounters, flattenedList); AssignInputOutputs(node.Activity); - - if(node.Activity is IVariableContainer variableContainer) + + if (node.Activity is IVariableContainer variableContainer) AssignVariables(variableContainer); } } @@ -52,32 +52,32 @@ public class IdentityGraphService : IIdentityGraphService public void AssignInputOutputs(IActivity activity) { var activityDescriptor = _activityRegistry.Find(activity.Type, activity.Version) ?? throw new Exception("Activity descriptor not found"); - var inputs = activityDescriptor.GetWrappedInputProperties(activity).Values.Where(x => x != null).Cast().ToList(); + var inputs = activityDescriptor.GetWrappedInputProperties(activity).Values.Cast().ToList(); var seed = 0; foreach (var input in inputs) { - var blockReference = input.MemoryBlockReference(); - - if(string.IsNullOrEmpty(blockReference.Id)) - blockReference.Id = $"{activity.Id}:input-{++seed}"; + var blockReference = input?.MemoryBlockReference(); + + if (blockReference != null!) + if (string.IsNullOrEmpty(blockReference.Id)) + blockReference.Id = $"{activity.Id}:input-{seed}"; + + seed++; } seed = 0; var outputs = activity.GetOutputs(); - - var assignedOutputs = outputs.Where(x => - { - var memoryBlockReference = x.Value.MemoryBlockReference(); - return memoryBlockReference != null! && memoryBlockReference.Id == null!; - }).ToList(); - foreach (var output in assignedOutputs) + foreach (var output in outputs) { var blockReference = output.Value.MemoryBlockReference(); - - if(string.IsNullOrEmpty(blockReference.Id)) - blockReference.Id = $"{activity.Id}:output-{++seed}"; + + if (blockReference != null!) + if (string.IsNullOrEmpty(blockReference.Id)) + blockReference.Id = $"{activity.Id}:output-{seed}"; + + seed++; } }