From 7479ff1210a33a5ddd8d06c8503bf81b60e3c2b2 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Mon, 26 Jul 2021 13:10:41 +0200 Subject: [PATCH] Prevent custom composite activities from overriding values specified by the activity definition This particularly fixes the issue where a composite activity can potentially specify its own activity ID, which would break the workflow since the activity definition ID (as generated by the designer) would be different. --- .../WorkflowBlueprintMaterializer.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core/Elsa.Core/Services/Workflows/WorkflowBlueprintMaterializer.cs b/src/core/Elsa.Core/Services/Workflows/WorkflowBlueprintMaterializer.cs index 920bc5f36..17cd68e77 100644 --- a/src/core/Elsa.Core/Services/Workflows/WorkflowBlueprintMaterializer.cs +++ b/src/core/Elsa.Core/Services/Workflows/WorkflowBlueprintMaterializer.cs @@ -155,19 +155,19 @@ namespace Elsa.Services.Workflows else if (typeof(CompositeActivity).IsAssignableFrom(activityType.Type)) { var compositeActivity = (CompositeActivity) ActivatorUtilities.CreateInstance(_serviceProvider, activityType.Type); - var compositeActivityBuilder = new CompositeActivityBuilder(_serviceProvider, _startingActivitiesProvider, activityType.Type, activityType.TypeName) - { - ActivityId = activityDefinition.ActivityId, - Name = activityDefinition.Name, - DisplayName = activityDefinition.DisplayName, - Description = activityDefinition.Description, - PersistWorkflowEnabled = activityDefinition.PersistWorkflow, - LoadWorkflowContextEnabled = activityDefinition.LoadWorkflowContext, - SaveWorkflowContextEnabled = activityDefinition.SaveWorkflowContext, - PropertyStorageProviders = activityDefinition.PropertyStorageProviders - }; + var compositeActivityBuilder = new CompositeActivityBuilder(_serviceProvider, _startingActivitiesProvider, activityType.Type, activityType.TypeName); compositeActivity.Build(compositeActivityBuilder); + + // Ensure the composite activity is assigned the same properties as the activity definition referencing this activity. + compositeActivityBuilder.ActivityId = activityDefinition.ActivityId; + compositeActivityBuilder.Name = activityDefinition.Name; + compositeActivityBuilder.DisplayName = activityDefinition.DisplayName; + compositeActivityBuilder.Description = activityDefinition.Description; + compositeActivityBuilder.PersistWorkflowEnabled = activityDefinition.PersistWorkflow; + compositeActivityBuilder.LoadWorkflowContextEnabled = activityDefinition.LoadWorkflowContext; + compositeActivityBuilder.SaveWorkflowContextEnabled = activityDefinition.SaveWorkflowContext; + compositeActivityBuilder.PropertyStorageProviders = activityDefinition.PropertyStorageProviders; var compositeActivityBlueprint = compositeActivityBuilder.Build($"{activityDefinition.ActivityId}:activity");