diff --git a/src/modules/Elsa.Workflows.Core/Activities/While.cs b/src/modules/Elsa.Workflows.Core/Activities/While.cs index ec2f85eeb..dc998be41 100644 --- a/src/modules/Elsa.Workflows.Core/Activities/While.cs +++ b/src/modules/Elsa.Workflows.Core/Activities/While.cs @@ -5,6 +5,7 @@ using Elsa.Workflows.Attributes; using Elsa.Workflows.Behaviors; using Elsa.Workflows.Contracts; using Elsa.Workflows.Models; +using Elsa.Workflows.UIHints; using JetBrains.Annotations; namespace Elsa.Workflows.Activities; @@ -69,7 +70,7 @@ public class While : Activity /// /// The condition to evaluate. /// - [Input(AutoEvaluate = false)] + [Input(AutoEvaluate = false, UIHint = InputUIHints.SingleLine)] public Input Condition { get; set; } = new(false); /// diff --git a/src/modules/Elsa.Workflows.Core/Serialization/Converters/InputJsonConverter.cs b/src/modules/Elsa.Workflows.Core/Serialization/Converters/InputJsonConverter.cs index abd643cd7..f7d194fca 100644 --- a/src/modules/Elsa.Workflows.Core/Serialization/Converters/InputJsonConverter.cs +++ b/src/modules/Elsa.Workflows.Core/Serialization/Converters/InputJsonConverter.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; using Elsa.Expressions.Contracts; @@ -24,6 +25,7 @@ public class InputJsonConverter : JsonConverter> public override bool CanConvert(Type typeToConvert) => typeof(Input).IsAssignableFrom(typeToConvert); /// + [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] public override Input Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (!JsonDocument.TryParseValue(ref reader, out var doc)) @@ -42,11 +44,17 @@ public class InputJsonConverter : JsonConverter> var memoryBlockReference = expressionDescriptor?.MemoryBlockReferenceFactory(); var memoryBlockReferenceType = memoryBlockReference?.GetType(); var expressionValueElement = expressionElement.TryGetProperty("value", out var expressionElementValueValue) ? expressionElementValueValue : default; - var expressionValue = expressionValueElement.ValueKind == JsonValueKind.String - ? expressionValueElement.GetString() - : expressionValueElement.ValueKind != JsonValueKind.Undefined && memoryBlockReferenceType != null - ? expressionValueElement.Deserialize(memoryBlockReferenceType, options)! - : default; + + var expressionValue = expressionValueElement.ValueKind switch + { + JsonValueKind.String => expressionValueElement.GetString(), + JsonValueKind.False => false, + JsonValueKind.True => true, + JsonValueKind.Number => expressionValueElement.GetDouble(), + JsonValueKind.Undefined => default, + _ => memoryBlockReferenceType != null ? expressionValueElement.Deserialize(memoryBlockReferenceType, options)! : default + }; + var expression = new Expression(expressionTypeName, expressionValue); if (memoryBlockReference == null)