diff --git a/src/modules/Elsa.Workflows.Core/Models/ActivityOutputRegister.cs b/src/modules/Elsa.Workflows.Core/Models/ActivityOutputRegister.cs index b0cac5d8e..ad23ec250 100644 --- a/src/modules/Elsa.Workflows.Core/Models/ActivityOutputRegister.cs +++ b/src/modules/Elsa.Workflows.Core/Models/ActivityOutputRegister.cs @@ -6,12 +6,12 @@ namespace Elsa.Workflows.Core.Models; public class ActivityOutputRegister { private readonly ICollection _records = new List(); - + /// /// The default output name. /// public const string DefaultOutputName = "Result"; - + /// /// Records an activity's output. /// @@ -21,7 +21,7 @@ public class ActivityOutputRegister { Record(activityExecutionContext, default, outputValue); } - + /// /// Records an activity's output. /// @@ -33,18 +33,26 @@ public class ActivityOutputRegister var activityId = activityExecutionContext.Activity.Id; var activityInstanceId = activityExecutionContext.Id; var containerId = activityExecutionContext.ParentActivityExecutionContext?.Id ?? activityExecutionContext.WorkflowExecutionContext.Id; - + outputName ??= DefaultOutputName; - var record = new ActivityOutputRecord(containerId, activityId, activityInstanceId, outputName, outputValue); + + // Inspect the output descriptor to see if the specified output name matches any PropertyInfo's name. + // If so, use that descriptor's name instead. + var outputDescriptor = activityExecutionContext.ActivityDescriptor.Outputs.FirstOrDefault(x => x.PropertyInfo?.Name == outputName); + if (outputDescriptor != null) + outputName = outputDescriptor.Name; + + var record = new ActivityOutputRecord(containerId, activityId, activityInstanceId, outputName, outputValue); + _records.Add(record); } - + /// /// Finds all output records matching the specified predicate. /// public IEnumerable FindMany(Func predicate) => _records.Where(predicate); - + /// /// Gets the output value for the specified activity ID. /// diff --git a/src/modules/Elsa.Workflows.Core/Models/InputDescriptor.cs b/src/modules/Elsa.Workflows.Core/Models/InputDescriptor.cs index 087611435..18706a1a4 100644 --- a/src/modules/Elsa.Workflows.Core/Models/InputDescriptor.cs +++ b/src/modules/Elsa.Workflows.Core/Models/InputDescriptor.cs @@ -1,3 +1,4 @@ +using System.Reflection; using Elsa.Workflows.Core.Contracts; namespace Elsa.Workflows.Core.Models; @@ -30,7 +31,8 @@ public class InputDescriptor : PropertyDescriptor bool isReadOnly = false, bool isBrowsable = true, bool isSynthetic = false, - Type? storageDriverType = default) + Type? storageDriverType = default, + PropertyInfo? propertyInfo = default) { Name = name; Type = type; @@ -45,11 +47,11 @@ public class InputDescriptor : PropertyDescriptor Order = order; DefaultValue = defaultValue; DefaultSyntax = defaultSyntax; - //SupportedSyntaxes = supportedSyntaxes?.ToList() ?? new List(); IsReadOnly = isReadOnly; StorageDriverType = storageDriverType; IsSynthetic = isSynthetic; IsBrowsable = isBrowsable; + PropertyInfo = propertyInfo; } /// @@ -81,7 +83,6 @@ public class InputDescriptor : PropertyDescriptor /// The default syntax. /// public string? DefaultSyntax { get; set; } - //public ICollection SupportedSyntaxes { get; set; } = new List(); /// /// True if the input is readonly, false otherwise. diff --git a/src/modules/Elsa.Workflows.Core/Models/OutputDescriptor.cs b/src/modules/Elsa.Workflows.Core/Models/OutputDescriptor.cs index 6021a0d16..69ccc154f 100644 --- a/src/modules/Elsa.Workflows.Core/Models/OutputDescriptor.cs +++ b/src/modules/Elsa.Workflows.Core/Models/OutputDescriptor.cs @@ -1,3 +1,4 @@ +using System.Reflection; using System.Text.Json.Serialization; using Elsa.Workflows.Core.Contracts; @@ -21,8 +22,8 @@ public class OutputDescriptor : PropertyDescriptor Type type, Func valueGetter, Action valueSetter, - - string? description = default, + PropertyInfo? propertyInfo = default, + string? description = default, bool? isBrowsable = default) { Name = name; @@ -32,5 +33,6 @@ public class OutputDescriptor : PropertyDescriptor ValueSetter = valueSetter; Description = description; IsBrowsable = isBrowsable; + PropertyInfo = propertyInfo; } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/Models/PropertyDescriptor.cs b/src/modules/Elsa.Workflows.Core/Models/PropertyDescriptor.cs index a0c3172a2..80a718c98 100644 --- a/src/modules/Elsa.Workflows.Core/Models/PropertyDescriptor.cs +++ b/src/modules/Elsa.Workflows.Core/Models/PropertyDescriptor.cs @@ -1,3 +1,4 @@ +using System.Reflection; using System.Text.Json.Serialization; using Elsa.Workflows.Core.Contracts; @@ -55,4 +56,10 @@ public abstract class PropertyDescriptor /// [JsonIgnore] public Action ValueSetter { get; set; } = default!; + + /// + /// The source of the property, if any. + /// + [JsonIgnore] + public PropertyInfo? PropertyInfo { get; set; } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/Services/ActivityDescriber.cs b/src/modules/Elsa.Workflows.Core/Services/ActivityDescriber.cs index dd9ae374a..ffa458b6b 100644 --- a/src/modules/Elsa.Workflows.Core/Services/ActivityDescriber.cs +++ b/src/modules/Elsa.Workflows.Core/Services/ActivityDescriber.cs @@ -125,6 +125,7 @@ public class ActivityDescriber : IActivityDescriber wrappedPropertyType, propertyInfo.GetValue, propertyInfo.SetValue, + propertyInfo, descriptionAttribute?.Description ?? outputAttribute?.Description, outputAttribute?.IsBrowsable ?? true )); @@ -160,7 +161,10 @@ public class ActivityDescriber : IActivityDescriber _defaultValueResolver.GetDefaultValue(propertyInfo), inputAttribute?.DefaultSyntax, inputAttribute?.IsReadOnly ?? false, - inputAttribute?.IsBrowsable ?? true + inputAttribute?.IsBrowsable ?? true, + false, + default, + propertyInfo ); }