diff --git a/src/Test/TestCases.Workflows/TestXamls/ImproveAssignabilityOutArgumentActivity.xaml b/src/Test/TestCases.Workflows/TestXamls/ImproveAssignabilityOutArgumentActivity.xaml
new file mode 100644
index 000000000..17048dabb
--- /dev/null
+++ b/src/Test/TestCases.Workflows/TestXamls/ImproveAssignabilityOutArgumentActivity.xaml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+ C#
+
+
+
+
+
+
+
+
+
+
+
+ myEnumerable
+
+
+
+
+
+
+
+ dateTimeOutArgument
+
+
+
+
+
+
+
+ nullableDateTimeOutArgument
+
+
+
+
+
+
+
+
+
+ big
+
+
+
+
+ new string('A', 100) ;
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Test/TestCases.Workflows/TestXamls/TestHelper.cs b/src/Test/TestCases.Workflows/TestXamls/TestHelper.cs
index bf6c0a652..7d1a80987 100644
--- a/src/Test/TestCases.Workflows/TestXamls/TestHelper.cs
+++ b/src/Test/TestCases.Workflows/TestXamls/TestHelper.cs
@@ -46,5 +46,6 @@ public enum TestXamls
SpecialCharacters,
ValueSpecialCharacterCSharp,
ValueSpecialCharacterVb,
+ ImproveAssignabilityOutArgumentActivity
}
}
diff --git a/src/Test/TestCases.Workflows/WF4Samples/Expressions.cs b/src/Test/TestCases.Workflows/WF4Samples/Expressions.cs
index e28c386af..6899bf164 100644
--- a/src/Test/TestCases.Workflows/WF4Samples/Expressions.cs
+++ b/src/Test/TestCases.Workflows/WF4Samples/Expressions.cs
@@ -21,7 +21,7 @@ namespace TestCases.Workflows.WF4Samples
{
using StringDictionary = Dictionary;
- public abstract class ExpressionsBase
+ public abstract class ExpressionsBaseCommon
{
protected abstract bool CompileExpressions { get; }
protected Activity GetActivityFromXamlResource(TestXamls xamlName) => TestHelper.GetActivityFromXamlResource(xamlName, CompileExpressions);
@@ -31,6 +31,10 @@ protected Activity Compile(TestXamls xamlName)
Compiler.Run(activity);
return activity;
}
+ }
+
+ public abstract class ExpressionsBase : ExpressionsBaseCommon
+ {
protected const string CorrectOutput = @"John Doe earns $55000.00
Frank Kimono earns $89000.00
Salary statistics: minimum salary is $55000.00, maximum salary is $89000.00, average salary is $72000.00
diff --git a/src/Test/TestCases.Workflows/WF4Samples/ImproveAssignabilityOutArgumentActivity.cs b/src/Test/TestCases.Workflows/WF4Samples/ImproveAssignabilityOutArgumentActivity.cs
new file mode 100644
index 000000000..3d57c3cf4
--- /dev/null
+++ b/src/Test/TestCases.Workflows/WF4Samples/ImproveAssignabilityOutArgumentActivity.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Activities;
+using System.Collections.Generic;
+
+namespace TestCases.Workflows.WF4Samples;
+
+public class ImproveAssignabilityOutArgumentActivity : NativeActivity
+{
+ // OutArgument of type List
+ public OutArgument> Result { get; set; }
+
+ // Additional OutArguments
+ public OutArgument DateTimeOutArgument { get; set; }
+ public OutArgument NullableDateTimeOutArgument { get; set; }
+
+ public ImproveAssignabilityOutArgumentActivity() : base()
+ {
+ }
+
+ protected override void CacheMetadata(NativeActivityMetadata metadata)
+ {
+ // Result
+ var resultArg = new RuntimeArgument(
+ "Result",
+ typeof(List),
+ ArgumentDirection.Out);
+ metadata.Bind(this.Result, resultArg);
+ metadata.AddArgument(resultArg);
+
+ // DateTimeOutArgument
+ var dateTimeArg = new RuntimeArgument(
+ "DateTimeOutArgument",
+ typeof(DateTime),
+ ArgumentDirection.Out);
+ metadata.Bind(this.DateTimeOutArgument, dateTimeArg);
+ metadata.AddArgument(dateTimeArg);
+
+ // NullableDateTimeOutArgument
+ var nullableDateTimeArg = new RuntimeArgument(
+ "NullableDateTimeOutArgument",
+ typeof(DateTime?),
+ ArgumentDirection.Out);
+ metadata.Bind(this.NullableDateTimeOutArgument, nullableDateTimeArg);
+ metadata.AddArgument(nullableDateTimeArg);
+ }
+
+ protected override void Execute(NativeActivityContext context)
+ {
+ var result = new List
+ {
+ "aaa",
+ "bbb",
+ "ccc"
+ };
+
+ Result.Set(context, result);
+ DateTimeOutArgument.Set(context, DateTime.Now);
+ NullableDateTimeOutArgument.Set(context, DateTime.Now);
+ }
+}
diff --git a/src/Test/TestCases.Workflows/WF4Samples/ImproveAssignabilityOutArgumentTests.cs b/src/Test/TestCases.Workflows/WF4Samples/ImproveAssignabilityOutArgumentTests.cs
new file mode 100644
index 000000000..f92e09cb2
--- /dev/null
+++ b/src/Test/TestCases.Workflows/WF4Samples/ImproveAssignabilityOutArgumentTests.cs
@@ -0,0 +1,33 @@
+using Shouldly;
+using System;
+using System.Activities;
+using System.Activities.XamlIntegration;
+using System.Collections.Generic;
+using Xunit;
+
+namespace TestCases.Workflows.WF4Samples;
+
+public class ImproveAssignabilityOutArgumentTests : ExpressionsBaseCommon
+{
+ protected override bool CompileExpressions => true;
+
+ [Fact]
+ public void CompileImproveAssignabilityOutArgumentActivity()
+ {
+ Activity activity = null;
+
+ // Assert that ActivityXamlServices.Load does not throw
+ Should.NotThrow(() =>
+ {
+ activity = ActivityXamlServices.Load(TestHelper.GetXamlStream(TestXamls.ImproveAssignabilityOutArgumentActivity),
+ new ActivityXamlServicesSettings
+ {
+ CompileExpressions = true
+ });
+ });
+
+ var invoker = new WorkflowInvoker(activity);
+ var result = invoker.Invoke();
+ result["myEnumerable"].ShouldBe(new List { "aaa", "bbb", "ccc" });
+ }
+}
diff --git a/src/Test/TestCases.Workflows/WF4Samples/ValueSpecialCharacterTests.cs b/src/Test/TestCases.Workflows/WF4Samples/ValueSpecialCharacterTests.cs
index 8646557a2..7ee099b6e 100644
--- a/src/Test/TestCases.Workflows/WF4Samples/ValueSpecialCharacterTests.cs
+++ b/src/Test/TestCases.Workflows/WF4Samples/ValueSpecialCharacterTests.cs
@@ -19,7 +19,7 @@ namespace TestCases.Workflows.WF4Samples
//4. Assign: output = Dict.First.Key. => we expect the key is "KeyName"
//Results: the output has the unexpected value of "ValueName", instead of "KeyName", but if we enable parameter rename,
//everything works as expected
- public class ValueSpecialCharacterTests : ExpressionsBase
+ public class ValueSpecialCharacterTests : ExpressionsBaseCommon
{
protected override bool CompileExpressions => true;
diff --git a/src/Test/TestCases.Workflows/XamlTests.cs b/src/Test/TestCases.Workflows/XamlTests.cs
index 10fd267b0..a7049e3df 100644
--- a/src/Test/TestCases.Workflows/XamlTests.cs
+++ b/src/Test/TestCases.Workflows/XamlTests.cs
@@ -225,6 +225,16 @@ public async Task CSharp_CompileAnonymousTypes(Type targetType)
Assert.Equal(typeof(IEnumerable