From d85fffac7138a91515805797e9b0032a1623bbe1 Mon Sep 17 00:00:00 2001 From: Jing Ling Date: Sun, 28 Jan 2024 14:46:16 +0800 Subject: [PATCH] [AOT] Trim compatibility for project WorkflowCore --- Directory.Packages.props | 120 ++++++ WorkflowCore.sln | 5 +- src/WorkflowCore.DSL/WorkflowCore.DSL.csproj | 10 +- .../WorkflowCore.Testing.csproj | 6 +- .../Interface/IContainerStepBuilder.cs | 13 +- .../Interface/IParallelStepBuilder.cs | 9 +- src/WorkflowCore/Interface/IStepBody.cs | 4 +- src/WorkflowCore/Interface/IStepBuilder.cs | 36 +- .../Interface/IStepOutcomeBuilder.cs | 17 +- .../Interface/IWorkflowBuilder.cs | 15 +- .../Interface/IWorkflowController.cs | 19 +- .../Interface/IWorkflowModifier.cs | 376 ++++++++++-------- .../Interface/IWorkflowRegistry.cs | 3 + src/WorkflowCore/Models/WorkflowDefinition.cs | 12 +- src/WorkflowCore/Models/WorkflowStep.cs | 48 ++- .../Models/WorkflowStepCollection.cs | 9 +- src/WorkflowCore/Primitives/Activity.cs | 13 +- src/WorkflowCore/Primitives/EndStep.cs | 12 +- src/WorkflowCore/Primitives/SagaContainer.cs | 11 +- src/WorkflowCore/Primitives/WaitFor.cs | 9 +- .../ServiceCollectionExtensions.cs | 14 +- .../Services/ActivityController.cs | 26 +- .../Services/BackgroundTasks/QueueConsumer.cs | 30 +- .../MemoryPersistenceProvider.cs | 4 +- .../TransientMemoryPersistenceProvider.cs | 1 + .../FluentBuilders/ParallelStepBuilder.cs | 17 +- .../FluentBuilders/ReturnStepBuilder.cs | 15 +- .../Services/FluentBuilders/StepBuilder.cs | 45 ++- .../FluentBuilders/StepOutcomeBuilder.cs | 15 +- .../FluentBuilders/WorkflowBuilder.cs | 63 ++- .../Services/SyncWorkflowRunner.cs | 2 +- .../Services/WorkflowController.cs | 18 +- src/WorkflowCore/Services/WorkflowHost.cs | 16 +- src/WorkflowCore/Services/WorkflowRegistry.cs | 25 +- src/WorkflowCore/WorkflowCore.csproj | 39 +- .../WorkflowCore.Users.csproj | 4 +- .../Controllers/WorkflowsController.cs | 2 +- .../WorkflowCore.WebAPI.csproj | 8 +- .../SqlLockProvider.cs | 2 +- ...orkflowCore.LockProviders.SqlServer.csproj | 4 +- ...lowCore.Persistence.EntityFramework.csproj | 14 +- .../WorkflowCore.Persistence.MongoDB.csproj | 8 +- .../WorkflowCore.Persistence.MySQL.csproj | 24 +- ...WorkflowCore.Persistence.PostgreSQL.csproj | 23 +- .../ServiceCollectionExtensions.cs | 4 +- .../Services/RavendbPersistenceProvider.cs | 18 +- .../WorkflowCore.Persistence.RavenDB.csproj | 6 +- .../WorkflowCore.Persistence.SqlServer.csproj | 21 +- .../WorkflowCore.Persistence.Sqlite.csproj | 10 +- .../WorkflowCore.Providers.AWS.csproj | 12 +- .../WorkflowCore.Providers.Azure.csproj | 10 +- ...orkflowCore.Providers.Elasticsearch.csproj | 6 +- .../WorkflowCore.Providers.Redis.csproj | 9 +- ...orkflowCore.QueueProviders.RabbitMQ.csproj | 6 +- ...rkflowCore.QueueProviders.SqlServer.csproj | 13 +- src/samples/Directory.Build.props | 16 +- .../WorkflowCore.Sample01.csproj | 12 +- .../SimpleDecisionWorkflow.cs | 1 + .../WorkflowCore.Sample02.csproj | 4 +- .../WorkflowCore.Sample03/Steps/AddNumbers.cs | 7 +- .../WorkflowCore.Sample03.csproj | 4 +- .../WorkflowCore.Sample04.csproj | 6 +- .../WorkflowCore.Sample05.csproj | 2 +- .../MultipleOutcomeWorkflow.cs | 1 + .../WorkflowCore.Sample06.csproj | 2 +- src/samples/WorkflowCore.Sample07/Startup.cs | 9 +- .../WorkflowCore.Sample07.csproj | 5 +- .../WorkflowCore.Sample08.csproj | 2 +- .../WorkflowCore.Sample09.csproj | 2 +- .../WorkflowCore.Sample09s.csproj | 2 +- .../WorkflowCore.Sample10.csproj | 2 +- .../WorkflowCore.Sample11.csproj | 4 +- .../WorkflowCore.Sample12.csproj | 2 +- .../WorkflowCore.Sample13.csproj | 2 +- .../WorkflowCore.Sample15.csproj | 4 +- .../WorkflowCore.Sample16.csproj | 4 +- .../WorkflowCore.Sample18.csproj | 10 +- .../WorkflowCore.Sample19.csproj | 10 +- .../WorkflowCore.TestSample01/NUnitTest.cs | 2 +- .../WorkflowCore.TestSample01.csproj | 14 +- test/Directory.Build.props | 41 +- test/Docker.Testify/Docker.Testify.csproj | 6 +- .../Scenarios/ActivityScenario.cs | 9 +- .../Scenarios/ForkScenario.cs | 10 +- .../Scenarios/UserScenario.cs | 7 +- .../WorkflowCore.IntegrationTests.csproj | 2 +- .../WorkflowCore.TestAssets.csproj | 4 +- .../WorkflowCore.Tests.DynamoDB.csproj | 2 +- .../WorkflowCore.Tests.Elasticsearch.csproj | 2 +- .../Scenarios/MongoForkScenario.cs | 1 + .../WorkflowCore.Tests.MongoDB.csproj | 4 +- .../Scenarios/MysqlForkScenario.cs | 1 + .../WorkflowCore.Tests.MySQL.csproj | 3 +- .../Scenarios/PostgresForkScenario.cs | 1 + .../WorkflowCore.Tests.PostgreSQL.csproj | 2 +- ...wCore.Tests.QueueProviders.RabbitMQ.csproj | 2 +- .../WorkflowCore.Tests.Redis.csproj | 4 +- .../WorkflowCore.Tests.SqlServer.csproj | 2 +- .../BasePersistenceFixture.cs | 38 +- 99 files changed, 949 insertions(+), 602 deletions(-) create mode 100644 Directory.Packages.props 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.0 DSL 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.0 3.5.2 3.5.2.0 3.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()) as IStepBody : null; } } - public class WorkflowStep : WorkflowStep - where TStepBody : IStepBody + public class WorkflowStep< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TStepBody> : WorkflowStep + where TStepBody : IStepBody { +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif public override Type BodyType => typeof(TStepBody); } - public enum ExecutionPipelineDirective - { - Next = 0, - Defer = 1, - EndWorkflow = 2 + public enum ExecutionPipelineDirective + { + Next = 0, + Defer = 1, + EndWorkflow = 2 } } diff --git a/src/WorkflowCore/Models/WorkflowStepCollection.cs b/src/WorkflowCore/Models/WorkflowStepCollection.cs index 68346620e..7eac7f019 100644 --- a/src/WorkflowCore/Models/WorkflowStepCollection.cs +++ b/src/WorkflowCore/Models/WorkflowStepCollection.cs @@ -8,7 +8,7 @@ namespace WorkflowCore.Models public class WorkflowStepCollection : ICollection { private readonly Dictionary _dictionary = new Dictionary(); - + public WorkflowStepCollection() { } @@ -38,12 +38,9 @@ IEnumerator IEnumerable.GetEnumerator() public WorkflowStep FindById(int id) { - if (!_dictionary.ContainsKey(id)) - return null; - - return _dictionary[id]; + return !_dictionary.TryGetValue(id, out WorkflowStep value) ? null : value; } - + public void Add(WorkflowStep item) { _dictionary.Add(item.Id, item); diff --git a/src/WorkflowCore/Primitives/Activity.cs b/src/WorkflowCore/Primitives/Activity.cs index 4f0ebb0c1..4302c8d90 100644 --- a/src/WorkflowCore/Primitives/Activity.cs +++ b/src/WorkflowCore/Primitives/Activity.cs @@ -8,25 +8,18 @@ namespace WorkflowCore.Primitives public class Activity : StepBody { public string ActivityName { get; set; } - + public DateTime EffectiveDate { get; set; } public object Parameters { get; set; } - + public object Result { get; set; } public override ExecutionResult Run(IStepExecutionContext context) { if (!context.ExecutionPointer.EventPublished) { - DateTime effectiveDate = DateTime.MinValue; - - if (EffectiveDate != null) - { - effectiveDate = EffectiveDate; - } - - return ExecutionResult.WaitForActivity(ActivityName, Parameters, effectiveDate); + return ExecutionResult.WaitForActivity(ActivityName, Parameters, EffectiveDate); } if (context.ExecutionPointer.EventData is ActivityResult) diff --git a/src/WorkflowCore/Primitives/EndStep.cs b/src/WorkflowCore/Primitives/EndStep.cs index fbe53b39d..bef46277e 100644 --- a/src/WorkflowCore/Primitives/EndStep.cs +++ b/src/WorkflowCore/Primitives/EndStep.cs @@ -1,16 +1,22 @@ using System; +#if NET8_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif using WorkflowCore.Models; namespace WorkflowCore.Primitives { public class EndStep : WorkflowStep { +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif public override Type BodyType => null; public override ExecutionPipelineDirective InitForExecution( - WorkflowExecutorResult executorResult, - WorkflowDefinition defintion, - WorkflowInstance workflow, + WorkflowExecutorResult executorResult, + WorkflowDefinition definition, + WorkflowInstance workflow, ExecutionPointer executionPointer) { return ExecutionPipelineDirective.EndWorkflow; diff --git a/src/WorkflowCore/Primitives/SagaContainer.cs b/src/WorkflowCore/Primitives/SagaContainer.cs index 93470cdbb..aa4fcd85f 100644 --- a/src/WorkflowCore/Primitives/SagaContainer.cs +++ b/src/WorkflowCore/Primitives/SagaContainer.cs @@ -1,9 +1,16 @@ -using WorkflowCore.Interface; +#if NET8_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif +using WorkflowCore.Interface; using WorkflowCore.Models; namespace WorkflowCore.Primitives { - public class SagaContainer : WorkflowStep + public class SagaContainer< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TStepBody> : WorkflowStep where TStepBody : IStepBody { public override bool ResumeChildrenAfterCompensation => false; diff --git a/src/WorkflowCore/Primitives/WaitFor.cs b/src/WorkflowCore/Primitives/WaitFor.cs index 7f84be2cd..01d4d3f21 100644 --- a/src/WorkflowCore/Primitives/WaitFor.cs +++ b/src/WorkflowCore/Primitives/WaitFor.cs @@ -18,14 +18,7 @@ public override ExecutionResult Run(IStepExecutionContext context) { if (!context.ExecutionPointer.EventPublished) { - DateTime effectiveDate = DateTime.MinValue; - - if (EffectiveDate != null) - { - effectiveDate = EffectiveDate; - } - - return ExecutionResult.WaitForEvent(EventName, EventKey, effectiveDate); + return ExecutionResult.WaitForEvent(EventName, EventKey, EffectiveDate); } EventData = context.ExecutionPointer.EventData; diff --git a/src/WorkflowCore/ServiceCollectionExtensions.cs b/src/WorkflowCore/ServiceCollectionExtensions.cs index 760a89d41..1c9b07331 100644 --- a/src/WorkflowCore/ServiceCollectionExtensions.cs +++ b/src/WorkflowCore/ServiceCollectionExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.Linq; using WorkflowCore.Interface; using WorkflowCore.Services; @@ -93,7 +94,11 @@ public static IServiceCollection AddWorkflow(this IServiceCollection services, A /// The type of middleware. /// It must implement . /// The services collection for chaining. - public static IServiceCollection AddWorkflowStepMiddleware( + public static IServiceCollection AddWorkflowStepMiddleware< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] +#endif + TMiddleware>( this IServiceCollection services, Func factory = null) where TMiddleware : class, IWorkflowStepMiddleware => @@ -111,7 +116,11 @@ public static IServiceCollection AddWorkflowStepMiddleware( /// The type of middleware. /// It must implement . /// The services collection for chaining. - public static IServiceCollection AddWorkflowMiddleware( + public static IServiceCollection AddWorkflowMiddleware< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] +#endif + TMiddleware>( this IServiceCollection services, Func factory = null) where TMiddleware : class, IWorkflowMiddleware => @@ -120,4 +129,3 @@ public static IServiceCollection AddWorkflowMiddleware( : services.AddTransient(factory); } } - diff --git a/src/WorkflowCore/Services/ActivityController.cs b/src/WorkflowCore/Services/ActivityController.cs index e37481521..8cd4c9c52 100644 --- a/src/WorkflowCore/Services/ActivityController.cs +++ b/src/WorkflowCore/Services/ActivityController.cs @@ -1,16 +1,18 @@ using System; using System.Linq; using System.Text; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Text.Json.Serialization.Metadata; using System.Threading; using System.Threading.Tasks; -using Newtonsoft.Json; using WorkflowCore.Exceptions; using WorkflowCore.Interface; using WorkflowCore.Models; namespace WorkflowCore.Services { - public class ActivityController : IActivityController + public partial class ActivityController : IActivityController { private readonly ISubscriptionRepository _subscriptionRepository; private readonly IDistributedLockProvider _lockProvider; @@ -113,8 +115,13 @@ class Token public string Encode() { - var json = JsonConvert.SerializeObject(this); +#if NET8_0_OR_GREATER + var raw = JsonSerializer.SerializeToUtf8Bytes(this, typeof(Token), TokenSerializeContext.Default); + return Convert.ToBase64String(raw); +#else + var json = JsonSerializer.Serialize(this); return Convert.ToBase64String(Encoding.UTF8.GetBytes(json)); +#endif } public static Token Create(string subscriptionId, string activityName) @@ -130,9 +137,20 @@ public static Token Create(string subscriptionId, string activityName) public static Token Decode(string encodedToken) { var raw = Convert.FromBase64String(encodedToken); +#if NET8_0_OR_GREATER + return JsonSerializer.Deserialize(raw, TokenSerializeContext.Default.Token); +#else var json = Encoding.UTF8.GetString(raw); - return JsonConvert.DeserializeObject(json); + return JsonSerializer.Deserialize(raw); +#endif } } + +#if NET8_0_OR_GREATER + [JsonSerializable(typeof(Token))] + partial class TokenSerializeContext : JsonSerializerContext + { + } +#endif } } \ No newline at end of file diff --git a/src/WorkflowCore/Services/BackgroundTasks/QueueConsumer.cs b/src/WorkflowCore/Services/BackgroundTasks/QueueConsumer.cs index a5392ecbb..b4fd915b5 100644 --- a/src/WorkflowCore/Services/BackgroundTasks/QueueConsumer.cs +++ b/src/WorkflowCore/Services/BackgroundTasks/QueueConsumer.cs @@ -1,10 +1,10 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; -using ConcurrentCollections; using Microsoft.Extensions.Logging; using OpenTelemetry.Trace; using WorkflowCore.Interface; @@ -14,17 +14,19 @@ namespace WorkflowCore.Services.BackgroundTasks { internal abstract class QueueConsumer : IBackgroundTask { - protected abstract QueueType Queue { get; } - protected virtual int MaxConcurrentItems => Math.Max(Environment.ProcessorCount, 2); - protected virtual bool EnableSecondPasses => false; + private readonly Dictionary _activeTasks; + // Refer to https://github.com/dotnet/runtime/issues/39919#issuecomment-954774092 + private readonly ConcurrentDictionary _secondPasses; + private CancellationTokenSource _cancellationTokenSource; protected readonly IQueueProvider QueueProvider; protected readonly ILogger Logger; protected readonly WorkflowOptions Options; - protected Task DispatchTask; - private CancellationTokenSource _cancellationTokenSource; - private Dictionary _activeTasks; - private ConcurrentHashSet _secondPasses; + protected Task DispatchTask; + + protected abstract QueueType Queue { get; } + protected virtual int MaxConcurrentItems => Math.Max(Environment.ProcessorCount, 2); + protected virtual bool EnableSecondPasses => false; protected QueueConsumer(IQueueProvider queueProvider, ILoggerFactory loggerFactory, WorkflowOptions options) { @@ -33,7 +35,7 @@ protected QueueConsumer(IQueueProvider queueProvider, ILoggerFactory loggerFacto Logger = loggerFactory.CreateLogger(GetType()); _activeTasks = new Dictionary(); - _secondPasses = new ConcurrentHashSet(); + _secondPasses = new ConcurrentDictionary(); } protected abstract Task ProcessItem(string itemId, CancellationToken cancellationToken); @@ -62,7 +64,7 @@ public virtual void Stop() private async Task Execute() { - var cancelToken = _cancellationTokenSource.Token; + var cancelToken = _cancellationTokenSource.Token; while (!cancelToken.IsCancellationRequested) { @@ -100,14 +102,14 @@ private async Task Execute() } if (hasTask) { - _secondPasses.Add(item); + _secondPasses.TryAdd(item, 0); if (!EnableSecondPasses) await QueueProvider.QueueWork(item, Queue); activity?.Dispose(); continue; } - _secondPasses.TryRemove(item); + _secondPasses.TryRemove(item, out _); var waitHandle = new ManualResetEvent(false); lock (_activeTasks) @@ -145,9 +147,9 @@ private async Task ExecuteItem(string itemId, EventWaitHandle waitHandle, Activi try { await ProcessItem(itemId, _cancellationTokenSource.Token); - while (EnableSecondPasses && _secondPasses.Contains(itemId)) + while (EnableSecondPasses && _secondPasses.ContainsKey(itemId)) { - _secondPasses.TryRemove(itemId); + _secondPasses.TryRemove(itemId, out _); await ProcessItem(itemId, _cancellationTokenSource.Token); } } diff --git a/src/WorkflowCore/Services/DefaultProviders/MemoryPersistenceProvider.cs b/src/WorkflowCore/Services/DefaultProviders/MemoryPersistenceProvider.cs index cb69c8791..4ca9a206b 100644 --- a/src/WorkflowCore/Services/DefaultProviders/MemoryPersistenceProvider.cs +++ b/src/WorkflowCore/Services/DefaultProviders/MemoryPersistenceProvider.cs @@ -99,14 +99,14 @@ public async Task> GetWorkflowInstances(WorkflowSt { lock (_instances) { - var result = _instances.AsQueryable(); + IEnumerable result = _instances; if (status.HasValue) { result = result.Where(x => x.Status == status.Value); } - if (!String.IsNullOrEmpty(type)) + if (!string.IsNullOrEmpty(type)) { result = result.Where(x => x.WorkflowDefinitionId == type); } diff --git a/src/WorkflowCore/Services/DefaultProviders/TransientMemoryPersistenceProvider.cs b/src/WorkflowCore/Services/DefaultProviders/TransientMemoryPersistenceProvider.cs index 31ec6dbe2..02f2c8c9c 100644 --- a/src/WorkflowCore/Services/DefaultProviders/TransientMemoryPersistenceProvider.cs +++ b/src/WorkflowCore/Services/DefaultProviders/TransientMemoryPersistenceProvider.cs @@ -40,6 +40,7 @@ public TransientMemoryPersistenceProvider(ISingletonMemoryProvider innerService) public Task> GetWorkflowInstances(IEnumerable ids, CancellationToken _ = default) => _innerService.GetWorkflowInstances(ids); + [Obsolete] public Task> GetWorkflowInstances(WorkflowStatus? status, string type, DateTime? createdFrom, DateTime? createdTo, int skip, int take) => _innerService.GetWorkflowInstances(status, type, createdFrom, createdTo, skip, take); public Task MarkEventProcessed(string id, CancellationToken _ = default) => _innerService.MarkEventProcessed(id); diff --git a/src/WorkflowCore/Services/FluentBuilders/ParallelStepBuilder.cs b/src/WorkflowCore/Services/FluentBuilders/ParallelStepBuilder.cs index 81cb34690..991e82ac1 100644 --- a/src/WorkflowCore/Services/FluentBuilders/ParallelStepBuilder.cs +++ b/src/WorkflowCore/Services/FluentBuilders/ParallelStepBuilder.cs @@ -1,11 +1,18 @@ using System; +#if NET8_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif using WorkflowCore.Interface; using WorkflowCore.Models; using WorkflowCore.Primitives; namespace WorkflowCore.Services { - public class ParallelStepBuilder : IParallelStepBuilder + public class ParallelStepBuilder : IParallelStepBuilder where TStepBody : IStepBody { private readonly IStepBuilder _referenceBuilder; @@ -14,7 +21,7 @@ public class ParallelStepBuilder : IParallelStepBuilder WorkflowBuilder { get; private set; } public WorkflowStep Step { get; set; } - + public ParallelStepBuilder(IWorkflowBuilder workflowBuilder, IStepBuilder stepBuilder, IStepBuilder referenceBuilder) { WorkflowBuilder = workflowBuilder; @@ -22,15 +29,15 @@ public ParallelStepBuilder(IWorkflowBuilder workflowBuilder, IStepBuilder _stepBuilder = stepBuilder; _referenceBuilder = referenceBuilder; } - + public IParallelStepBuilder Do(Action> builder) { var lastStep = WorkflowBuilder.LastStep; builder.Invoke(WorkflowBuilder); - + if (lastStep == WorkflowBuilder.LastStep) throw new NotSupportedException("Empty Do block not supported"); - + Step.Children.Add(lastStep + 1); //TODO: make more elegant return this; diff --git a/src/WorkflowCore/Services/FluentBuilders/ReturnStepBuilder.cs b/src/WorkflowCore/Services/FluentBuilders/ReturnStepBuilder.cs index 0777533b5..606ad4e61 100644 --- a/src/WorkflowCore/Services/FluentBuilders/ReturnStepBuilder.cs +++ b/src/WorkflowCore/Services/FluentBuilders/ReturnStepBuilder.cs @@ -1,10 +1,21 @@ using System; +#if NET8_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif using WorkflowCore.Interface; using WorkflowCore.Models; namespace WorkflowCore.Services { - public class ReturnStepBuilder : IContainerStepBuilder + public class ReturnStepBuilder : IContainerStepBuilder where TStepBody : IStepBody where TParentStep : IStepBody { @@ -20,7 +31,7 @@ public ReturnStepBuilder(IWorkflowBuilder workflowBuilder, WorkflowStep Do(Action> builder) { builder.Invoke(WorkflowBuilder); diff --git a/src/WorkflowCore/Services/FluentBuilders/StepBuilder.cs b/src/WorkflowCore/Services/FluentBuilders/StepBuilder.cs index 9e41f15ca..615fa5f4d 100644 --- a/src/WorkflowCore/Services/FluentBuilders/StepBuilder.cs +++ b/src/WorkflowCore/Services/FluentBuilders/StepBuilder.cs @@ -1,5 +1,8 @@ using System; using System.Collections; +#if NET8_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif using System.Linq.Expressions; using WorkflowCore.Interface; using WorkflowCore.Models; @@ -7,7 +10,11 @@ namespace WorkflowCore.Services { - public class StepBuilder : IStepBuilder, IContainerStepBuilder + public class StepBuilder : IStepBuilder, IContainerStepBuilder where TStepBody : IStepBody { public IWorkflowBuilder WorkflowBuilder { get; private set; } @@ -32,7 +39,11 @@ public IStepBuilder Id(string id) return this; } - public IStepBuilder Then(Action> stepSetup = null) + public IStepBuilder Then< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TStep>(Action> stepSetup = null) where TStep : IStepBody { WorkflowStep newStep = new WorkflowStep(); @@ -50,7 +61,11 @@ public IStepBuilder Then(Action> return stepBuilder; } - public IStepBuilder Then(IStepBuilder newStep) + public IStepBuilder Then< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TStep>(IStepBuilder newStep) where TStep : IStepBody { Step.Outcomes.Add(new ValueOutcome { NextStep = newStep.Step.Id }); @@ -101,7 +116,11 @@ public IStepOutcomeBuilder When(object outcomeValue, string label = null) return outcomeBuilder; } - public IStepBuilder Branch(object outcomeValue, IStepBuilder branch) where TStep : IStepBody + public IStepBuilder Branch< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TStep>(object outcomeValue, IStepBuilder branch) where TStep : IStepBody { if (branch.WorkflowBuilder.Steps.Count == 0) return this; @@ -118,7 +137,11 @@ public IStepBuilder Branch(object outcomeValue, IStepBu return this; } - public IStepBuilder Branch(Expression> outcomeExpression, IStepBuilder branch) where TStep : IStepBody + public IStepBuilder Branch< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TStep>(Expression> outcomeExpression, IStepBuilder branch) where TStep : IStepBody { if (branch.WorkflowBuilder.Steps.Count == 0) return this; @@ -207,7 +230,11 @@ public IStepBuilder WaitFor(string eventName, Expression End(string name) where TStep : IStepBody + public IStepBuilder End< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TStep>(string name) where TStep : IStepBody { var ancestor = IterateParents(Step.Id, name); @@ -495,7 +522,11 @@ public IStepBuilder Do(Action> builder return this; } - public IStepBuilder CompensateWith(Action> stepSetup = null) where TStep : IStepBody + public IStepBuilder CompensateWith< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TStep>(Action> stepSetup = null) where TStep : IStepBody { WorkflowStep newStep = new WorkflowStep(); WorkflowBuilder.AddStep(newStep); diff --git a/src/WorkflowCore/Services/FluentBuilders/StepOutcomeBuilder.cs b/src/WorkflowCore/Services/FluentBuilders/StepOutcomeBuilder.cs index 1d654152a..17b24cb73 100644 --- a/src/WorkflowCore/Services/FluentBuilders/StepOutcomeBuilder.cs +++ b/src/WorkflowCore/Services/FluentBuilders/StepOutcomeBuilder.cs @@ -1,4 +1,7 @@ using System; +#if NET8_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif using WorkflowCore.Interface; using WorkflowCore.Models; using WorkflowCore.Primitives; @@ -16,7 +19,11 @@ public StepOutcomeBuilder(IWorkflowBuilder workflowBuilder, ValueOutcome Outcome = outcome; } - public IStepBuilder Then(Action> stepSetup = null) + public IStepBuilder Then< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TStep>(Action> stepSetup = null) where TStep : IStepBody { WorkflowStep step = new WorkflowStep(); @@ -34,7 +41,11 @@ public IStepBuilder Then(Action> return stepBuilder; } - public IStepBuilder Then(IStepBuilder step) + public IStepBuilder Then< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TStep>(IStepBuilder step) where TStep : IStepBody { Outcome.NextStep = step.Step.Id; diff --git a/src/WorkflowCore/Services/FluentBuilders/WorkflowBuilder.cs b/src/WorkflowCore/Services/FluentBuilders/WorkflowBuilder.cs index adc02f488..a49969eeb 100644 --- a/src/WorkflowCore/Services/FluentBuilders/WorkflowBuilder.cs +++ b/src/WorkflowCore/Services/FluentBuilders/WorkflowBuilder.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -21,7 +22,11 @@ public class WorkflowBuilder : IWorkflowBuilder public int LastStep => Steps.Max(x => x.Id); - public IWorkflowBuilder UseData() + public IWorkflowBuilder UseData< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + T>() { IWorkflowBuilder result = new WorkflowBuilder(Steps); return result; @@ -119,12 +124,14 @@ public void AttachBranch(IWorkflowBuilder branch) Branches.Add(branch); } - } - public class WorkflowBuilder : WorkflowBuilder, IWorkflowBuilder + public class WorkflowBuilder< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TData> : WorkflowBuilder, IWorkflowBuilder { - public override WorkflowDefinition Build(string id, int version) { var result = base.Build(id, version); @@ -137,7 +144,11 @@ public WorkflowBuilder(IEnumerable steps) this.Steps.AddRange(steps); } - public IStepBuilder StartWith(Action> stepSetup = null) + public IStepBuilder StartWith< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TStep>(Action> stepSetup = null) where TStep : IStepBody { WorkflowStep step = new WorkflowStep(); @@ -189,12 +200,20 @@ public IWorkflowBuilder CreateBranch() return result; } - public IStepBuilder Then(Action> stepSetup = null) where TStep : IStepBody + public IStepBuilder Then< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TStep>(Action> stepSetup = null) where TStep : IStepBody { return Start().Then(stepSetup); } - public IStepBuilder Then(IStepBuilder newStep) where TStep : IStepBody + public IStepBuilder Then< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] +#endif + TStep>(IStepBuilder newStep) where TStep : IStepBody { return Start().Then(newStep); } @@ -209,13 +228,17 @@ public IStepBuilder Then(Action bo return Start().Then(body); } - public IStepBuilder WaitFor(string eventName, Expression> eventKey, Expression> effectiveDate = null, + public IStepBuilder WaitFor( + string eventName, Expression> eventKey, + Expression> effectiveDate = null, Expression> cancelCondition = null) { return Start().WaitFor(eventName, eventKey, effectiveDate, cancelCondition); } - public IStepBuilder WaitFor(string eventName, Expression> eventKey, Expression> effectiveDate = null, + public IStepBuilder WaitFor( + string eventName, Expression> eventKey, + Expression> effectiveDate = null, Expression> cancelCondition = null) { return Start().WaitFor(eventName, eventKey, effectiveDate, cancelCondition); @@ -236,12 +259,16 @@ public IContainerStepBuilder ForEach(Expression ForEach(Expression> collection, Expression> runParallel) + public IContainerStepBuilder ForEach( + Expression> collection, + Expression> runParallel) { return Start().ForEach(collection, runParallel); } - public IContainerStepBuilder ForEach(Expression> collection, Expression> runParallel) + public IContainerStepBuilder ForEach( + Expression> collection, + Expression> runParallel) { return Start().ForEach(collection, runParallel); } @@ -286,17 +313,25 @@ public IContainerStepBuilder Schedule(Expressio return Start().Schedule(time); } - public IContainerStepBuilder Recur(Expression> interval, Expression> until) + public IContainerStepBuilder Recur( + Expression> interval, + Expression> until) { return Start().Recur(interval, until); } - public IStepBuilder Activity(string activityName, Expression> parameters = null, Expression> effectiveDate = null, + public IStepBuilder Activity( + string activityName, Expression> parameters = null, + Expression> effectiveDate = null, Expression> cancelCondition = null) { return Start().Activity(activityName, parameters, effectiveDate, cancelCondition); } - public IStepBuilder Activity(Expression> activityName, Expression> parameters = null, Expression> effectiveDate = null, Expression> cancelCondition = null) + public IStepBuilder Activity( + Expression> activityName, + Expression> parameters = null, + Expression> effectiveDate = null, + Expression> cancelCondition = null) { return Start().Activity(activityName, parameters, effectiveDate, cancelCondition); } diff --git a/src/WorkflowCore/Services/SyncWorkflowRunner.cs b/src/WorkflowCore/Services/SyncWorkflowRunner.cs index 5317a8966..5e962ce56 100644 --- a/src/WorkflowCore/Services/SyncWorkflowRunner.cs +++ b/src/WorkflowCore/Services/SyncWorkflowRunner.cs @@ -64,7 +64,7 @@ public async Task RunWorkflowSync(string workflowId, in if (typeof(TData) == def.DataType) wf.Data = new TData(); else - wf.Data = def.DataType.GetConstructor(new Type[0]).Invoke(new object[0]); + wf.Data = def.DataType.GetConstructor(Array.Empty()).Invoke(Array.Empty()); } wf.ExecutionPointers.Add(_pointerFactory.BuildGenesisPointer(def)); diff --git a/src/WorkflowCore/Services/WorkflowController.cs b/src/WorkflowCore/Services/WorkflowController.cs index 79272e084..32998b55d 100755 --- a/src/WorkflowCore/Services/WorkflowController.cs +++ b/src/WorkflowCore/Services/WorkflowController.cs @@ -1,5 +1,7 @@ using System; -using System.Linq; +#if NET8_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif using System.Threading; using System.Threading.Tasks; @@ -80,7 +82,7 @@ public async Task StartWorkflow(string workflowId, int? version, if (typeof(TData) == def.DataType) wf.Data = new TData(); else - wf.Data = def.DataType.GetConstructor(new Type[0]).Invoke(new object[0]); + wf.Data = def.DataType.GetConstructor(Array.Empty()).Invoke(Array.Empty()); } wf.ExecutionPointers.Add(_pointerFactory.BuildGenesisPointer(def)); @@ -226,14 +228,22 @@ await _eventHub.PublishNotification(new WorkflowTerminated } } - public void RegisterWorkflow() + public void RegisterWorkflow< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] +#endif + TWorkflow>() where TWorkflow : IWorkflow { var wf = ActivatorUtilities.CreateInstance(_serviceProvider); _registry.RegisterWorkflow(wf); } - public void RegisterWorkflow() + public void RegisterWorkflow< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] +#endif + TWorkflow, TData>() where TWorkflow : IWorkflow where TData : new() { diff --git a/src/WorkflowCore/Services/WorkflowHost.cs b/src/WorkflowCore/Services/WorkflowHost.cs index 73c8850fa..8553f5b8d 100644 --- a/src/WorkflowCore/Services/WorkflowHost.cs +++ b/src/WorkflowCore/Services/WorkflowHost.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; -using System.Linq; +#if NET8_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; @@ -135,13 +137,21 @@ public async Task StopAsync(CancellationToken cancellationToken) await _lifeCycleEventHub.Stop(); } - public void RegisterWorkflow() + public void RegisterWorkflow< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] +#endif + TWorkflow>() where TWorkflow : IWorkflow { _workflowController.RegisterWorkflow(); } - public void RegisterWorkflow() + public void RegisterWorkflow< +#if NET8_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] +#endif + TWorkflow, TData>() where TWorkflow : IWorkflow where TData : new() { diff --git a/src/WorkflowCore/Services/WorkflowRegistry.cs b/src/WorkflowCore/Services/WorkflowRegistry.cs index beed19c0e..a62a087a2 100644 --- a/src/WorkflowCore/Services/WorkflowRegistry.cs +++ b/src/WorkflowCore/Services/WorkflowRegistry.cs @@ -1,6 +1,9 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; +#if NET8_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif using System.Linq; using Microsoft.Extensions.DependencyInjection; using WorkflowCore.Interface; @@ -10,9 +13,9 @@ namespace WorkflowCore.Services { public class WorkflowRegistry : IWorkflowRegistry { - private readonly IServiceProvider _serviceProvider; + private readonly IServiceProvider _serviceProvider; private readonly ConcurrentDictionary _registry = new ConcurrentDictionary(); - private readonly ConcurrentDictionary _lastestVersion = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _latestVersion = new ConcurrentDictionary(); public WorkflowRegistry(IServiceProvider serviceProvider) { @@ -29,9 +32,9 @@ public WorkflowDefinition GetDefinition(string workflowId, int? version = null) } else { - if (!_lastestVersion.ContainsKey(workflowId)) + if (!_latestVersion.ContainsKey(workflowId)) return default; - return _lastestVersion[workflowId]; + return _latestVersion[workflowId]; } } @@ -43,13 +46,13 @@ public void DeregisterWorkflow(string workflowId, int version) lock (_registry) { _registry.TryRemove($"{workflowId}-{version}", out var _); - if (_lastestVersion[workflowId].Version == version) + if (_latestVersion[workflowId].Version == version) { - _lastestVersion.TryRemove(workflowId, out var _); + _latestVersion.TryRemove(workflowId, out var _); var latest = _registry.Values.Where(x => x.Id == workflowId).OrderByDescending(x => x.Version).FirstOrDefault(); if (latest != default) - _lastestVersion[workflowId] = latest; + _latestVersion[workflowId] = latest; } } } @@ -72,14 +75,14 @@ public void RegisterWorkflow(WorkflowDefinition definition) lock (_registry) { _registry[$"{definition.Id}-{definition.Version}"] = definition; - if (!_lastestVersion.ContainsKey(definition.Id)) + if (!_latestVersion.ContainsKey(definition.Id)) { - _lastestVersion[definition.Id] = definition; + _latestVersion[definition.Id] = definition; return; } - if (_lastestVersion[definition.Id].Version <= definition.Version) - _lastestVersion[definition.Id] = definition; + if (_latestVersion[definition.Id].Version <= definition.Version) + _latestVersion[definition.Id] = definition; } } diff --git a/src/WorkflowCore/WorkflowCore.csproj b/src/WorkflowCore/WorkflowCore.csproj index bb567d87c..226279783 100644 --- a/src/WorkflowCore/WorkflowCore.csproj +++ b/src/WorkflowCore/WorkflowCore.csproj @@ -3,7 +3,7 @@ Workflow Core Daniel Gerlag - netstandard2.0 + netstandard2.0;netcoreapp3.1;netstandard2.1;net6.0;net8.0 WorkflowCore WorkflowCore workflow;.NET;Core;state machine @@ -13,28 +13,29 @@ Workflow Core is a light weight workflow engine targeting .NET Standard. + + + true + true + + - - - - - - - - - - - - - - - - <_Parameter1>WorkflowCore.IntegrationTests - + + + + + + + + + + + + - + diff --git a/src/extensions/WorkflowCore.Users/WorkflowCore.Users.csproj b/src/extensions/WorkflowCore.Users/WorkflowCore.Users.csproj index 66c96f4ec..0d29447f9 100644 --- a/src/extensions/WorkflowCore.Users/WorkflowCore.Users.csproj +++ b/src/extensions/WorkflowCore.Users/WorkflowCore.Users.csproj @@ -3,7 +3,7 @@ Workflow Core extensions for human workflow Daniel Gerlag - netstandard2.0 + netstandard2.0;net6.0;net8.0 WorkflowCore.Users WorkflowCore.Users workflow;.NET;Core;state machine;WorkflowCore;human;user @@ -22,7 +22,7 @@ - + diff --git a/src/extensions/WorkflowCore.WebAPI/Controllers/WorkflowsController.cs b/src/extensions/WorkflowCore.WebAPI/Controllers/WorkflowsController.cs index 3c88df3fb..62133720f 100644 --- a/src/extensions/WorkflowCore.WebAPI/Controllers/WorkflowsController.cs +++ b/src/extensions/WorkflowCore.WebAPI/Controllers/WorkflowsController.cs @@ -27,8 +27,8 @@ public WorkflowsController(IWorkflowHost workflowHost, IWorkflowRegistry registr _logger = loggerFactory.CreateLogger(); } - [HttpGet] + [Obsolete] public async Task Get(WorkflowStatus? status, string type, DateTime? createdFrom, DateTime? createdTo, int skip, int take) { var result = await _workflowStore.GetWorkflowInstances(status, type, createdFrom, createdTo, skip, take); diff --git a/src/extensions/WorkflowCore.WebAPI/WorkflowCore.WebAPI.csproj b/src/extensions/WorkflowCore.WebAPI/WorkflowCore.WebAPI.csproj index f6eb6ea92..1b598b377 100644 --- a/src/extensions/WorkflowCore.WebAPI/WorkflowCore.WebAPI.csproj +++ b/src/extensions/WorkflowCore.WebAPI/WorkflowCore.WebAPI.csproj @@ -3,7 +3,7 @@ Workflow Core REST API Daniel Gerlag - netstandard2.0 + netstandard2.0;net6.0;net8.0 WorkflowCore.WebAPI WorkflowCore.WebAPI workflow;.NET;Core;state machine;WorkflowCore;REST;API @@ -22,9 +22,9 @@ - - - + + + diff --git a/src/providers/WorkflowCore.LockProviders.SqlServer/SqlLockProvider.cs b/src/providers/WorkflowCore.LockProviders.SqlServer/SqlLockProvider.cs index 92795d871..15aac4d79 100644 --- a/src/providers/WorkflowCore.LockProviders.SqlServer/SqlLockProvider.cs +++ b/src/providers/WorkflowCore.LockProviders.SqlServer/SqlLockProvider.cs @@ -80,7 +80,7 @@ public async Task AcquireLock(string Id, CancellationToken cancellationTok catch (Exception ex) { connection.Close(); - throw ex; + throw; } } finally diff --git a/src/providers/WorkflowCore.LockProviders.SqlServer/WorkflowCore.LockProviders.SqlServer.csproj b/src/providers/WorkflowCore.LockProviders.SqlServer/WorkflowCore.LockProviders.SqlServer.csproj index 5c798129a..022044bab 100644 --- a/src/providers/WorkflowCore.LockProviders.SqlServer/WorkflowCore.LockProviders.SqlServer.csproj +++ b/src/providers/WorkflowCore.LockProviders.SqlServer/WorkflowCore.LockProviders.SqlServer.csproj @@ -1,14 +1,14 @@  - netstandard2.0 + netstandard2.0;net6.0;net8.0 Distributed lock provider for Workflow-core using SQL Server https://github.com/danielgerlag/workflow-core https://github.com/danielgerlag/workflow-core/blob/master/LICENSE.md - + diff --git a/src/providers/WorkflowCore.Persistence.EntityFramework/WorkflowCore.Persistence.EntityFramework.csproj b/src/providers/WorkflowCore.Persistence.EntityFramework/WorkflowCore.Persistence.EntityFramework.csproj index b5fb079c9..a2ce00930 100644 --- a/src/providers/WorkflowCore.Persistence.EntityFramework/WorkflowCore.Persistence.EntityFramework.csproj +++ b/src/providers/WorkflowCore.Persistence.EntityFramework/WorkflowCore.Persistence.EntityFramework.csproj @@ -3,7 +3,7 @@ Workflow Core EntityFramework Core Persistence Provider Daniel Gerlag - netstandard2.1;net6.0 + netstandard2.1;net6.0;net8.0 WorkflowCore.Persistence.EntityFramework WorkflowCore.Persistence.EntityFramework workflow;.NET;Core;state machine;WorkflowCore;EntityFramework;EntityFrameworkCore @@ -21,17 +21,9 @@ - - - - - - - - - - + + diff --git a/src/providers/WorkflowCore.Persistence.MongoDB/WorkflowCore.Persistence.MongoDB.csproj b/src/providers/WorkflowCore.Persistence.MongoDB/WorkflowCore.Persistence.MongoDB.csproj index e55685a2e..2e68429c6 100644 --- a/src/providers/WorkflowCore.Persistence.MongoDB/WorkflowCore.Persistence.MongoDB.csproj +++ b/src/providers/WorkflowCore.Persistence.MongoDB/WorkflowCore.Persistence.MongoDB.csproj @@ -3,7 +3,7 @@ Workflow Core MongoDB Persistence Provider Daniel Gerlag - netstandard2.0 + netstandard2.0;net6.0;net8.0 WorkflowCore.Persistence.MongoDB WorkflowCore.Persistence.MongoDB workflow;.NET;Core;state machine;WorkflowCore;MongoDB;Mongo @@ -22,12 +22,12 @@ - - + + - + diff --git a/src/providers/WorkflowCore.Persistence.MySQL/WorkflowCore.Persistence.MySQL.csproj b/src/providers/WorkflowCore.Persistence.MySQL/WorkflowCore.Persistence.MySQL.csproj index 8b87ba216..094f75f78 100644 --- a/src/providers/WorkflowCore.Persistence.MySQL/WorkflowCore.Persistence.MySQL.csproj +++ b/src/providers/WorkflowCore.Persistence.MySQL/WorkflowCore.Persistence.MySQL.csproj @@ -4,7 +4,7 @@ Workflow Core MySQL Persistence Provider 1.0.0 Daniel Gerlag - netstandard2.1;net6.0 + netstandard2.1;net6.0;net8.0 WorkflowCore.Persistence.MySQL WorkflowCore.Persistence.MySQL workflow;.NET;Core;state machine;WorkflowCore;MySQL @@ -18,28 +18,12 @@ Provides support to persist workflows running on Workflow Core to a MySQL database. - - - all - runtime; build; native; contentfiles; analyzers - - - - - - - all - runtime; build; native; contentfiles; analyzers - - - - - - + + all runtime; build; native; contentfiles; analyzers - + diff --git a/src/providers/WorkflowCore.Persistence.PostgreSQL/WorkflowCore.Persistence.PostgreSQL.csproj b/src/providers/WorkflowCore.Persistence.PostgreSQL/WorkflowCore.Persistence.PostgreSQL.csproj index 583c706f0..782c1e2b9 100644 --- a/src/providers/WorkflowCore.Persistence.PostgreSQL/WorkflowCore.Persistence.PostgreSQL.csproj +++ b/src/providers/WorkflowCore.Persistence.PostgreSQL/WorkflowCore.Persistence.PostgreSQL.csproj @@ -3,7 +3,7 @@ Workflow Core PostgreSQL Persistence Provider Daniel Gerlag - netstandard2.1;net6.0 + netstandard2.1;net6.0;net8.0 WorkflowCore.Persistence.PostgreSQL WorkflowCore.Persistence.PostgreSQL workflow;.NET;Core;state machine;WorkflowCore;PostgreSQL @@ -22,25 +22,12 @@ - - - - - All - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - + + + All - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/providers/WorkflowCore.Persistence.RavenDB/ServiceCollectionExtensions.cs b/src/providers/WorkflowCore.Persistence.RavenDB/ServiceCollectionExtensions.cs index fb05b9ba3..513368f20 100644 --- a/src/providers/WorkflowCore.Persistence.RavenDB/ServiceCollectionExtensions.cs +++ b/src/providers/WorkflowCore.Persistence.RavenDB/ServiceCollectionExtensions.cs @@ -5,6 +5,7 @@ using WorkflowCore.Persistence.RavenDB.Services; using WorkflowCore.Interface; using WorkflowCore.Persistence.RavenDB; +using Microsoft.Extensions.Logging; namespace Microsoft.Extensions.DependencyInjection { @@ -21,7 +22,8 @@ public static WorkflowOptions UseRavenDB(this WorkflowOptions options, RavenStor options.UsePersistence(sp => { - return new RavendbPersistenceProvider(store); + var loggerFactory = sp.GetService(); + return new RavendbPersistenceProvider(store, loggerFactory); }); options.Services.AddTransient(sp => diff --git a/src/providers/WorkflowCore.Persistence.RavenDB/Services/RavendbPersistenceProvider.cs b/src/providers/WorkflowCore.Persistence.RavenDB/Services/RavendbPersistenceProvider.cs index 3e1d5e2ea..ec0b10d61 100644 --- a/src/providers/WorkflowCore.Persistence.RavenDB/Services/RavendbPersistenceProvider.cs +++ b/src/providers/WorkflowCore.Persistence.RavenDB/Services/RavendbPersistenceProvider.cs @@ -1,4 +1,5 @@ -using Raven.Client.Documents; +using Microsoft.Extensions.Logging; +using Raven.Client.Documents; using Raven.Client.Documents.Linq; using Raven.Client.Documents.Operations; using Raven.Client.Documents.Session; @@ -16,15 +17,18 @@ namespace WorkflowCore.Persistence.RavenDB.Services public class RavendbPersistenceProvider : IPersistenceProvider { internal const string WorkflowCollectionName = "wfc.workflows"; + private static bool indexesCreated = false; + private readonly IDocumentStore _database; - static bool indexesCreated = false; + private readonly ILogger _logger; public bool SupportsScheduledCommands => false; - public RavendbPersistenceProvider(IDocumentStore database) + public RavendbPersistenceProvider(IDocumentStore database, ILoggerFactory loggerFactory) { _database = database; - CreateIndexes(this); + _logger = loggerFactory.CreateLogger(); + CreateIndexes(this); } static void CreateIndexes(RavendbPersistenceProvider instance) @@ -216,7 +220,8 @@ public async Task SetSubscriptionToken(string eventSubscriptionId, string } catch (Exception e) { - return false; + _logger.LogError(e, "Failed to set subscription token"); + return false; } } @@ -240,7 +245,8 @@ public async Task ClearSubscriptionToken(string eventSubscriptionId, string toke } catch (Exception e) { - throw e; + _logger.LogError(e, "Failed to clear subscription token"); + throw; } } diff --git a/src/providers/WorkflowCore.Persistence.RavenDB/WorkflowCore.Persistence.RavenDB.csproj b/src/providers/WorkflowCore.Persistence.RavenDB/WorkflowCore.Persistence.RavenDB.csproj index 69c8e94e7..16a560a35 100644 --- a/src/providers/WorkflowCore.Persistence.RavenDB/WorkflowCore.Persistence.RavenDB.csproj +++ b/src/providers/WorkflowCore.Persistence.RavenDB/WorkflowCore.Persistence.RavenDB.csproj @@ -2,7 +2,7 @@ Workflow Core RavenDB Persistence Provider - netstandard2.0 + netstandard2.0;net6.0;net8.0 WorkflowCore.Persistence.RavenDB WorkflowCore.Persistence.RavenDB workflow;.NET;Core;state machine;WorkflowCore;RavenDB @@ -17,7 +17,7 @@ - + @@ -25,7 +25,7 @@ - + diff --git a/src/providers/WorkflowCore.Persistence.SqlServer/WorkflowCore.Persistence.SqlServer.csproj b/src/providers/WorkflowCore.Persistence.SqlServer/WorkflowCore.Persistence.SqlServer.csproj index b6db766bd..f4d1458db 100644 --- a/src/providers/WorkflowCore.Persistence.SqlServer/WorkflowCore.Persistence.SqlServer.csproj +++ b/src/providers/WorkflowCore.Persistence.SqlServer/WorkflowCore.Persistence.SqlServer.csproj @@ -4,7 +4,7 @@ Workflow Core SQL Server Persistence Provider 1.8.0 Daniel Gerlag - netstandard2.1;net6.0 + netstandard2.1;net6.0;net8.0 WorkflowCore.Persistence.SqlServer WorkflowCore.Persistence.SqlServer workflow;.NET;Core;state machine;WorkflowCore @@ -23,23 +23,12 @@ - - - - All - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - + + + All - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/providers/WorkflowCore.Persistence.Sqlite/WorkflowCore.Persistence.Sqlite.csproj b/src/providers/WorkflowCore.Persistence.Sqlite/WorkflowCore.Persistence.Sqlite.csproj index 88b9ceec9..33d01686e 100644 --- a/src/providers/WorkflowCore.Persistence.Sqlite/WorkflowCore.Persistence.Sqlite.csproj +++ b/src/providers/WorkflowCore.Persistence.Sqlite/WorkflowCore.Persistence.Sqlite.csproj @@ -4,7 +4,7 @@ Workflow Core Sqlite Persistence Provider 1.5.0 Daniel Gerlag - netstandard2.1;net6.0 + netstandard2.1;net6.0;net8.0 WorkflowCore.Persistence.Sqlite WorkflowCore.Persistence.Sqlite workflow;.NET;Core;state machine;WorkflowCore;Sqlite @@ -23,12 +23,8 @@ - - - - - - + + diff --git a/src/providers/WorkflowCore.Providers.AWS/WorkflowCore.Providers.AWS.csproj b/src/providers/WorkflowCore.Providers.AWS/WorkflowCore.Providers.AWS.csproj index 4ea4a1ed8..a567c0f69 100644 --- a/src/providers/WorkflowCore.Providers.AWS/WorkflowCore.Providers.AWS.csproj +++ b/src/providers/WorkflowCore.Providers.AWS/WorkflowCore.Providers.AWS.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0;net6.0;net8.0 Daniel Gerlag AWS providers for Workflow Core @@ -14,11 +14,11 @@ - - - - - + + + + + diff --git a/src/providers/WorkflowCore.Providers.Azure/WorkflowCore.Providers.Azure.csproj b/src/providers/WorkflowCore.Providers.Azure/WorkflowCore.Providers.Azure.csproj index cedd72024..d7724fbf7 100644 --- a/src/providers/WorkflowCore.Providers.Azure/WorkflowCore.Providers.Azure.csproj +++ b/src/providers/WorkflowCore.Providers.Azure/WorkflowCore.Providers.Azure.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0;net6.0;net8.0 Azure providers for Workflow Core - Provides distributed lock management on Workflow Core @@ -16,10 +16,10 @@ - - - - + + + + diff --git a/src/providers/WorkflowCore.Providers.Elasticsearch/WorkflowCore.Providers.Elasticsearch.csproj b/src/providers/WorkflowCore.Providers.Elasticsearch/WorkflowCore.Providers.Elasticsearch.csproj index 7bf5600b8..1f1d5edeb 100644 --- a/src/providers/WorkflowCore.Providers.Elasticsearch/WorkflowCore.Providers.Elasticsearch.csproj +++ b/src/providers/WorkflowCore.Providers.Elasticsearch/WorkflowCore.Providers.Elasticsearch.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0;net6.0;net8.0 https://github.com/danielgerlag/workflow-core/blob/master/LICENSE.md https://github.com/danielgerlag/workflow-core https://github.com/danielgerlag/workflow-core.git @@ -12,8 +12,8 @@ - - + + diff --git a/src/providers/WorkflowCore.Providers.Redis/WorkflowCore.Providers.Redis.csproj b/src/providers/WorkflowCore.Providers.Redis/WorkflowCore.Providers.Redis.csproj index b1cc0aa97..a95288dc5 100644 --- a/src/providers/WorkflowCore.Providers.Redis/WorkflowCore.Providers.Redis.csproj +++ b/src/providers/WorkflowCore.Providers.Redis/WorkflowCore.Providers.Redis.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0;net6.0;net8.0 https://github.com/danielgerlag/workflow-core/blob/master/LICENSE.md https://github.com/danielgerlag/workflow-core.git git @@ -10,10 +10,9 @@ - - - - + + + diff --git a/src/providers/WorkflowCore.QueueProviders.RabbitMQ/WorkflowCore.QueueProviders.RabbitMQ.csproj b/src/providers/WorkflowCore.QueueProviders.RabbitMQ/WorkflowCore.QueueProviders.RabbitMQ.csproj index 3ef1064ae..756717291 100644 --- a/src/providers/WorkflowCore.QueueProviders.RabbitMQ/WorkflowCore.QueueProviders.RabbitMQ.csproj +++ b/src/providers/WorkflowCore.QueueProviders.RabbitMQ/WorkflowCore.QueueProviders.RabbitMQ.csproj @@ -3,7 +3,7 @@ Workflow Core RabbitMQ queue provider Daniel Gerlag - netstandard2.0 + netstandard2.0;net6.0;net8.0 WorkflowCore.QueueProviders.RabbitMQ WorkflowCore.QueueProviders.RabbitMQ workflow;.NET;Core;state machine;WorkflowCore;RabbitMQ @@ -22,8 +22,8 @@ - - + + diff --git a/src/providers/WorkflowCore.QueueProviders.SqlServer/WorkflowCore.QueueProviders.SqlServer.csproj b/src/providers/WorkflowCore.QueueProviders.SqlServer/WorkflowCore.QueueProviders.SqlServer.csproj index c24b7d89e..0bded008d 100644 --- a/src/providers/WorkflowCore.QueueProviders.SqlServer/WorkflowCore.QueueProviders.SqlServer.csproj +++ b/src/providers/WorkflowCore.QueueProviders.SqlServer/WorkflowCore.QueueProviders.SqlServer.csproj @@ -1,28 +1,21 @@ - netstandard2.0 + netstandard2.0;net6.0;net8.0 Roberto Paterlini Queue provider for Workflow-core using SQL Server Service Broker alpha - - - - - - - - - + + diff --git a/src/samples/Directory.Build.props b/src/samples/Directory.Build.props index 0f8bd594d..3615b1c49 100644 --- a/src/samples/Directory.Build.props +++ b/src/samples/Directory.Build.props @@ -1,7 +1,13 @@ - - net6.0;netcoreapp3.1 - latest - false - + + net6.0;netcoreapp3.1 + latest + false + + + + + true + $(NoWarn);NETSDK1138 + \ No newline at end of file diff --git a/src/samples/WorkflowCore.Sample01/WorkflowCore.Sample01.csproj b/src/samples/WorkflowCore.Sample01/WorkflowCore.Sample01.csproj index d20a6bc51..f0cb00f97 100644 --- a/src/samples/WorkflowCore.Sample01/WorkflowCore.Sample01.csproj +++ b/src/samples/WorkflowCore.Sample01/WorkflowCore.Sample01.csproj @@ -15,12 +15,12 @@ - - - - - - + + + + + + diff --git a/src/samples/WorkflowCore.Sample02/SimpleDecisionWorkflow.cs b/src/samples/WorkflowCore.Sample02/SimpleDecisionWorkflow.cs index 91a0323f2..078c17a49 100644 --- a/src/samples/WorkflowCore.Sample02/SimpleDecisionWorkflow.cs +++ b/src/samples/WorkflowCore.Sample02/SimpleDecisionWorkflow.cs @@ -11,6 +11,7 @@ public class SimpleDecisionWorkflow : IWorkflow public int Version => 1; + [Obsolete] public void Build(IWorkflowBuilder builder) { builder diff --git a/src/samples/WorkflowCore.Sample02/WorkflowCore.Sample02.csproj b/src/samples/WorkflowCore.Sample02/WorkflowCore.Sample02.csproj index be4e85c2d..74fefbdae 100644 --- a/src/samples/WorkflowCore.Sample02/WorkflowCore.Sample02.csproj +++ b/src/samples/WorkflowCore.Sample02/WorkflowCore.Sample02.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/src/samples/WorkflowCore.Sample03/Steps/AddNumbers.cs b/src/samples/WorkflowCore.Sample03/Steps/AddNumbers.cs index a8209d227..6f6f48108 100644 --- a/src/samples/WorkflowCore.Sample03/Steps/AddNumbers.cs +++ b/src/samples/WorkflowCore.Sample03/Steps/AddNumbers.cs @@ -14,11 +14,10 @@ public class AddNumbers : StepBodyAsync public int Output { get; set; } - - public override async Task RunAsync(IStepExecutionContext context) + public override Task RunAsync(IStepExecutionContext context) { - Output = (Input1 + Input2); - return ExecutionResult.Next(); + Output = Input1 + Input2; + return Task.FromResult(ExecutionResult.Next()); } } } diff --git a/src/samples/WorkflowCore.Sample03/WorkflowCore.Sample03.csproj b/src/samples/WorkflowCore.Sample03/WorkflowCore.Sample03.csproj index 180c03454..3327a5f2a 100644 --- a/src/samples/WorkflowCore.Sample03/WorkflowCore.Sample03.csproj +++ b/src/samples/WorkflowCore.Sample03/WorkflowCore.Sample03.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/src/samples/WorkflowCore.Sample04/WorkflowCore.Sample04.csproj b/src/samples/WorkflowCore.Sample04/WorkflowCore.Sample04.csproj index 5940a8e00..cd1e90cb9 100644 --- a/src/samples/WorkflowCore.Sample04/WorkflowCore.Sample04.csproj +++ b/src/samples/WorkflowCore.Sample04/WorkflowCore.Sample04.csproj @@ -23,9 +23,9 @@ - - - + + + diff --git a/src/samples/WorkflowCore.Sample05/WorkflowCore.Sample05.csproj b/src/samples/WorkflowCore.Sample05/WorkflowCore.Sample05.csproj index bbfd7f7c7..4a8152953 100644 --- a/src/samples/WorkflowCore.Sample05/WorkflowCore.Sample05.csproj +++ b/src/samples/WorkflowCore.Sample05/WorkflowCore.Sample05.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/samples/WorkflowCore.Sample06/MultipleOutcomeWorkflow.cs b/src/samples/WorkflowCore.Sample06/MultipleOutcomeWorkflow.cs index 5f7661455..3cbb3d3ef 100644 --- a/src/samples/WorkflowCore.Sample06/MultipleOutcomeWorkflow.cs +++ b/src/samples/WorkflowCore.Sample06/MultipleOutcomeWorkflow.cs @@ -11,6 +11,7 @@ public class MultipleOutcomeWorkflow : IWorkflow public int Version => 1; + [Obsolete] public void Build(IWorkflowBuilder builder) { builder diff --git a/src/samples/WorkflowCore.Sample06/WorkflowCore.Sample06.csproj b/src/samples/WorkflowCore.Sample06/WorkflowCore.Sample06.csproj index 47e03b0ee..6d7779ffa 100644 --- a/src/samples/WorkflowCore.Sample06/WorkflowCore.Sample06.csproj +++ b/src/samples/WorkflowCore.Sample06/WorkflowCore.Sample06.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/samples/WorkflowCore.Sample07/Startup.cs b/src/samples/WorkflowCore.Sample07/Startup.cs index 80264f6d2..f5fdd9334 100644 --- a/src/samples/WorkflowCore.Sample07/Startup.cs +++ b/src/samples/WorkflowCore.Sample07/Startup.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using WorkflowCore.Interface; @@ -10,7 +11,6 @@ namespace WorkflowCore.Sample07 { public class Startup { - public void ConfigureServices(IServiceCollection services) { services.AddLogging(); @@ -18,15 +18,14 @@ public void ConfigureServices(IServiceCollection services) services.AddMvc(); } - - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { //loggerFactory.AddConsole(); //start the workflow host var host = app.ApplicationServices.GetService(); host.RegisterWorkflow(); - host.RegisterWorkflow(); + host.RegisterWorkflow(); host.Start(); if (env.IsDevelopment()) @@ -34,7 +33,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF app.UseDeveloperExceptionPage(); } - app.UseMvc(); + app.UseMvc(); } } } diff --git a/src/samples/WorkflowCore.Sample07/WorkflowCore.Sample07.csproj b/src/samples/WorkflowCore.Sample07/WorkflowCore.Sample07.csproj index 1cc78f66f..753780c2b 100644 --- a/src/samples/WorkflowCore.Sample07/WorkflowCore.Sample07.csproj +++ b/src/samples/WorkflowCore.Sample07/WorkflowCore.Sample07.csproj @@ -22,9 +22,8 @@ - - - + + diff --git a/src/samples/WorkflowCore.Sample08/WorkflowCore.Sample08.csproj b/src/samples/WorkflowCore.Sample08/WorkflowCore.Sample08.csproj index f6ae3bcba..8da96aadc 100644 --- a/src/samples/WorkflowCore.Sample08/WorkflowCore.Sample08.csproj +++ b/src/samples/WorkflowCore.Sample08/WorkflowCore.Sample08.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/samples/WorkflowCore.Sample09/WorkflowCore.Sample09.csproj b/src/samples/WorkflowCore.Sample09/WorkflowCore.Sample09.csproj index e7c7206ec..6619eb1f7 100644 --- a/src/samples/WorkflowCore.Sample09/WorkflowCore.Sample09.csproj +++ b/src/samples/WorkflowCore.Sample09/WorkflowCore.Sample09.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/samples/WorkflowCore.Sample09s/WorkflowCore.Sample09s.csproj b/src/samples/WorkflowCore.Sample09s/WorkflowCore.Sample09s.csproj index 67c94bc64..443145818 100644 --- a/src/samples/WorkflowCore.Sample09s/WorkflowCore.Sample09s.csproj +++ b/src/samples/WorkflowCore.Sample09s/WorkflowCore.Sample09s.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/samples/WorkflowCore.Sample10/WorkflowCore.Sample10.csproj b/src/samples/WorkflowCore.Sample10/WorkflowCore.Sample10.csproj index e7c7206ec..6619eb1f7 100644 --- a/src/samples/WorkflowCore.Sample10/WorkflowCore.Sample10.csproj +++ b/src/samples/WorkflowCore.Sample10/WorkflowCore.Sample10.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/samples/WorkflowCore.Sample11/WorkflowCore.Sample11.csproj b/src/samples/WorkflowCore.Sample11/WorkflowCore.Sample11.csproj index 106048445..a25c5d053 100644 --- a/src/samples/WorkflowCore.Sample11/WorkflowCore.Sample11.csproj +++ b/src/samples/WorkflowCore.Sample11/WorkflowCore.Sample11.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/src/samples/WorkflowCore.Sample12/WorkflowCore.Sample12.csproj b/src/samples/WorkflowCore.Sample12/WorkflowCore.Sample12.csproj index e0fb0e8aa..d4ab95034 100644 --- a/src/samples/WorkflowCore.Sample12/WorkflowCore.Sample12.csproj +++ b/src/samples/WorkflowCore.Sample12/WorkflowCore.Sample12.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/samples/WorkflowCore.Sample13/WorkflowCore.Sample13.csproj b/src/samples/WorkflowCore.Sample13/WorkflowCore.Sample13.csproj index 522eaac98..2bad708f4 100644 --- a/src/samples/WorkflowCore.Sample13/WorkflowCore.Sample13.csproj +++ b/src/samples/WorkflowCore.Sample13/WorkflowCore.Sample13.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/samples/WorkflowCore.Sample15/WorkflowCore.Sample15.csproj b/src/samples/WorkflowCore.Sample15/WorkflowCore.Sample15.csproj index f8d1df555..098122901 100644 --- a/src/samples/WorkflowCore.Sample15/WorkflowCore.Sample15.csproj +++ b/src/samples/WorkflowCore.Sample15/WorkflowCore.Sample15.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/src/samples/WorkflowCore.Sample16/WorkflowCore.Sample16.csproj b/src/samples/WorkflowCore.Sample16/WorkflowCore.Sample16.csproj index f8d1df555..098122901 100644 --- a/src/samples/WorkflowCore.Sample16/WorkflowCore.Sample16.csproj +++ b/src/samples/WorkflowCore.Sample16/WorkflowCore.Sample16.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/src/samples/WorkflowCore.Sample18/WorkflowCore.Sample18.csproj b/src/samples/WorkflowCore.Sample18/WorkflowCore.Sample18.csproj index c1c6e0846..bb898d4a9 100644 --- a/src/samples/WorkflowCore.Sample18/WorkflowCore.Sample18.csproj +++ b/src/samples/WorkflowCore.Sample18/WorkflowCore.Sample18.csproj @@ -1,14 +1,14 @@ - + Exe - - - - + + + + diff --git a/src/samples/WorkflowCore.Sample19/WorkflowCore.Sample19.csproj b/src/samples/WorkflowCore.Sample19/WorkflowCore.Sample19.csproj index 181b45e66..0410f5157 100644 --- a/src/samples/WorkflowCore.Sample19/WorkflowCore.Sample19.csproj +++ b/src/samples/WorkflowCore.Sample19/WorkflowCore.Sample19.csproj @@ -5,11 +5,11 @@ - - - - - + + + + + diff --git a/src/samples/WorkflowCore.TestSample01/NUnitTest.cs b/src/samples/WorkflowCore.TestSample01/NUnitTest.cs index 167c97441..ccf777e73 100644 --- a/src/samples/WorkflowCore.TestSample01/NUnitTest.cs +++ b/src/samples/WorkflowCore.TestSample01/NUnitTest.cs @@ -11,7 +11,7 @@ namespace WorkflowCore.TestSample01 public class NUnitTest : WorkflowTest { [SetUp] - protected void Setup() + protected override void Setup() { base.Setup(); } diff --git a/src/samples/WorkflowCore.TestSample01/WorkflowCore.TestSample01.csproj b/src/samples/WorkflowCore.TestSample01/WorkflowCore.TestSample01.csproj index 308565745..f593223ec 100644 --- a/src/samples/WorkflowCore.TestSample01/WorkflowCore.TestSample01.csproj +++ b/src/samples/WorkflowCore.TestSample01/WorkflowCore.TestSample01.csproj @@ -1,13 +1,13 @@  - - - - - - - + + + + + + + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 3b2ad7341..d3e80a5ab 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,24 +1,25 @@ - - net6.0;netcoreapp3.1 - latest - false - + + net6.0;netcoreapp3.1 + latest + false + - - - - - - - - - - - - + + + true + $(NoWarn);NETSDK1138 + + + + + + + + + + + + - - - \ No newline at end of file diff --git a/test/Docker.Testify/Docker.Testify.csproj b/test/Docker.Testify/Docker.Testify.csproj index a83648df4..414cba031 100644 --- a/test/Docker.Testify/Docker.Testify.csproj +++ b/test/Docker.Testify/Docker.Testify.csproj @@ -1,9 +1,7 @@  - - - - + + diff --git a/test/WorkflowCore.IntegrationTests/Scenarios/ActivityScenario.cs b/test/WorkflowCore.IntegrationTests/Scenarios/ActivityScenario.cs index 1e082f4db..cafa42816 100644 --- a/test/WorkflowCore.IntegrationTests/Scenarios/ActivityScenario.cs +++ b/test/WorkflowCore.IntegrationTests/Scenarios/ActivityScenario.cs @@ -5,6 +5,7 @@ using FluentAssertions; using System.Linq; using WorkflowCore.Testing; +using System.Threading.Tasks; namespace WorkflowCore.IntegrationTests.Scenarios { @@ -47,16 +48,16 @@ public ActivityScenario() } [Fact] - public void Scenario() + public async Task Scenario() { var workflowId = StartWorkflow(new MyDataClass { ActivityInput = new ActivityInput { Value1 = "a", Value2 = 1 } }); - var activity = Host.GetPendingActivity("act-1", "worker1", TimeSpan.FromSeconds(30)).Result; + var activity = await Host.GetPendingActivity("act-1", "worker1", TimeSpan.FromSeconds(30)); if (activity != null) { var actInput = (ActivityInput)activity.Parameters; - Host.SubmitActivitySuccess(activity.Token, new ActivityOutput - { + await Host.SubmitActivitySuccess(activity.Token, new ActivityOutput + { Value1 = actInput.Value1 + "1", Value2 = actInput.Value2 + 1 }); diff --git a/test/WorkflowCore.IntegrationTests/Scenarios/ForkScenario.cs b/test/WorkflowCore.IntegrationTests/Scenarios/ForkScenario.cs index 89a9b46e0..97088093d 100644 --- a/test/WorkflowCore.IntegrationTests/Scenarios/ForkScenario.cs +++ b/test/WorkflowCore.IntegrationTests/Scenarios/ForkScenario.cs @@ -3,9 +3,11 @@ using WorkflowCore.Models; using Xunit; using FluentAssertions; +using System.Threading.Tasks; namespace WorkflowCore.IntegrationTests.Scenarios { + [Obsolete] public class ForkScenario : BaseScenario { static int TaskATicker = 0; @@ -57,16 +59,16 @@ public void Build(IWorkflowBuilder builder) } [Fact] - public void Scenario() + public async Task Scenario() { - var workflowId = Host.StartWorkflow("OutcomeFork").Result; - var instance = PersistenceProvider.GetWorkflowInstance(workflowId).Result; + var workflowId = await Host.StartWorkflow("OutcomeFork"); + var instance = await PersistenceProvider.GetWorkflowInstance(workflowId); int counter = 0; while ((instance.Status == WorkflowStatus.Runnable) && (counter < 300)) { System.Threading.Thread.Sleep(100); counter++; - instance = PersistenceProvider.GetWorkflowInstance(workflowId).Result; + instance = await PersistenceProvider.GetWorkflowInstance(workflowId); } instance.Status.Should().Be(WorkflowStatus.Complete); diff --git a/test/WorkflowCore.IntegrationTests/Scenarios/UserScenario.cs b/test/WorkflowCore.IntegrationTests/Scenarios/UserScenario.cs index 66d442018..9984ffe76 100644 --- a/test/WorkflowCore.IntegrationTests/Scenarios/UserScenario.cs +++ b/test/WorkflowCore.IntegrationTests/Scenarios/UserScenario.cs @@ -5,6 +5,7 @@ using FluentAssertions; using System.Linq; using WorkflowCore.Testing; +using System.Threading.Tasks; namespace WorkflowCore.IntegrationTests.Scenarios { @@ -37,7 +38,7 @@ public UserScenario() } [Fact] - public void Scenario() + public async Task Scenario() { var workflowId = StartWorkflow(null); var counter = 0; @@ -50,11 +51,11 @@ public void Scenario() var openItems1 = Host.GetOpenUserActions(workflowId).ToList(); - Host.PublishUserAction(openItems1.First().Key, "user1", "yes").Wait(); + await Host.PublishUserAction(openItems1.First().Key, "user1", "yes"); WaitForWorkflowToComplete(workflowId, TimeSpan.FromSeconds(30)); - var openItems2 = Host.GetOpenUserActions(workflowId); + var openItems2 = Host.GetOpenUserActions(workflowId); ApproveStepTicker.Should().Be(1); DisapproveStepTicker.Should().Be(0); diff --git a/test/WorkflowCore.IntegrationTests/WorkflowCore.IntegrationTests.csproj b/test/WorkflowCore.IntegrationTests/WorkflowCore.IntegrationTests.csproj index bdc973728..c077184d3 100644 --- a/test/WorkflowCore.IntegrationTests/WorkflowCore.IntegrationTests.csproj +++ b/test/WorkflowCore.IntegrationTests/WorkflowCore.IntegrationTests.csproj @@ -17,7 +17,7 @@ - + diff --git a/test/WorkflowCore.TestAssets/WorkflowCore.TestAssets.csproj b/test/WorkflowCore.TestAssets/WorkflowCore.TestAssets.csproj index cbba0dccb..b217dfe6d 100644 --- a/test/WorkflowCore.TestAssets/WorkflowCore.TestAssets.csproj +++ b/test/WorkflowCore.TestAssets/WorkflowCore.TestAssets.csproj @@ -38,8 +38,8 @@ - - + + diff --git a/test/WorkflowCore.Tests.DynamoDB/WorkflowCore.Tests.DynamoDB.csproj b/test/WorkflowCore.Tests.DynamoDB/WorkflowCore.Tests.DynamoDB.csproj index 65320489d..713f59d8c 100644 --- a/test/WorkflowCore.Tests.DynamoDB/WorkflowCore.Tests.DynamoDB.csproj +++ b/test/WorkflowCore.Tests.DynamoDB/WorkflowCore.Tests.DynamoDB.csproj @@ -1,7 +1,7 @@ - + diff --git a/test/WorkflowCore.Tests.Elasticsearch/WorkflowCore.Tests.Elasticsearch.csproj b/test/WorkflowCore.Tests.Elasticsearch/WorkflowCore.Tests.Elasticsearch.csproj index 9aa005f40..2eeb7d813 100644 --- a/test/WorkflowCore.Tests.Elasticsearch/WorkflowCore.Tests.Elasticsearch.csproj +++ b/test/WorkflowCore.Tests.Elasticsearch/WorkflowCore.Tests.Elasticsearch.csproj @@ -1,7 +1,7 @@  - + diff --git a/test/WorkflowCore.Tests.MongoDB/Scenarios/MongoForkScenario.cs b/test/WorkflowCore.Tests.MongoDB/Scenarios/MongoForkScenario.cs index f582f0e7b..80ab9db5f 100644 --- a/test/WorkflowCore.Tests.MongoDB/Scenarios/MongoForkScenario.cs +++ b/test/WorkflowCore.Tests.MongoDB/Scenarios/MongoForkScenario.cs @@ -6,6 +6,7 @@ namespace WorkflowCore.Tests.MongoDB.Scenarios { [Collection("Mongo collection")] + [Obsolete] public class MongoForkScenario : ForkScenario { protected override void Configure(IServiceCollection services) diff --git a/test/WorkflowCore.Tests.MongoDB/WorkflowCore.Tests.MongoDB.csproj b/test/WorkflowCore.Tests.MongoDB/WorkflowCore.Tests.MongoDB.csproj index c708f7bf3..12d036d24 100644 --- a/test/WorkflowCore.Tests.MongoDB/WorkflowCore.Tests.MongoDB.csproj +++ b/test/WorkflowCore.Tests.MongoDB/WorkflowCore.Tests.MongoDB.csproj @@ -20,8 +20,8 @@ - - + + diff --git a/test/WorkflowCore.Tests.MySQL/Scenarios/MysqlForkScenario.cs b/test/WorkflowCore.Tests.MySQL/Scenarios/MysqlForkScenario.cs index 8a57e465b..fffefaee3 100644 --- a/test/WorkflowCore.Tests.MySQL/Scenarios/MysqlForkScenario.cs +++ b/test/WorkflowCore.Tests.MySQL/Scenarios/MysqlForkScenario.cs @@ -6,6 +6,7 @@ namespace WorkflowCore.Tests.MySQL.Scenarios { [Collection("Mysql collection")] + [Obsolete] public class MysqlForkScenario : ForkScenario { protected override void Configure(IServiceCollection services) diff --git a/test/WorkflowCore.Tests.MySQL/WorkflowCore.Tests.MySQL.csproj b/test/WorkflowCore.Tests.MySQL/WorkflowCore.Tests.MySQL.csproj index a56acc9b7..d11895dee 100644 --- a/test/WorkflowCore.Tests.MySQL/WorkflowCore.Tests.MySQL.csproj +++ b/test/WorkflowCore.Tests.MySQL/WorkflowCore.Tests.MySQL.csproj @@ -1,7 +1,8 @@ - + + diff --git a/test/WorkflowCore.Tests.PostgreSQL/Scenarios/PostgresForkScenario.cs b/test/WorkflowCore.Tests.PostgreSQL/Scenarios/PostgresForkScenario.cs index 4ad8fe86a..c1447ae5e 100644 --- a/test/WorkflowCore.Tests.PostgreSQL/Scenarios/PostgresForkScenario.cs +++ b/test/WorkflowCore.Tests.PostgreSQL/Scenarios/PostgresForkScenario.cs @@ -6,6 +6,7 @@ namespace WorkflowCore.Tests.PostgreSQL.Scenarios { [Collection("Postgres collection")] + [Obsolete] public class PostgresForkScenario : ForkScenario { protected override void Configure(IServiceCollection services) diff --git a/test/WorkflowCore.Tests.PostgreSQL/WorkflowCore.Tests.PostgreSQL.csproj b/test/WorkflowCore.Tests.PostgreSQL/WorkflowCore.Tests.PostgreSQL.csproj index 66cc649b4..a98afd491 100644 --- a/test/WorkflowCore.Tests.PostgreSQL/WorkflowCore.Tests.PostgreSQL.csproj +++ b/test/WorkflowCore.Tests.PostgreSQL/WorkflowCore.Tests.PostgreSQL.csproj @@ -20,7 +20,7 @@ - + diff --git a/test/WorkflowCore.Tests.QueueProviders.RabbitMQ/WorkflowCore.Tests.QueueProviders.RabbitMQ.csproj b/test/WorkflowCore.Tests.QueueProviders.RabbitMQ/WorkflowCore.Tests.QueueProviders.RabbitMQ.csproj index 98e658fed..b03a5c6d5 100644 --- a/test/WorkflowCore.Tests.QueueProviders.RabbitMQ/WorkflowCore.Tests.QueueProviders.RabbitMQ.csproj +++ b/test/WorkflowCore.Tests.QueueProviders.RabbitMQ/WorkflowCore.Tests.QueueProviders.RabbitMQ.csproj @@ -1,7 +1,7 @@ - + diff --git a/test/WorkflowCore.Tests.Redis/WorkflowCore.Tests.Redis.csproj b/test/WorkflowCore.Tests.Redis/WorkflowCore.Tests.Redis.csproj index 147dad6da..dea7d8fb0 100644 --- a/test/WorkflowCore.Tests.Redis/WorkflowCore.Tests.Redis.csproj +++ b/test/WorkflowCore.Tests.Redis/WorkflowCore.Tests.Redis.csproj @@ -1,8 +1,8 @@ - - + + diff --git a/test/WorkflowCore.Tests.SqlServer/WorkflowCore.Tests.SqlServer.csproj b/test/WorkflowCore.Tests.SqlServer/WorkflowCore.Tests.SqlServer.csproj index 24e83536e..ef4793f7c 100644 --- a/test/WorkflowCore.Tests.SqlServer/WorkflowCore.Tests.SqlServer.csproj +++ b/test/WorkflowCore.Tests.SqlServer/WorkflowCore.Tests.SqlServer.csproj @@ -1,7 +1,7 @@  - + diff --git a/test/WorkflowCore.UnitTests/BasePersistenceFixture.cs b/test/WorkflowCore.UnitTests/BasePersistenceFixture.cs index 9114da7b9..b935a4574 100644 --- a/test/WorkflowCore.UnitTests/BasePersistenceFixture.cs +++ b/test/WorkflowCore.UnitTests/BasePersistenceFixture.cs @@ -15,7 +15,7 @@ public abstract class BasePersistenceFixture protected abstract IPersistenceProvider Subject { get; } [Fact] - public void CreateNewWorkflow_should_generate_id() + public async Task CreateNewWorkflow_should_generate_id() { var workflow = new WorkflowInstance { @@ -33,14 +33,14 @@ public void CreateNewWorkflow_should_generate_id() StepId = 0 }); - var workflowId = Subject.CreateNewWorkflow(workflow).Result; + var workflowId = await Subject.CreateNewWorkflow(workflow); workflowId.Should().NotBeNull(); workflow.Id.Should().NotBeNull(); } [Fact] - public void GetWorkflowInstance_should_retrieve_workflow() + public async Task GetWorkflowInstance_should_retrieve_workflow() { var workflow = new WorkflowInstance { @@ -60,9 +60,9 @@ public void GetWorkflowInstance_should_retrieve_workflow() SleepUntil = new DateTime(2000, 1, 1).ToUniversalTime(), Scope = new List { "4", "3", "2", "1" } }); - var workflowId = Subject.CreateNewWorkflow(workflow).Result; + var workflowId = await Subject.CreateNewWorkflow(workflow); - var retrievedWorkflow = Subject.GetWorkflowInstance(workflowId).Result; + var retrievedWorkflow = await Subject.GetWorkflowInstance(workflowId); retrievedWorkflow.ShouldBeEquivalentTo(workflow); retrievedWorkflow.ExecutionPointers.FindById("1") @@ -70,7 +70,7 @@ public void GetWorkflowInstance_should_retrieve_workflow() } [Fact] - public void GetWorkflowInstances_should_retrieve_workflows() + public async Task GetWorkflowInstances_should_retrieve_workflows() { var workflow01 = new WorkflowInstance { @@ -90,7 +90,7 @@ public void GetWorkflowInstances_should_retrieve_workflows() SleepUntil = new DateTime(2000, 1, 1).ToUniversalTime(), Scope = new List { "4", "3", "2", "1" } }); - var workflowId01 = Subject.CreateNewWorkflow(workflow01).Result; + var workflowId01 = await Subject.CreateNewWorkflow(workflow01); var workflow02 = new WorkflowInstance { @@ -110,7 +110,7 @@ public void GetWorkflowInstances_should_retrieve_workflows() SleepUntil = new DateTime(2000, 1, 1).ToUniversalTime(), Scope = new List { "4", "3", "2", "1" } }); - var workflowId02 = Subject.CreateNewWorkflow(workflow02).Result; + var workflowId02 = await Subject.CreateNewWorkflow(workflow02); var workflow03 = new WorkflowInstance { @@ -130,9 +130,9 @@ public void GetWorkflowInstances_should_retrieve_workflows() SleepUntil = new DateTime(2000, 1, 1).ToUniversalTime(), Scope = new List { "4", "3", "2", "1" } }); - var workflowId03 = Subject.CreateNewWorkflow(workflow03).Result; + var workflowId03 = await Subject.CreateNewWorkflow(workflow03); - var retrievedWorkflows = Subject.GetWorkflowInstances(new[] { workflowId01, workflowId02, workflowId03 }).Result; + var retrievedWorkflows = await Subject.GetWorkflowInstances(new[] { workflowId01, workflowId02, workflowId03 }); retrievedWorkflows.Count().ShouldBeEquivalentTo(3); @@ -153,7 +153,7 @@ public void GetWorkflowInstances_should_retrieve_workflows() } [Fact] - public void PersistWorkflow() + public async Task PersistWorkflow() { var oldWorkflow = new WorkflowInstance { @@ -173,21 +173,21 @@ public void PersistWorkflow() StepId = 0, Scope = new List { "1", "2", "3", "4" } }); - var workflowId = Subject.CreateNewWorkflow(oldWorkflow).Result; + var workflowId = await Subject.CreateNewWorkflow(oldWorkflow); var newWorkflow = Utils.DeepCopy(oldWorkflow); newWorkflow.Data = oldWorkflow.Data; newWorkflow.Reference = oldWorkflow.Reference; newWorkflow.NextExecution = 7; newWorkflow.ExecutionPointers.Add(new ExecutionPointer { Id = Guid.NewGuid().ToString(), Active = true, StepId = 1 }); - Subject.PersistWorkflow(newWorkflow).Wait(); + await Subject.PersistWorkflow(newWorkflow); - var current = Subject.GetWorkflowInstance(workflowId).Result; + var current = await Subject.GetWorkflowInstance(workflowId); current.ShouldBeEquivalentTo(newWorkflow); } [Fact] - public void PersistWorkflow_with_subscriptions() + public async Task PersistWorkflow_with_subscriptions() { var workflow = new WorkflowInstance { @@ -220,7 +220,7 @@ public void PersistWorkflow_with_subscriptions() EventName = "Event2", }); - var workflowId = Subject.CreateNewWorkflow(workflow).Result; + var workflowId = await Subject.CreateNewWorkflow(workflow); workflow.NextExecution = 0; List subscriptions = new List(); @@ -240,14 +240,14 @@ public void PersistWorkflow_with_subscriptions() subscriptions.Add(subscription); } - Subject.PersistWorkflow(workflow, subscriptions).Wait(); + await Subject.PersistWorkflow(workflow, subscriptions); - var current = Subject.GetWorkflowInstance(workflowId).Result; + var current = await Subject.GetWorkflowInstance(workflowId); current.ShouldBeEquivalentTo(workflow); foreach (var pointer in workflow.ExecutionPointers) { - subscriptions = Subject.GetSubscriptions(pointer.EventName, workflowId, DateTime.UtcNow).Result.ToList(); + subscriptions = (await Subject.GetSubscriptions(pointer.EventName, workflowId, DateTime.UtcNow)).ToList(); subscriptions.Should().HaveCount(1); } }