diff --git a/Directory.Packages.props b/Directory.Packages.props
new file mode 100644
index 000000000..babad6bc2
--- /dev/null
+++ b/Directory.Packages.props
@@ -0,0 +1,120 @@
+
+
+
+ true
+
+
+
+
+
+ 3.1.2
+ 5.0.1
+ 3.1.2
+ 6.0.0
+ 8.0.0
+
+
+ 3.1.2
+ 3.1.2
+ 3.1.2
+ 6.0.0
+ 8.0.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WorkflowCore.sln b/WorkflowCore.sln
index e7fb81a2e..e22210e7a 100644
--- a/WorkflowCore.sln
+++ b/WorkflowCore.sln
@@ -1,12 +1,13 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.29509.3
+# Visual Studio Version 17
+VisualStudioVersion = 17.9.34518.117
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EF47161E-E399-451C-BDE8-E92AAD3BD761}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F6AC9AEB-24EF-475A-B190-AA4D9E01270A}"
ProjectSection(SolutionItems) = preProject
+ Directory.Packages.props = Directory.Packages.props
README.md = README.md
EndProjectSection
EndProject
diff --git a/src/WorkflowCore.DSL/WorkflowCore.DSL.csproj b/src/WorkflowCore.DSL/WorkflowCore.DSL.csproj
index 94765a53e..9fb38d853 100644
--- a/src/WorkflowCore.DSL/WorkflowCore.DSL.csproj
+++ b/src/WorkflowCore.DSL/WorkflowCore.DSL.csproj
@@ -1,7 +1,7 @@
-
+
- netstandard2.0
+ netstandard2.0;net8.0DSL extenstion for Workflow Core provding support for JSON and YAML workflow definitions.Daniel Gerlag
@@ -9,9 +9,9 @@
-
-
-
+
+
+
diff --git a/src/WorkflowCore.Testing/WorkflowCore.Testing.csproj b/src/WorkflowCore.Testing/WorkflowCore.Testing.csproj
index 6102c9892..274db77cb 100644
--- a/src/WorkflowCore.Testing/WorkflowCore.Testing.csproj
+++ b/src/WorkflowCore.Testing/WorkflowCore.Testing.csproj
@@ -1,7 +1,7 @@
- netstandard2.0
+ netstandard2.0;netstandard2.1;net6.0;net8.03.5.23.5.2.03.5.2.0
@@ -9,9 +9,7 @@
-
-
-
+
diff --git a/src/WorkflowCore/Interface/IContainerStepBuilder.cs b/src/WorkflowCore/Interface/IContainerStepBuilder.cs
index 1d52bf2c8..bed0d7cd7 100644
--- a/src/WorkflowCore/Interface/IContainerStepBuilder.cs
+++ b/src/WorkflowCore/Interface/IContainerStepBuilder.cs
@@ -1,8 +1,19 @@
using System;
+#if NET8_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
namespace WorkflowCore.Interface
{
- public interface IContainerStepBuilder
+ public interface IContainerStepBuilder
where TStepBody : IStepBody
where TReturnStep : IStepBody
{
diff --git a/src/WorkflowCore/Interface/IParallelStepBuilder.cs b/src/WorkflowCore/Interface/IParallelStepBuilder.cs
index 572058fc8..e217c63de 100644
--- a/src/WorkflowCore/Interface/IParallelStepBuilder.cs
+++ b/src/WorkflowCore/Interface/IParallelStepBuilder.cs
@@ -1,9 +1,16 @@
using System;
+#if NET8_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
using WorkflowCore.Primitives;
namespace WorkflowCore.Interface
{
- public interface IParallelStepBuilder
+ public interface IParallelStepBuilder
where TStepBody : IStepBody
{
IParallelStepBuilder Do(Action> builder);
diff --git a/src/WorkflowCore/Interface/IStepBody.cs b/src/WorkflowCore/Interface/IStepBody.cs
index cc786fd87..16252b7d9 100644
--- a/src/WorkflowCore/Interface/IStepBody.cs
+++ b/src/WorkflowCore/Interface/IStepBody.cs
@@ -4,7 +4,7 @@
namespace WorkflowCore.Interface
{
public interface IStepBody
- {
- Task RunAsync(IStepExecutionContext context);
+ {
+ Task RunAsync(IStepExecutionContext context);
}
}
diff --git a/src/WorkflowCore/Interface/IStepBuilder.cs b/src/WorkflowCore/Interface/IStepBuilder.cs
index e20d585c5..94644a3ec 100644
--- a/src/WorkflowCore/Interface/IStepBuilder.cs
+++ b/src/WorkflowCore/Interface/IStepBuilder.cs
@@ -1,14 +1,20 @@
using System;
+#if NET8_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
using System.Linq.Expressions;
using WorkflowCore.Models;
namespace WorkflowCore.Interface
{
- public interface IStepBuilder : IWorkflowModifier
+ public interface IStepBuilder : IWorkflowModifier
where TStepBody : IStepBody
{
-
- IWorkflowBuilder WorkflowBuilder { get; }
+ IWorkflowBuilder WorkflowBuilder { get; }
WorkflowStep Step { get; set; }
@@ -46,14 +52,22 @@ public interface IStepBuilder : IWorkflowModifier
///
///
- IStepBuilder Branch(object outcomeValue, IStepBuilder branch) where TStep : IStepBody;
+ IStepBuilder Branch<
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+#endif
+ TStep>(object outcomeValue, IStepBuilder branch) where TStep : IStepBody;
///
/// Configure an outcome branch for this step, then wire it to another step
///
///
///
- IStepBuilder Branch(Expression> outcomeExpression, IStepBuilder branch) where TStep : IStepBody;
+ IStepBuilder Branch<
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+#endif
+ TStep>(Expression> outcomeExpression, IStepBuilder branch) where TStep : IStepBody;
///
/// Map properties on the step to properties on the workflow data object before the step executes
@@ -97,7 +111,11 @@ public interface IStepBuilder : IWorkflowModifier
IStepBuilder Output(Action action);
- IStepBuilder End(string name) where TStep : IStepBody;
+ IStepBuilder End<
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+#endif
+ TStep>(string name) where TStep : IStepBody;
///
/// Configure the behavior when this step throws an unhandled exception
@@ -119,7 +137,11 @@ public interface IStepBuilder : IWorkflowModifierThe type of the step to execute
/// Configure additional parameters for this step
///
- IStepBuilder CompensateWith(Action> stepSetup = null) where TStep : IStepBody;
+ IStepBuilder CompensateWith<
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+#endif
+ TStep>(Action> stepSetup = null) where TStep : IStepBody;
///
/// Undo step if unhandled exception is thrown by this step
diff --git a/src/WorkflowCore/Interface/IStepOutcomeBuilder.cs b/src/WorkflowCore/Interface/IStepOutcomeBuilder.cs
index 0145ca1db..234ecf52f 100644
--- a/src/WorkflowCore/Interface/IStepOutcomeBuilder.cs
+++ b/src/WorkflowCore/Interface/IStepOutcomeBuilder.cs
@@ -1,18 +1,29 @@
using System;
+#if NET8_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
using WorkflowCore.Models;
using WorkflowCore.Primitives;
namespace WorkflowCore.Interface
-{
+{
public interface IStepOutcomeBuilder
{
IWorkflowBuilder WorkflowBuilder { get; }
ValueOutcome Outcome { get; }
- IStepBuilder Then(Action> stepSetup = null) where TStep : IStepBody;
+ IStepBuilder Then<
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+#endif
+ TStep>(Action> stepSetup = null) where TStep : IStepBody;
- IStepBuilder Then(IStepBuilder step) where TStep : IStepBody;
+ IStepBuilder Then<
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+#endif
+ TStep>(IStepBuilder step) where TStep : IStepBody;
IStepBuilder Then(Func body);
diff --git a/src/WorkflowCore/Interface/IWorkflowBuilder.cs b/src/WorkflowCore/Interface/IWorkflowBuilder.cs
index b7b371882..6477e1475 100644
--- a/src/WorkflowCore/Interface/IWorkflowBuilder.cs
+++ b/src/WorkflowCore/Interface/IWorkflowBuilder.cs
@@ -1,4 +1,7 @@
using System;
+#if NET8_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
using System.Collections.Generic;
using WorkflowCore.Models;
using WorkflowCore.Primitives;
@@ -11,7 +14,11 @@ public interface IWorkflowBuilder
int LastStep { get; }
- IWorkflowBuilder UseData();
+ IWorkflowBuilder UseData<
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+#endif
+ T>();
WorkflowDefinition Build(string id, int version);
@@ -22,7 +29,11 @@ public interface IWorkflowBuilder
public interface IWorkflowBuilder : IWorkflowBuilder, IWorkflowModifier
{
- IStepBuilder StartWith(Action> stepSetup = null) where TStep : IStepBody;
+ IStepBuilder StartWith<
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+#endif
+ TStep>(Action> stepSetup = null) where TStep : IStepBody;
IStepBuilder StartWith(Func body);
diff --git a/src/WorkflowCore/Interface/IWorkflowController.cs b/src/WorkflowCore/Interface/IWorkflowController.cs
index 924925d2c..fb4cba296 100644
--- a/src/WorkflowCore/Interface/IWorkflowController.cs
+++ b/src/WorkflowCore/Interface/IWorkflowController.cs
@@ -1,5 +1,9 @@
using System;
+#if NET8_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
using System.Threading.Tasks;
+using Microsoft.Extensions.DependencyInjection;
namespace WorkflowCore.Interface
{
@@ -11,8 +15,16 @@ public interface IWorkflowController
Task StartWorkflow(string workflowId, int? version, TData data = null, string reference=null) where TData : class, new();
Task PublishEvent(string eventName, string eventKey, object eventData, DateTime? effectiveDate = null);
- void RegisterWorkflow() where TWorkflow : IWorkflow;
- void RegisterWorkflow() where TWorkflow : IWorkflow where TData : new();
+ void RegisterWorkflow<
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
+#endif
+ TWorkflow>() where TWorkflow : IWorkflow;
+ void RegisterWorkflow<
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
+#endif
+ TWorkflow, TData>() where TWorkflow : IWorkflow where TData : new();
///
/// Suspend the execution of a given workflow until .ResumeWorkflow is called
@@ -29,11 +41,10 @@ public interface IWorkflowController
Task ResumeWorkflow(string workflowId);
///
- /// Permanently terminate the exeuction of a given workflow
+ /// Permanently terminate the execution of a given workflow
///
///
///
Task TerminateWorkflow(string workflowId);
-
}
}
diff --git a/src/WorkflowCore/Interface/IWorkflowModifier.cs b/src/WorkflowCore/Interface/IWorkflowModifier.cs
index 835855e97..4deee79fe 100644
--- a/src/WorkflowCore/Interface/IWorkflowModifier.cs
+++ b/src/WorkflowCore/Interface/IWorkflowModifier.cs
@@ -1,4 +1,7 @@
using System;
+#if NET8_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
using System.Collections;
using System.Linq.Expressions;
using WorkflowCore.Models;
@@ -6,182 +9,207 @@
namespace WorkflowCore.Interface
{
- public interface IWorkflowModifier
+ public interface IWorkflowModifier
where TStepBody : IStepBody
{
- ///
- /// Specify the next step in the workflow
- ///
- /// The type of the step to execute
- /// Configure additional parameters for this step
- ///
- IStepBuilder Then(Action> stepSetup = null) where TStep : IStepBody;
-
- ///
- /// Specify the next step in the workflow
- ///
- ///
- ///
- ///
- IStepBuilder Then(IStepBuilder newStep) where TStep : IStepBody;
-
- ///
- /// Specify an inline next step in the workflow
- ///
- ///
- ///
- IStepBuilder Then(Func body);
-
- ///
- /// Specify an inline next step in the workflow
- ///
- ///
- ///
- IStepBuilder Then(Action body);
-
- ///
- /// Wait here until to specified event is published
- ///
- /// The name used to identify the kind of event to wait for
- /// A specific key value within the context of the event to wait for
- /// Listen for events as of this effective date
- /// A conditon that when true will cancel this WaitFor
- ///
- IStepBuilder WaitFor(string eventName, Expression> eventKey,
- Expression> effectiveDate = null, Expression> cancelCondition = null);
-
- ///
- /// Wait here until to specified event is published
- ///
- /// The name used to identify the kind of event to wait for
- /// A specific key value within the context of the event to wait for
- /// Listen for events as of this effective date
- /// A conditon that when true will cancel this WaitFor
- ///
- IStepBuilder WaitFor(string eventName,
- Expression> eventKey,
- Expression> effectiveDate = null, Expression> cancelCondition = null);
-
- ///
- /// Wait for a specified period
- ///
- ///
- ///
- IStepBuilder Delay(Expression> period);
-
- ///
- /// Evaluate an expression and take a different path depending on the value
- ///
- /// Expression to evaluate for decision
- ///
- IStepBuilder Decide(Expression> expression);
-
- ///
- /// Execute a block of steps, once for each item in a collection in a parallel foreach
- ///
- /// Resolves a collection for iterate over
- ///
- IContainerStepBuilder ForEach(Expression> collection);
-
- ///
- /// Execute a block of steps, once for each item in a collection in a RunParallel foreach
- ///
- /// Resolves a collection for iterate over
- ///
- IContainerStepBuilder ForEach(Expression> collection, Expression> runParallel);
-
- ///
- /// Execute a block of steps, once for each item in a collection in a RunParallel foreach
- ///
- /// Resolves a collection for iterate over
- ///
- IContainerStepBuilder ForEach(Expression> collection, Expression> runParallel);
-
- ///
- /// Repeat a block of steps until a condition becomes true
- ///
- /// Resolves a condition to break out of the while loop
- ///
- IContainerStepBuilder While(Expression> condition);
-
- ///
- /// Repeat a block of steps until a condition becomes true
- ///
- /// Resolves a condition to break out of the while loop
- ///
- IContainerStepBuilder While(Expression> condition);
-
- ///
- /// Execute a block of steps if a condition is true
- ///
- /// Resolves a condition to evaluate
- ///
- IContainerStepBuilder If(Expression> condition);
-
- ///
- /// Execute a block of steps if a condition is true
- ///
- /// Resolves a condition to evaluate
- ///
- IContainerStepBuilder If(Expression> condition);
-
- ///
- /// Configure an outcome for this step, then wire it to a sequence
- ///
- ///
- ///
- IContainerStepBuilder When(Expression> outcomeValue,
- string label = null);
-
- ///
- /// Execute multiple blocks of steps in parallel
- ///
- ///
- IParallelStepBuilder Parallel();
-
- ///
- /// Execute a sequence of steps in a container
- ///
- ///
- IStepBuilder Saga(Action> builder);
-
- ///
- /// Schedule a block of steps to execute in parallel sometime in the future
- ///
- /// The time span to wait before executing the block
- ///
- IContainerStepBuilder Schedule(Expression> time);
-
- ///
- /// Schedule a block of steps to execute in parallel sometime in the future at a recurring interval
- ///
- /// The time span to wait between recurring executions
- /// Resolves a condition to stop the recurring task
- ///
- IContainerStepBuilder Recur(Expression> interval,
- Expression> until);
-
- ///
- /// Wait here until an external activity is complete
- ///
- /// The name used to identify the activity to wait for
- /// The data to pass the external activity worker
- /// Listen for events as of this effective date
- /// A conditon that when true will cancel this WaitFor
- ///
- IStepBuilder Activity(string activityName, Expression> parameters = null,
- Expression> effectiveDate = null, Expression> cancelCondition = null);
-
- ///
- /// Wait here until an external activity is complete
- ///
- /// The name used to identify the activity to wait for
- /// The data to pass the external activity worker
- /// Listen for events as of this effective date
- /// A conditon that when true will cancel this WaitFor
- ///
- IStepBuilder Activity(Expression> activityName, Expression> parameters = null,
- Expression> effectiveDate = null, Expression> cancelCondition = null);
+ ///
+ /// Specify the next step in the workflow
+ ///
+ /// The type of the step to execute
+ /// Configure additional parameters for this step
+ ///
+ IStepBuilder Then<
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+#endif
+ TStep>(Action> stepSetup = null) where TStep : IStepBody;
+
+ ///
+ /// Specify the next step in the workflow
+ ///
+ ///
+ ///
+ ///
+ IStepBuilder Then<
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+#endif
+ TStep>(IStepBuilder newStep) where TStep : IStepBody;
+
+ ///
+ /// Specify an inline next step in the workflow
+ ///
+ ///
+ ///
+ IStepBuilder Then(Func body);
+
+ ///
+ /// Specify an inline next step in the workflow
+ ///
+ ///
+ ///
+ IStepBuilder Then(Action body);
+
+ ///
+ /// Wait here until to specified event is published
+ ///
+ /// The name used to identify the kind of event to wait for
+ /// A specific key value within the context of the event to wait for
+ /// Listen for events as of this effective date
+ /// A condition that when true will cancel this WaitFor
+ ///
+ IStepBuilder WaitFor(
+ string eventName, Expression> eventKey,
+ Expression> effectiveDate = null,
+ Expression> cancelCondition = null);
+
+ ///
+ /// Wait here until to specified event is published
+ ///
+ /// The name used to identify the kind of event to wait for
+ /// A specific key value within the context of the event to wait for
+ /// Listen for events as of this effective date
+ /// A condition that when true will cancel this WaitFor
+ ///
+ IStepBuilder WaitFor(string eventName,
+ Expression> eventKey,
+ Expression> effectiveDate = null,
+ Expression> cancelCondition = null);
+
+ ///
+ /// Wait for a specified period
+ ///
+ ///
+ ///
+ IStepBuilder Delay(Expression> period);
+
+ ///
+ /// Evaluate an expression and take a different path depending on the value
+ ///
+ /// Expression to evaluate for decision
+ ///
+ IStepBuilder Decide(Expression> expression);
+
+ ///
+ /// Execute a block of steps, once for each item in a collection in a parallel foreach
+ ///
+ /// Resolves a collection for iterate over
+ ///
+ IContainerStepBuilder ForEach(Expression> collection);
+
+ ///
+ /// Execute a block of steps, once for each item in a collection in a RunParallel foreach
+ ///
+ /// Resolves a collection for iterate over
+ ///
+ IContainerStepBuilder ForEach(
+ Expression> collection,
+ Expression> runParallel);
+
+ ///
+ /// Execute a block of steps, once for each item in a collection in a RunParallel foreach
+ ///
+ /// Resolves a collection for iterate over
+ ///
+ IContainerStepBuilder ForEach(
+ Expression> collection,
+ Expression> runParallel);
+
+ ///
+ /// Repeat a block of steps until a condition becomes true
+ ///
+ /// Resolves a condition to break out of the while loop
+ ///
+ IContainerStepBuilder While(Expression> condition);
+
+ ///
+ /// Repeat a block of steps until a condition becomes true
+ ///
+ /// Resolves a condition to break out of the while loop
+ ///
+ IContainerStepBuilder While(Expression> condition);
+
+ ///
+ /// Execute a block of steps if a condition is true
+ ///
+ /// Resolves a condition to evaluate
+ ///
+ IContainerStepBuilder If(Expression> condition);
+
+ ///
+ /// Execute a block of steps if a condition is true
+ ///
+ /// Resolves a condition to evaluate
+ ///
+ IContainerStepBuilder If(Expression> condition);
+
+ ///
+ /// Configure an outcome for this step, then wire it to a sequence
+ ///
+ ///
+ ///
+ IContainerStepBuilder When(Expression> outcomeValue, string label = null);
+
+ ///
+ /// Execute multiple blocks of steps in parallel
+ ///
+ ///
+ IParallelStepBuilder Parallel();
+
+ ///
+ /// Execute a sequence of steps in a container
+ ///
+ ///
+ IStepBuilder Saga(Action> builder);
+
+ ///
+ /// Schedule a block of steps to execute in parallel sometime in the future
+ ///
+ /// The time span to wait before executing the block
+ ///
+ IContainerStepBuilder Schedule(Expression> time);
+
+ ///
+ /// Schedule a block of steps to execute in parallel sometime in the future at a recurring interval
+ ///
+ /// The time span to wait between recurring executions
+ /// Resolves a condition to stop the recurring task
+ ///
+ IContainerStepBuilder Recur(
+ Expression> interval,
+ Expression> until);
+
+ ///
+ /// Wait here until an external activity is complete
+ ///
+ /// The name used to identify the activity to wait for
+ /// The data to pass the external activity worker
+ /// Listen for events as of this effective date
+ /// A condition that when true will cancel this WaitFor
+ ///
+ IStepBuilder Activity(
+ string activityName,
+ Expression> parameters = null,
+ Expression> effectiveDate = null,
+ Expression> cancelCondition = null);
+
+ ///
+ /// Wait here until an external activity is complete
+ ///
+ /// The name used to identify the activity to wait for
+ /// The data to pass the external activity worker
+ /// Listen for events as of this effective date
+ /// A condition that when true will cancel this WaitFor
+ ///
+ IStepBuilder Activity(
+ Expression> activityName,
+ Expression> parameters = null,
+ Expression> effectiveDate = null,
+ Expression> cancelCondition = null);
}
}
\ No newline at end of file
diff --git a/src/WorkflowCore/Interface/IWorkflowRegistry.cs b/src/WorkflowCore/Interface/IWorkflowRegistry.cs
index 40143e3c1..06d4fc2e6 100644
--- a/src/WorkflowCore/Interface/IWorkflowRegistry.cs
+++ b/src/WorkflowCore/Interface/IWorkflowRegistry.cs
@@ -1,4 +1,7 @@
using System.Collections.Generic;
+#if NET8_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
using WorkflowCore.Models;
namespace WorkflowCore.Interface
diff --git a/src/WorkflowCore/Models/WorkflowDefinition.cs b/src/WorkflowCore/Models/WorkflowDefinition.cs
index d40fc5a2e..0cf99469f 100644
--- a/src/WorkflowCore/Models/WorkflowDefinition.cs
+++ b/src/WorkflowCore/Models/WorkflowDefinition.cs
@@ -1,5 +1,8 @@
using System;
-
+#if NET8_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+#endif
namespace WorkflowCore.Models
{
@@ -13,6 +16,9 @@ public class WorkflowDefinition
public WorkflowStepCollection Steps { get; set; } = new WorkflowStepCollection();
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+#endif
public Type DataType { get; set; }
public WorkflowErrorHandling DefaultErrorBehavior { get; set; }
@@ -21,9 +27,11 @@ public class WorkflowDefinition
public Type OnExecuteMiddlewareError { get; set; }
public TimeSpan? DefaultErrorRetryInterval { get; set; }
-
}
+#if NET8_0_OR_GREATER
+ [JsonConverter(typeof(JsonStringEnumConverter))]
+#endif
public enum WorkflowErrorHandling
{
Retry = 0,
diff --git a/src/WorkflowCore/Models/WorkflowStep.cs b/src/WorkflowCore/Models/WorkflowStep.cs
index 814219916..f7a393268 100644
--- a/src/WorkflowCore/Models/WorkflowStep.cs
+++ b/src/WorkflowCore/Models/WorkflowStep.cs
@@ -1,12 +1,19 @@
using System;
+#if NET8_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
using System.Collections.Generic;
using System.Linq.Expressions;
+using System.Reflection;
using WorkflowCore.Interface;
namespace WorkflowCore.Models
{
public abstract class WorkflowStep
{
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+#endif
public abstract Type BodyType { get; }
public virtual int Id { get; set; }
@@ -48,7 +55,7 @@ public virtual ExecutionPipelineDirective BeforeExecute(WorkflowExecutorResult e
}
public virtual void AfterExecute(WorkflowExecutorResult executorResult, IStepExecutionContext context, ExecutionResult stepResult, ExecutionPointer executionPointer)
- {
+ {
}
public virtual void PrimeForRetry(ExecutionPointer pointer)
@@ -57,40 +64,45 @@ public virtual void PrimeForRetry(ExecutionPointer pointer)
///
/// Called after every workflow execution round,
- /// every exectuon pointer with no end time, even if this step was not executed in this round
+ /// every execution pointer with no end time, even if this step was not executed in this round
///
///
- ///
+ ///
///
///
- public virtual void AfterWorkflowIteration(WorkflowExecutorResult executorResult, WorkflowDefinition defintion, WorkflowInstance workflow, ExecutionPointer executionPointer)
+ public virtual void AfterWorkflowIteration(WorkflowExecutorResult executorResult, WorkflowDefinition definition, WorkflowInstance workflow, ExecutionPointer executionPointer)
{
-
}
public virtual IStepBody ConstructBody(IServiceProvider serviceProvider)
{
- IStepBody body = (serviceProvider.GetService(BodyType) as IStepBody);
- if (body == null)
+ if (serviceProvider.GetService(BodyType) is IStepBody body)
{
- var stepCtor = BodyType.GetConstructor(new Type[] { });
- if (stepCtor != null)
- body = (stepCtor.Invoke(null) as IStepBody);
+ return body;
}
- return body;
+
+ var stepCtor = BodyType.GetConstructor(Array.Empty());
+ return stepCtor != null ? stepCtor.Invoke(Array.Empty