From 93f54de2a823bd2606060b33429402a68ee6268e Mon Sep 17 00:00:00 2001 From: Chris Patterson Date: Thu, 15 Sep 2016 10:13:43 -0700 Subject: [PATCH] Moving to Green Pipes for pipe context usage --- ...onymous.NHibernateIntegration.Tests.csproj | 4 + ...utomatonymous.NHibernateIntegration.csproj | 4 + .../Automatonymous.Tests.csproj | 4 + .../StateChangeObserver.cs | 7 +- .../Automatonymous.Visualizer.csproj | 4 + src/Automatonymous.sln | 8 +- src/Automatonymous.sln.DotSettings | 1 + .../Accessors/InitialIfNullStateAccessor.cs | 6 +- .../IntCompositeEventStatusAccessor.cs | 4 +- .../Accessors/IntStateAccessor.cs | 6 +- .../Accessors/RawStateAccessor.cs | 6 +- .../Accessors/StringStateAccessor.cs | 7 +- .../StructCompositeEventStatusAccessor.cs | 4 +- .../Activities/ActionActivity.cs | 6 +- .../Activities/AsyncActivity.cs | 12 +- .../Activities/AsyncFactoryActivity.cs | 12 +- .../Activities/CatchFaultActivity.cs | 12 +- .../Activities/CompositeEventActivity.cs | 15 +- .../Activities/DataConverterActivity.cs | 4 +- .../Activities/FactoryActivity.cs | 8 +- .../Activities/FaultedActionActivity.cs | 14 +- src/Automatonymous/Activities/SlimActivity.cs | 4 +- .../Activities/TransitionActivity.cs | 34 ++-- src/Automatonymous/Automatonymous.csproj | 18 +- .../AutomatonymousStateMachine.cs | 10 +- .../Behaviors/ActivityBehavior.cs | 23 +-- src/Automatonymous/Behaviors/EmptyBehavior.cs | 4 +- .../Behaviors/ExceptionBehavior.cs | 4 +- .../Behaviors/ExceptionTypeCache.cs | 8 +- .../Contexts/BehaviorContextProxy.cs | 40 +---- .../Contexts/BehaviorExceptionContextProxy.cs | 39 +---- .../Contexts/EventBehaviorContext.cs | 27 +-- .../Contexts/EventContextProxy.cs | 41 +---- src/Automatonymous/Contexts/PayloadCache.cs | 107 ------------ .../Contexts/StateMachineEventContext.cs | 46 +++--- .../Contexts/StateMachineInstanceContext.cs | 32 +--- .../Contexts/StateUnhandledEventContext.cs | 28 +--- .../Exceptions/PayloadException.cs | 30 ---- .../Exceptions/PayloadFactoryException.cs | 30 ---- .../Exceptions/PayloadNotFoundException.cs | 30 ---- src/Automatonymous/InstanceContext.cs | 38 +---- src/Automatonymous/Internals/Connectable.cs | 154 ------------------ .../Internals/ExpressionExtensions.cs | 67 -------- .../Internals/ReadOnlyProperty.cs | 45 ----- .../Internals/ReadWriteProperty.cs | 44 ----- src/Automatonymous/Internals/TaskUtil.cs | 42 ----- src/Automatonymous/IntrospectionExtensions.cs | 2 +- .../Observers/EventObservable.cs | 16 +- .../Observers/NonTransitionEventObserver.cs | 4 +- .../Observers/SelectedEventObserver.cs | 4 +- .../Observers/StateObservable.cs | 6 +- src/Automatonymous/PayloadFactory.cs | 17 -- src/Automatonymous/StateChanged.cs | 22 --- .../States/StateMachineState.cs | 26 +-- src/Automatonymous/ThenExtensions.cs | 2 +- 55 files changed, 232 insertions(+), 960 deletions(-) delete mode 100644 src/Automatonymous/Contexts/PayloadCache.cs delete mode 100644 src/Automatonymous/Exceptions/PayloadException.cs delete mode 100644 src/Automatonymous/Exceptions/PayloadFactoryException.cs delete mode 100644 src/Automatonymous/Exceptions/PayloadNotFoundException.cs delete mode 100644 src/Automatonymous/Internals/Connectable.cs delete mode 100644 src/Automatonymous/Internals/ExpressionExtensions.cs delete mode 100644 src/Automatonymous/Internals/ReadOnlyProperty.cs delete mode 100644 src/Automatonymous/Internals/ReadWriteProperty.cs delete mode 100644 src/Automatonymous/Internals/TaskUtil.cs delete mode 100644 src/Automatonymous/PayloadFactory.cs delete mode 100644 src/Automatonymous/StateChanged.cs diff --git a/src/Automatonymous.NHibernateIntegration.Tests/Automatonymous.NHibernateIntegration.Tests.csproj b/src/Automatonymous.NHibernateIntegration.Tests/Automatonymous.NHibernateIntegration.Tests.csproj index f8011eb..07c0a2b 100644 --- a/src/Automatonymous.NHibernateIntegration.Tests/Automatonymous.NHibernateIntegration.Tests.csproj +++ b/src/Automatonymous.NHibernateIntegration.Tests/Automatonymous.NHibernateIntegration.Tests.csproj @@ -75,6 +75,10 @@ + + {59052db9-b527-4683-a56a-56c4d8fb6584} + GreenPipes + {c0932502-0847-4966-8d0a-2ca80b1669ed} Automatonymous.NHibernateIntegration diff --git a/src/Automatonymous.NHibernateIntegration/Automatonymous.NHibernateIntegration.csproj b/src/Automatonymous.NHibernateIntegration/Automatonymous.NHibernateIntegration.csproj index b59131b..b3b530f 100644 --- a/src/Automatonymous.NHibernateIntegration/Automatonymous.NHibernateIntegration.csproj +++ b/src/Automatonymous.NHibernateIntegration/Automatonymous.NHibernateIntegration.csproj @@ -60,6 +60,10 @@ + + {59052db9-b527-4683-a56a-56c4d8fb6584} + GreenPipes + {fd8f92eb-5818-4c59-8859-19d3a74f979b} Automatonymous diff --git a/src/Automatonymous.Tests/Automatonymous.Tests.csproj b/src/Automatonymous.Tests/Automatonymous.Tests.csproj index 5e51133..4ca02fd 100644 --- a/src/Automatonymous.Tests/Automatonymous.Tests.csproj +++ b/src/Automatonymous.Tests/Automatonymous.Tests.csproj @@ -83,6 +83,10 @@ + + {59052db9-b527-4683-a56a-56c4d8fb6584} + GreenPipes + {CD346A24-EEBB-493C-AAC0-E9896340B66A} Automatonymous.Visualizer diff --git a/src/Automatonymous.Tests/StateChangeObserver.cs b/src/Automatonymous.Tests/StateChangeObserver.cs index 50e2251..356a99a 100644 --- a/src/Automatonymous.Tests/StateChangeObserver.cs +++ b/src/Automatonymous.Tests/StateChangeObserver.cs @@ -1,4 +1,4 @@ -// Copyright 2011-2015 Chris Patterson, Dru Sellers +// Copyright 2011-2016 Chris Patterson, Dru Sellers // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the @@ -14,6 +14,7 @@ namespace Automatonymous.Tests { using System.Collections.Generic; using System.Threading.Tasks; + using GreenPipes.Util; class StateChangeObserver : @@ -27,9 +28,11 @@ public StateChangeObserver() public IList Events { get; private set; } - public async Task StateChanged(InstanceContext context, State currentState, State previousState) + public Task StateChanged(InstanceContext context, State currentState, State previousState) { Events.Add(new StateChange(context, currentState, previousState)); + + return TaskUtil.Completed; } diff --git a/src/Automatonymous.Visualizer/Automatonymous.Visualizer.csproj b/src/Automatonymous.Visualizer/Automatonymous.Visualizer.csproj index 0e547f7..575d183 100644 --- a/src/Automatonymous.Visualizer/Automatonymous.Visualizer.csproj +++ b/src/Automatonymous.Visualizer/Automatonymous.Visualizer.csproj @@ -61,6 +61,10 @@ + + {59052db9-b527-4683-a56a-56c4d8fb6584} + GreenPipes + {FD8F92EB-5818-4C59-8859-19D3A74F979B} Automatonymous diff --git a/src/Automatonymous.sln b/src/Automatonymous.sln index 5cf4576..998c2a8 100644 --- a/src/Automatonymous.sln +++ b/src/Automatonymous.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Automatonymous", "Automatonymous\Automatonymous.csproj", "{FD8F92EB-5818-4C59-8859-19D3A74F979B}" EndProject @@ -24,6 +24,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{2EF18B .nuget\NuGet.targets = .nuget\NuGet.targets EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenPipes", "..\..\GreenPipes\src\GreenPipes\GreenPipes.csproj", "{59052DB9-B527-4683-A56A-56C4D8FB6584}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -50,6 +52,10 @@ Global {06A25528-1537-4E70-85E2-CC979B924417}.Debug|Any CPU.Build.0 = Debug|Any CPU {06A25528-1537-4E70-85E2-CC979B924417}.Release|Any CPU.ActiveCfg = Release|Any CPU {06A25528-1537-4E70-85E2-CC979B924417}.Release|Any CPU.Build.0 = Release|Any CPU + {59052DB9-B527-4683-A56A-56C4D8FB6584}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {59052DB9-B527-4683-A56A-56C4D8FB6584}.Debug|Any CPU.Build.0 = Debug|Any CPU + {59052DB9-B527-4683-A56A-56C4D8FB6584}.Release|Any CPU.ActiveCfg = Release|Any CPU + {59052DB9-B527-4683-A56A-56C4D8FB6584}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Automatonymous.sln.DotSettings b/src/Automatonymous.sln.DotSettings index df07c12..aa1db51 100644 --- a/src/Automatonymous.sln.DotSettings +++ b/src/Automatonymous.sln.DotSettings @@ -6,6 +6,7 @@ 2 False False + True LINE_BREAK False True diff --git a/src/Automatonymous/Accessors/InitialIfNullStateAccessor.cs b/src/Automatonymous/Accessors/InitialIfNullStateAccessor.cs index 1fbad45..7f5509a 100644 --- a/src/Automatonymous/Accessors/InitialIfNullStateAccessor.cs +++ b/src/Automatonymous/Accessors/InitialIfNullStateAccessor.cs @@ -35,14 +35,14 @@ public InitialIfNullStateAccessor(State initialState, StateAccessor> StateAccessor.Get(InstanceContext context) { - State state = await _stateAccessor.Get(context); + State state = await _stateAccessor.Get(context).ConfigureAwait(false); if (state == null) { var behaviorContext = new EventBehaviorContext(context); - await _initialBehavior.Execute(behaviorContext); + await _initialBehavior.Execute(behaviorContext).ConfigureAwait(false); - state = await _stateAccessor.Get(context); + state = await _stateAccessor.Get(context).ConfigureAwait(false); } return state; } diff --git a/src/Automatonymous/Accessors/IntCompositeEventStatusAccessor.cs b/src/Automatonymous/Accessors/IntCompositeEventStatusAccessor.cs index 02fd95c..c8bfaee 100644 --- a/src/Automatonymous/Accessors/IntCompositeEventStatusAccessor.cs +++ b/src/Automatonymous/Accessors/IntCompositeEventStatusAccessor.cs @@ -1,4 +1,4 @@ -// Copyright 2011-2015 Chris Patterson, Dru Sellers +// Copyright 2011-2016 Chris Patterson, Dru Sellers // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the @@ -13,7 +13,7 @@ namespace Automatonymous.Accessors { using System.Reflection; - using Internals; + using GreenPipes.Internals.Reflection; public class IntCompositeEventStatusAccessor : diff --git a/src/Automatonymous/Accessors/IntStateAccessor.cs b/src/Automatonymous/Accessors/IntStateAccessor.cs index 8da3bb6..b205e5a 100644 --- a/src/Automatonymous/Accessors/IntStateAccessor.cs +++ b/src/Automatonymous/Accessors/IntStateAccessor.cs @@ -1,4 +1,4 @@ -// Copyright 2011-2015 Chris Patterson, Dru Sellers +// Copyright 2011-2016 Chris Patterson, Dru Sellers // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the @@ -16,7 +16,9 @@ namespace Automatonymous.Accessors using System.Linq.Expressions; using System.Reflection; using System.Threading.Tasks; - using Internals; + using GreenPipes.Internals.Extensions; + using GreenPipes.Internals.Reflection; + using GreenPipes.Util; /// diff --git a/src/Automatonymous/Accessors/RawStateAccessor.cs b/src/Automatonymous/Accessors/RawStateAccessor.cs index c162489..b7c8d78 100644 --- a/src/Automatonymous/Accessors/RawStateAccessor.cs +++ b/src/Automatonymous/Accessors/RawStateAccessor.cs @@ -1,4 +1,4 @@ -// Copyright 2011-2015 Chris Patterson, Dru Sellers +// Copyright 2011-2016 Chris Patterson, Dru Sellers // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the @@ -16,7 +16,9 @@ namespace Automatonymous.Accessors using System.Linq.Expressions; using System.Reflection; using System.Threading.Tasks; - using Internals; + using GreenPipes.Internals.Extensions; + using GreenPipes.Internals.Reflection; + using GreenPipes.Util; public class RawStateAccessor : diff --git a/src/Automatonymous/Accessors/StringStateAccessor.cs b/src/Automatonymous/Accessors/StringStateAccessor.cs index 222186e..faa4033 100644 --- a/src/Automatonymous/Accessors/StringStateAccessor.cs +++ b/src/Automatonymous/Accessors/StringStateAccessor.cs @@ -1,4 +1,4 @@ -// Copyright 2011-2015 Chris Patterson, Dru Sellers +// Copyright 2011-2016 Chris Patterson, Dru Sellers // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the @@ -16,7 +16,10 @@ namespace Automatonymous.Accessors using System.Linq.Expressions; using System.Reflection; using System.Threading.Tasks; - using Internals; + using GreenPipes.Internals.Extensions; + using GreenPipes.Internals.Reflection; + using GreenPipes.Util; + /// /// Accesses the current state as a string property diff --git a/src/Automatonymous/Accessors/StructCompositeEventStatusAccessor.cs b/src/Automatonymous/Accessors/StructCompositeEventStatusAccessor.cs index e495ec9..93f0f02 100644 --- a/src/Automatonymous/Accessors/StructCompositeEventStatusAccessor.cs +++ b/src/Automatonymous/Accessors/StructCompositeEventStatusAccessor.cs @@ -1,4 +1,4 @@ -// Copyright 2011-2015 Chris Patterson, Dru Sellers +// Copyright 2011-2016 Chris Patterson, Dru Sellers // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the @@ -13,7 +13,7 @@ namespace Automatonymous.Accessors { using System.Reflection; - using Internals; + using GreenPipes.Internals.Reflection; public class StructCompositeEventStatusAccessor : diff --git a/src/Automatonymous/Activities/ActionActivity.cs b/src/Automatonymous/Activities/ActionActivity.cs index 1bea766..8942de6 100644 --- a/src/Automatonymous/Activities/ActionActivity.cs +++ b/src/Automatonymous/Activities/ActionActivity.cs @@ -35,14 +35,14 @@ async Task Activity.Execute(BehaviorContext context, Behav { _action(context); - await next.Execute(context); + await next.Execute(context).ConfigureAwait(false); } async Task Activity.Execute(BehaviorContext context, Behavior next) { _action(context); - await next.Execute(context); + await next.Execute(context).ConfigureAwait(false); } Task Activity.Faulted(BehaviorExceptionContext context, Behavior next) @@ -76,7 +76,7 @@ async Task Activity.Execute(BehaviorContext { _action(context); - await next.Execute(context); + await next.Execute(context).ConfigureAwait(false); } Task Activity.Faulted(BehaviorExceptionContext context, Behavior next) diff --git a/src/Automatonymous/Activities/AsyncActivity.cs b/src/Automatonymous/Activities/AsyncActivity.cs index 28885c1..f003e69 100644 --- a/src/Automatonymous/Activities/AsyncActivity.cs +++ b/src/Automatonymous/Activities/AsyncActivity.cs @@ -33,16 +33,16 @@ void Visitable.Accept(StateMachineVisitor visitor) async Task Activity.Execute(BehaviorContext context, Behavior next) { - await _asyncAction(context); + await _asyncAction(context).ConfigureAwait(false); - await next.Execute(context); + await next.Execute(context).ConfigureAwait(false); } async Task Activity.Execute(BehaviorContext context, Behavior next) { - await _asyncAction(context); + await _asyncAction(context).ConfigureAwait(false); - await next.Execute(context); + await next.Execute(context).ConfigureAwait(false); } Task Activity.Faulted(BehaviorExceptionContext context, Behavior next) @@ -75,9 +75,9 @@ void Visitable.Accept(StateMachineVisitor visitor) async Task Activity.Execute(BehaviorContext context, Behavior next) { - await _asyncAction(context); + await _asyncAction(context).ConfigureAwait(false); - await next.Execute(context); + await next.Execute(context).ConfigureAwait(false); } Task Activity.Faulted(BehaviorExceptionContext context, diff --git a/src/Automatonymous/Activities/AsyncFactoryActivity.cs b/src/Automatonymous/Activities/AsyncFactoryActivity.cs index e3af85f..06d703a 100644 --- a/src/Automatonymous/Activities/AsyncFactoryActivity.cs +++ b/src/Automatonymous/Activities/AsyncFactoryActivity.cs @@ -34,9 +34,9 @@ void Visitable.Accept(StateMachineVisitor visitor) async Task Activity.Execute(BehaviorContext context, Behavior next) { - Activity activity = await _activityFactory(context); + Activity activity = await _activityFactory(context).ConfigureAwait(false); - await activity.Execute(context, next); + await activity.Execute(context, next).ConfigureAwait(false); } Task Activity.Faulted(BehaviorExceptionContext context, @@ -64,18 +64,18 @@ void Visitable.Accept(StateMachineVisitor visitor) async Task Activity.Execute(BehaviorContext context, Behavior next) { - Activity activity = await _activityFactory(context); + Activity activity = await _activityFactory(context).ConfigureAwait(false); - await activity.Execute(context, next); + await activity.Execute(context, next).ConfigureAwait(false); } async Task Activity.Execute(BehaviorContext context, Behavior next) { - Activity activity = await _activityFactory(context); + Activity activity = await _activityFactory(context).ConfigureAwait(false); var upconvert = new WidenBehavior(next, context); - await activity.Execute(context, upconvert); + await activity.Execute(context, upconvert).ConfigureAwait(false); } Task Activity.Faulted(BehaviorExceptionContext context, Behavior next) diff --git a/src/Automatonymous/Activities/CatchFaultActivity.cs b/src/Automatonymous/Activities/CatchFaultActivity.cs index 912ac9a..e456ab8 100644 --- a/src/Automatonymous/Activities/CatchFaultActivity.cs +++ b/src/Automatonymous/Activities/CatchFaultActivity.cs @@ -53,13 +53,13 @@ async Task Activity.Faulted(BehaviorExceptionContext var exceptionContext = context as BehaviorExceptionContext; if (exceptionContext != null) { - await _behavior.Faulted(exceptionContext); + await _behavior.Faulted(exceptionContext).ConfigureAwait(false); // if the compensate returns, we should go forward normally - await next.Execute(context); + await next.Execute(context).ConfigureAwait(false); } else - await next.Faulted(context); + await next.Faulted(context).ConfigureAwait(false); } async Task Activity.Faulted(BehaviorExceptionContext context, @@ -68,13 +68,13 @@ async Task Activity.Faulted(BehaviorExceptionContext; if (exceptionContext != null) { - await _behavior.Faulted(exceptionContext); + await _behavior.Faulted(exceptionContext).ConfigureAwait(false); // if the compensate returns, we should go forward normally - await next.Execute(context); + await next.Execute(context).ConfigureAwait(false); } else - await next.Faulted(context); + await next.Faulted(context).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/src/Automatonymous/Activities/CompositeEventActivity.cs b/src/Automatonymous/Activities/CompositeEventActivity.cs index 593a834..e7892e5 100644 --- a/src/Automatonymous/Activities/CompositeEventActivity.cs +++ b/src/Automatonymous/Activities/CompositeEventActivity.cs @@ -14,6 +14,7 @@ namespace Automatonymous.Activities { using System.Threading.Tasks; using Accessors; + using GreenPipes.Util; public class CompositeEventActivity : @@ -42,19 +43,19 @@ void Visitable.Accept(StateMachineVisitor visitor) async Task Activity.Execute(BehaviorContext context, Behavior next) { - await Execute(context); + await Execute(context).ConfigureAwait(false); - await next.Execute(context); + await next.Execute(context).ConfigureAwait(false); } async Task Activity.Execute(BehaviorContext context, Behavior next) { - await Execute(context); + await Execute(context).ConfigureAwait(false); - await next.Execute(context); + await next.Execute(context).ConfigureAwait(false); } - async Task Execute(BehaviorContext context) + Task Execute(BehaviorContext context) { CompositeEventStatus value = _accessor.Get(context.Instance); value.Set(_flag); @@ -62,9 +63,9 @@ async Task Execute(BehaviorContext context) _accessor.Set(context.Instance, value); if (!value.Equals(_complete)) - return; + return TaskUtil.Completed; - await RaiseCompositeEvent(context); + return RaiseCompositeEvent(context); } Task RaiseCompositeEvent(BehaviorContext context) diff --git a/src/Automatonymous/Activities/DataConverterActivity.cs b/src/Automatonymous/Activities/DataConverterActivity.cs index ba7f35c..ca33e5b 100644 --- a/src/Automatonymous/Activities/DataConverterActivity.cs +++ b/src/Automatonymous/Activities/DataConverterActivity.cs @@ -35,7 +35,7 @@ Task Activity.Execute(BehaviorContext context, Behavior.Execute(BehaviorContext context, Behavior next) + Task Activity.Execute(BehaviorContext context, Behavior next) { var dataContext = context as BehaviorContext; if (dataContext == null) @@ -45,7 +45,7 @@ async Task Activity.Execute(BehaviorContext context, if (dataNext == null) throw new AutomatonymousException("The next behavior was not a valid type"); - await _activity.Execute(dataContext, dataNext); + return _activity.Execute(dataContext, dataNext); } Task Activity.Faulted(BehaviorExceptionContext context, Behavior next) diff --git a/src/Automatonymous/Activities/FactoryActivity.cs b/src/Automatonymous/Activities/FactoryActivity.cs index 0430683..20b6d28 100644 --- a/src/Automatonymous/Activities/FactoryActivity.cs +++ b/src/Automatonymous/Activities/FactoryActivity.cs @@ -32,20 +32,20 @@ void Visitable.Accept(StateMachineVisitor visitor) visitor.Visit(this); } - async Task Activity.Execute(BehaviorContext context, Behavior next) + Task Activity.Execute(BehaviorContext context, Behavior next) { Activity activity = _activityFactory(context); - await activity.Execute(context, next); + return activity.Execute(context, next); } - async Task Activity.Execute(BehaviorContext context, Behavior next) + Task Activity.Execute(BehaviorContext context, Behavior next) { Activity activity = _activityFactory(context); var upconvert = new WidenBehavior(next, context); - await activity.Execute(context, upconvert); + return activity.Execute(context, upconvert); } Task Activity.Faulted(BehaviorExceptionContext context, Behavior next) diff --git a/src/Automatonymous/Activities/FaultedActionActivity.cs b/src/Automatonymous/Activities/FaultedActionActivity.cs index 1f2464f..5486597 100644 --- a/src/Automatonymous/Activities/FaultedActionActivity.cs +++ b/src/Automatonymous/Activities/FaultedActionActivity.cs @@ -1,4 +1,4 @@ -// Copyright 2011-2015 Chris Patterson, Dru Sellers +// Copyright 2011-2016 Chris Patterson, Dru Sellers // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the @@ -42,23 +42,23 @@ Task Activity.Execute(BehaviorContext contex return next.Execute(context); } - async Task Activity.Faulted(BehaviorExceptionContext context, Behavior next) + Task Activity.Faulted(BehaviorExceptionContext context, Behavior next) { var exceptionContext = context as BehaviorExceptionContext; if (exceptionContext != null) _action(exceptionContext); - await next.Faulted(context); + return next.Faulted(context); } - async Task Activity.Faulted(BehaviorExceptionContext context, + Task Activity.Faulted(BehaviorExceptionContext context, Behavior next) { var exceptionContext = context as BehaviorExceptionContext; if (exceptionContext != null) _action(exceptionContext); - await next.Faulted(context); + return next.Faulted(context); } } @@ -85,14 +85,14 @@ Task Activity.Execute(BehaviorContext contex return next.Execute(context); } - async Task Activity.Faulted(BehaviorExceptionContext context, + Task Activity.Faulted(BehaviorExceptionContext context, Behavior next) { var exceptionContext = context as BehaviorExceptionContext; if (exceptionContext != null) _action(exceptionContext); - await next.Faulted(context); + return next.Faulted(context); } } } \ No newline at end of file diff --git a/src/Automatonymous/Activities/SlimActivity.cs b/src/Automatonymous/Activities/SlimActivity.cs index e1dfa68..fd19e28 100644 --- a/src/Automatonymous/Activities/SlimActivity.cs +++ b/src/Automatonymous/Activities/SlimActivity.cs @@ -36,11 +36,11 @@ void Visitable.Accept(StateMachineVisitor visitor) _activity.Accept(visitor); } - async Task Activity.Execute(BehaviorContext context, Behavior behavior) + Task Activity.Execute(BehaviorContext context, Behavior behavior) { var upconvert = new WidenBehavior(behavior, context); - await _activity.Execute(context, upconvert); + return _activity.Execute(context, upconvert); } Task Activity.Faulted(BehaviorExceptionContext context, Behavior next) diff --git a/src/Automatonymous/Activities/TransitionActivity.cs b/src/Automatonymous/Activities/TransitionActivity.cs index 4eaa690..ca74d3a 100644 --- a/src/Automatonymous/Activities/TransitionActivity.cs +++ b/src/Automatonymous/Activities/TransitionActivity.cs @@ -37,16 +37,16 @@ void Visitable.Accept(StateMachineVisitor visitor) async Task Activity.Execute(BehaviorContext context, Behavior next) { - await Transition(context); + await Transition(context).ConfigureAwait(false); - await next.Execute(context); + await next.Execute(context).ConfigureAwait(false); } async Task Activity.Execute(BehaviorContext context, Behavior next) { - await Transition(context); + await Transition(context).ConfigureAwait(false); - await next.Execute(context); + await next.Execute(context).ConfigureAwait(false); } Task Activity.Faulted(BehaviorExceptionContext context, Behavior next) @@ -61,22 +61,22 @@ Task Activity.Faulted(BehaviorExceptionContext context) { - State currentState = await _currentStateAccessor.Get(context); + State currentState = await _currentStateAccessor.Get(context).ConfigureAwait(false); if (_toState.Equals(currentState)) return; // Homey don't play re-entry, at least not yet. if (currentState != null && !currentState.HasState(_toState)) { - await RaiseCurrentStateLeaveEvents(context, currentState); + await RaiseCurrentStateLeaveEvents(context, currentState).ConfigureAwait(false); } - await RaiseBeforeEnterEvents(context, currentState, _toState); + await RaiseBeforeEnterEvents(context, currentState, _toState).ConfigureAwait(false); - await _currentStateAccessor.Set(context, _toState); + await _currentStateAccessor.Set(context, _toState).ConfigureAwait(false); if (currentState != null) { - await RaiseAfterLeaveEvents(context, currentState, _toState); + await RaiseAfterLeaveEvents(context, currentState, _toState).ConfigureAwait(false); } if (currentState == null || !_toState.HasState(currentState)) @@ -85,13 +85,13 @@ async Task Transition(BehaviorContext context) while (superState != null && (currentState == null || !superState.HasState(currentState))) { BehaviorContext superStateEnterContext = context.GetProxy(superState.Enter); - await superState.Raise(superStateEnterContext); + await superState.Raise(superStateEnterContext).ConfigureAwait(false); superState = superState.SuperState; } BehaviorContext enterContext = context.GetProxy(_toState.Enter); - await _toState.Raise(enterContext); + await _toState.Raise(enterContext).ConfigureAwait(false); } } @@ -100,14 +100,14 @@ async Task RaiseBeforeEnterEvents(BehaviorContext context, State superState = toState.SuperState; if (superState != null && (currentState == null || !superState.HasState(currentState))) { - await RaiseBeforeEnterEvents(context, currentState, superState); + await RaiseBeforeEnterEvents(context, currentState, superState).ConfigureAwait(false); } if (currentState != null && toState.HasState(currentState)) return; BehaviorContext beforeContext = context.GetProxy(toState.BeforeEnter, toState); - await toState.Raise(beforeContext); + await toState.Raise(beforeContext).ConfigureAwait(false); } async Task RaiseAfterLeaveEvents(BehaviorContext context, State fromState, State toState) @@ -116,25 +116,25 @@ async Task RaiseAfterLeaveEvents(BehaviorContext context, State afterContext = context.GetProxy(fromState.AfterLeave, fromState); - await fromState.Raise(afterContext); + await fromState.Raise(afterContext).ConfigureAwait(false); State superState = fromState.SuperState; if (superState != null) { - await RaiseAfterLeaveEvents(context, superState, toState); + await RaiseAfterLeaveEvents(context, superState, toState).ConfigureAwait(false); } } async Task RaiseCurrentStateLeaveEvents(BehaviorContext context, State fromState) { BehaviorContext leaveContext = context.GetProxy(fromState.Leave); - await fromState.Raise(leaveContext); + await fromState.Raise(leaveContext).ConfigureAwait(false); State superState = fromState.SuperState; while (superState != null && !superState.HasState(_toState)) { BehaviorContext superStateLeaveContext = context.GetProxy(superState.Leave); - await superState.Raise(superStateLeaveContext); + await superState.Raise(superStateLeaveContext).ConfigureAwait(false); superState = superState.SuperState; } diff --git a/src/Automatonymous/Automatonymous.csproj b/src/Automatonymous/Automatonymous.csproj index 9badc56..cb03dda 100644 --- a/src/Automatonymous/Automatonymous.csproj +++ b/src/Automatonymous/Automatonymous.csproj @@ -98,15 +98,11 @@ - - - - @@ -124,11 +120,6 @@ - - - - - @@ -144,10 +135,8 @@ - - @@ -178,7 +167,12 @@ - + + + {59052db9-b527-4683-a56a-56c4d8fb6584} + GreenPipes + +