diff --git a/src/Test/TestCases.Workflows/PowerFxtTests.cs b/src/Test/TestCases.Workflows/PowerFxtTests.cs deleted file mode 100644 index 5abab42a..00000000 --- a/src/Test/TestCases.Workflows/PowerFxtTests.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Shouldly; -using System.Activities; -using System.Activities.Statements; -using Xunit; - -namespace TestCases.Workflows; - -public class PowerFxTests -{ - [Fact] - public void EvaluateExpression() => new WriteLine { Text = new PowerFxValue("1+2*3") }.InvokeWorkflow().ShouldBe("7\r\n"); - [Fact] - public void EvaluateVariables() => new Sequence - { - Variables = { new Variable("one", 1) }, - Activities = { new Sequence { - Variables = { new Variable("two", 2) }, - Activities = { new Sequence - { - Variables = { new Variable("three", 3) }, - Activities = { new WriteLine { Text = new PowerFxValue("Len(20*(one+two*three))") } } - }}}} - }.InvokeWorkflow().ShouldBe("3\r\n"); - [Fact] - public void EvaluateMembers() => new Sequence - { - Variables = { new Variable("assembly", _=>new Name("codeBase", "en-US")) }, - Activities = { new WriteLine { Text = new PowerFxValue("Concatenate(assembly.CodeBase, assembly.CultureName)") } } - }.InvokeWorkflow().ShouldBe("codeBaseen-US\r\n"); - public record Name(string CodeBase, string CultureName) { } -} \ No newline at end of file diff --git a/src/Test/WorkflowApplicationTestExtensions/WorkflowApplicationTestSamples.cs b/src/Test/WorkflowApplicationTestExtensions/WorkflowApplicationTestSamples.cs index 7fe4f0bb..bc5549a7 100644 --- a/src/Test/WorkflowApplicationTestExtensions/WorkflowApplicationTestSamples.cs +++ b/src/Test/WorkflowApplicationTestExtensions/WorkflowApplicationTestSamples.cs @@ -27,7 +27,7 @@ public void RunUntilCompletion_Faulted() Should.Throw(app.RunUntilCompletion); } - [Fact] + [Fact(Skip="Flaky")] public void RunUntilCompletion_Aborted() { var app = new WorkflowApplication(new Delay { Duration = TimeSpan.MaxValue }); diff --git a/src/UiPath.Workflow/Activities/DesignerHelperImpl.cs b/src/UiPath.Workflow/Activities/DesignerHelperImpl.cs index 7dcbb08a..2562db56 100644 --- a/src/UiPath.Workflow/Activities/DesignerHelperImpl.cs +++ b/src/UiPath.Workflow/Activities/DesignerHelperImpl.cs @@ -3,7 +3,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.PowerFx.Core.Public.Values; using Microsoft.VisualBasic.Activities; using System.Activities.ExpressionParser; using System.Activities.Expressions; diff --git a/src/UiPath.Workflow/Activities/PowerFxValue.cs b/src/UiPath.Workflow/Activities/PowerFxValue.cs deleted file mode 100644 index 8fc7052e..00000000 --- a/src/UiPath.Workflow/Activities/PowerFxValue.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Microsoft.PowerFx; -using Microsoft.PowerFx.Core.Public.Values; - -namespace System.Activities; - -public class PowerFxValue : CodeActivity -{ - private static readonly RecalcEngine s_engine = new(); - - public PowerFxValue(string expression) - { - Expression = expression; - } - - public string Expression { get; } - - protected override T Execute(CodeActivityContext context) - { - RecordValue locals; - using (context.InheritVariables()) - { - locals = PowerFxHelper.GetLocals(Parent, local => local.GetLocation(context).Value); - } - - var result = s_engine.Eval(Expression, locals).ToObject(); - return (T) Convert.ChangeType(result, typeof(T)); - } -} - -public static class PowerFxHelper -{ - public static RecordValue GetLocals(Activity parent, Func getValue) - { - var localsValues = new Dictionary(); - foreach (var local in parent.GetLocals()) - { - localsValues.TryAdd(local.Name, FormulaValue.New(getValue(local), local.Type)); - } - - return FormulaValue.RecordFromFields(localsValues.Select(l => new NamedValue(l))); - } -} diff --git a/src/UiPath.Workflow/UiPath.Workflow.csproj b/src/UiPath.Workflow/UiPath.Workflow.csproj index e2631a07..e71fb699 100644 --- a/src/UiPath.Workflow/UiPath.Workflow.csproj +++ b/src/UiPath.Workflow/UiPath.Workflow.csproj @@ -23,7 +23,6 @@ -