-
Notifications
You must be signed in to change notification settings - Fork 803
Even more fluent syntax #369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HenningNT
wants to merge
70
commits into
dotnet-state-machine:dev
Choose a base branch
from
HenningNT:EvenMoreFluentSyntax
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 24 commits
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
67979f9
#102 Submitting fix solution file, and DotGraph output.
HenningNT cadcc0e
Fix: JSonExample project moved into example directory.
2d49948
Update README.md
HenningNT e8e8ca3
Add Parameterized Guard Clauses to PermitIf
trgrote 9a49132
Add PermitDynamicIf<T1[,T2]>
trgrote e639246
Change Guard Condition to Preserve No Arg Guard Description
trgrote f8ea45d
Add Missing PermitIf w/ Parameterized Guard Clauses
trgrote a95dcd8
Update Parameterized Guard Condition Unit Test
trgrote 1b44766
Change Name of GetGuardConditionsMet to just GuardConditionsMet
trgrote 6589502
Update Unit tests with new Accessor
trgrote 0485701
Add IgnoreIf unit Tests
trgrote cb30f43
Update README.md
HenningNT 7ea812e
Add unit tests that should work but don't for some dumb reason
trgrote dbbaa1b
Add more unit tests
trgrote 9396b61
Remove Irrelevenet unit tests
trgrote 119ec5a
Re-add publicly accessible guard checks
trgrote 43a88ce
Add Region Description to converters
trgrote 7782183
Add Missing IgnoreIfs
trgrote 5f67c34
Add missing InternalTransitionIf
trgrote f393f52
Update TryFindLocalHandler to evaluate guard conditions only once
trgrote ccd01e2
Re-add arguments to UnmetGuardConditions that was removed during merge
trgrote 73ca733
Add misssing } to unit test
trgrote 9c740da
#155 Removing old backup folder. The sln file is causing problems for…
db46ce3
Update appveyor.yml
HenningNT a14f1e3
Revert "#102 Submitting fix solution file, and DotGraph output."
a4ba731
Merge branch 'dev' of https://github.com/dotnet-state-machine/statele…
HenningNT cca2a19
Merge branch 'dev' of https://github.com/dotnet-state-machine/statele…
3d4d8bb
Merge pull request #6 from dotnet-state-machine/dev
HenningNT 3f323cc
Merge pull request #7 from dotnet-state-machine/master
HenningNT bf090e5
Added new classes. Added new tests.
HenningNT 3531bad
Added test to fire basic transition.
HenningNT 8142018
Added .If(), not working yet.
HenningNT ef7f754
Added Self() transition.
HenningTorsteinsenBouvet 4739a4c
Added Internal Transition.
HenningTorsteinsenBouvet 83c2e5d
Added more Assert to Fire_Transition_To_EndsUpInAnotherState
HenningTorsteinsenBouvet 9be9889
Added If(), and tests.
HenningTorsteinsenBouvet f548302
Added Do()
HenningTorsteinsenBouvet 7c41e78
Finished Do()
HenningTorsteinsenBouvet fdc25e8
Removed AddTriggerBehaviour in StateConfiguration class.
HenningTorsteinsenBouvet ed26191
Tidy up...
HenningTorsteinsenBouvet 9fd586f
Added test Fire_Transition_To_DoesAsyncAction
HenningTorsteinsenBouvet e359847
Added test Fire_Transition_To_If_TrueReceivedTriggerParameters.
HenningTorsteinsenBouvet 1528860
Added one generic parameter to If()
HenningTorsteinsenBouvet c18963a
Added two and three parameters to If()
HenningTorsteinsenBouvet cbe707d
Reworked Do(), so the Action takes a Transition object.
HenningTorsteinsenBouvet ad8d495
Decided on only one generic parameter for If() and Do().
HenningTorsteinsenBouvet 3826118
Finished implemented Dynamic()
HenningTorsteinsenBouvet 5058879
Added Dynamic<TArg>().
HenningTorsteinsenBouvet c62c770
Changed To() so that it allows chaining a new Transition without If()…
HenningTorsteinsenBouvet a3f8505
Added XML documentation to new methods.
HenningTorsteinsenBouvet 32a1731
Using var instead of explicit type.
HenningTorsteinsenBouvet 2e86cff
Updated examples to new syntax.
HenningTorsteinsenBouvet 6f32ecb
Fix spelling error in comment.
HenningTorsteinsenBouvet a96ac27
Some code simplifications
HenningTorsteinsenBouvet ce15ee4
Merge branch 'dev' of https://github.com/dotnet-state-machine/statele…
HenningTorsteinsenBouvet 71145ba
Merge branch 'dev' into EvenMoreFluentSyntax
HenningTorsteinsenBouvet 83b3b4b
Pick up some changes from upstream dev.
HenningTorsteinsenBouvet ea62b44
Removed Permit from StateConfiguration.
HenningTorsteinsenBouvet 4707cd7
Removed InternalTransition(TTrigger trigger, Action<Transition> entry…
HenningTorsteinsenBouvet 87aa8df
Removed a bunch of InternalTransitionIf.
HenningTorsteinsenBouvet d193875
Removed PermitIf(TTrigger trigger, TState destinationState, Func<bool…
HenningTorsteinsenBouvet d3586fe
Removed rest of PermitIf
HenningTorsteinsenBouvet ba9fcc9
Removed permitReentry.
HenningTorsteinsenBouvet e1e5129
Fixed async tests
HenningTorsteinsenBouvet 8ecf32b
Better synchronization of _firing, perhaps?
HenningTorsteinsenBouvet 8eae6eb
Replaced zero lenght array creation by Array.Empty
HenningTorsteinsenBouvet b8a5d89
Removed and change according to suggestions from IDE.
HenningTorsteinsenBouvet 156911b
Removed one permitDynamic
HenningTorsteinsenBouvet 834e97c
Removed another PaermitDynamic
HenningTorsteinsenBouvet 3c35bf5
Removed permitdynamicif without conditional.
HenningTorsteinsenBouvet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # Rules in this file were initially inferred by Visual Studio IntelliCode from the C:\Users\henning.torsteinsen\source\repos\stateless\HenningNTStateless codebase based on best match to current usage at 14.04.2020 | ||
| # You can modify the rules from these initially generated values to suit your own policies | ||
| # You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference | ||
| [*.cs] | ||
|
|
||
| #Core editorconfig formatting - indentation | ||
|
|
||
| #use soft tabs (spaces) for indentation | ||
| indent_style = space | ||
|
|
||
| #Formatting - new line options | ||
|
|
||
| #place else statements on a new line | ||
| csharp_new_line_before_else = true | ||
| #require braces to be on a new line for control_blocks, methods, properties, lambdas, types, and accessors (also known as "Allman" style) | ||
| csharp_new_line_before_open_brace = control_blocks, methods, properties, lambdas, types, accessors | ||
|
|
||
| #Formatting - organize using options | ||
|
|
||
| #sort System.* using directives alphabetically, and place them before other usings | ||
| dotnet_sort_system_directives_first = true | ||
|
|
||
| #Formatting - spacing options | ||
|
|
||
| #require NO space between a cast and the value | ||
| csharp_space_after_cast = false | ||
| #require a space before the colon for bases or interfaces in a type declaration | ||
| csharp_space_after_colon_in_inheritance_clause = true | ||
| #require a space after a keyword in a control flow statement such as a for loop | ||
| csharp_space_after_keywords_in_control_flow_statements = true | ||
| #require a space before the colon for bases or interfaces in a type declaration | ||
| csharp_space_before_colon_in_inheritance_clause = true | ||
| #remove space within empty argument list parentheses | ||
| csharp_space_between_method_call_empty_parameter_list_parentheses = false | ||
| #remove space between method call name and opening parenthesis | ||
| csharp_space_between_method_call_name_and_opening_parenthesis = false | ||
| #do not place space characters after the opening parenthesis and before the closing parenthesis of a method call | ||
| csharp_space_between_method_call_parameter_list_parentheses = false | ||
| #remove space within empty parameter list parentheses for a method declaration | ||
| csharp_space_between_method_declaration_empty_parameter_list_parentheses = false | ||
| #place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list. | ||
| csharp_space_between_method_declaration_parameter_list_parentheses = false | ||
|
|
||
| #Formatting - wrapping options | ||
|
|
||
| #leave code block on single line | ||
| csharp_preserve_single_line_blocks = true | ||
| #leave statements and member declarations on the same line | ||
| csharp_preserve_single_line_statements = true | ||
|
|
||
| #Style - expression bodied member options | ||
|
|
||
| #prefer block bodies for accessors | ||
| csharp_style_expression_bodied_accessors = false:suggestion | ||
| #prefer block bodies for constructors | ||
| csharp_style_expression_bodied_constructors = false:suggestion | ||
| #prefer block bodies for methods | ||
| csharp_style_expression_bodied_methods = false:suggestion | ||
| #prefer block bodies for properties | ||
| csharp_style_expression_bodied_properties = false:suggestion | ||
|
|
||
| #Style - expression level options | ||
|
|
||
| #prefer out variables to be declared inline in the argument list of a method call when possible | ||
| csharp_style_inlined_variable_declaration = true:suggestion | ||
| #prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them | ||
| dotnet_style_predefined_type_for_member_access = true:suggestion | ||
|
|
||
| #Style - implicit and explicit types | ||
|
|
||
| #prefer var is used to declare variables with built-in system types such as int | ||
| csharp_style_var_for_built_in_types = true:suggestion | ||
| #prefer var when the type is already mentioned on the right-hand side of a declaration expression | ||
| csharp_style_var_when_type_is_apparent = true:suggestion | ||
|
|
||
| #Style - language keyword and framework type options | ||
|
|
||
| #prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them | ||
| dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion | ||
|
|
||
| #Style - qualification options | ||
|
|
||
| #prefer fields not to be prefaced with this. or Me. in Visual Basic | ||
| dotnet_style_qualification_for_field = false:suggestion | ||
| #prefer methods not to be prefaced with this. or Me. in Visual Basic | ||
| dotnet_style_qualification_for_method = false:suggestion | ||
| #prefer properties not to be prefaced with this. or Me. in Visual Basic | ||
| dotnet_style_qualification_for_property = false:suggestion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| using System; | ||
|
|
||
| namespace Stateless | ||
| { | ||
| partial class StateMachine<TState, TTrigger> | ||
| { | ||
| /// <summary> | ||
| /// This class containd the required trigger information for a transition. | ||
| /// </summary> | ||
| public class DestinationConfiguration | ||
| { | ||
| private readonly TransitionConfiguration _transitionConfiguration; | ||
| private readonly TriggerBehaviour _triggerBehaviour; | ||
| private readonly StateRepresentation _representation; | ||
|
|
||
| internal DestinationConfiguration(TransitionConfiguration transitionConfiguration, TriggerBehaviour triggerBehaviour, StateRepresentation representation) | ||
| { | ||
| _transitionConfiguration = transitionConfiguration; | ||
| _triggerBehaviour = triggerBehaviour; | ||
| _representation = representation; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Adds a guard function to the trigger. This guard function will determine if the transition will occur or not. | ||
| /// </summary> | ||
| /// <param name="guard">This method is run when the state machine fires the trigger.</param> | ||
| /// <param name="description">Optional description of the guard</param> | ||
| public DestinationConfiguration If(Func<object[], bool> guard, string description = null) | ||
| { | ||
| _triggerBehaviour.SetGuard(new TransitionGuard(guard, description)); | ||
| return this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Adds a guard function to the trigger. This guard function will determine if the transition will occur or not. | ||
| /// </summary> | ||
| /// <typeparam name="TArg">The parameter to the guard function </typeparam> | ||
| /// <param name="guard">This method is run when the state machine fires the trigger.</param> | ||
| /// <param name="description">Optional description of the guard</param> | ||
| public DestinationConfiguration If<TArg>(Func<TArg, bool> guard, string description = null) | ||
| { | ||
| _triggerBehaviour.SetGuard(new TransitionGuard(TransitionGuard.ToPackedGuard(guard), description)); | ||
| return this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates a new transition. Use To(), Self(), Internal() or Dynamic() to set up the destination. | ||
| /// </summary> | ||
| /// <param name="trigger">The event trigger that will trigger this transition.</param> | ||
| public TransitionConfiguration Transition(TTrigger trigger) | ||
| { | ||
| return new TransitionConfiguration(_transitionConfiguration.StateConfiguration, _representation, trigger); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Adds an action to a transition. The action will be executed before the Exit action(s) (if any) are executed. | ||
| /// </summary> | ||
| /// <param name="someAction">The action run when the trigger event is handled.</param> | ||
| public StateConfiguration Do(Action someAction) | ||
| { | ||
| if (someAction == null) throw new ArgumentNullException(nameof(someAction)); | ||
|
|
||
| _triggerBehaviour.AddAction((t, args) => someAction()); | ||
| return _transitionConfiguration.StateConfiguration; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Adds an action to a transition. The action will be executed before the Exit action(s) (if any) are executed. | ||
| /// </summary> | ||
| /// <param name="someAction">The action run when the trigger event is handled.</param> | ||
| public StateConfiguration Do(Action<Transition> someAction) | ||
| { | ||
| if (someAction == null) throw new ArgumentNullException(nameof(someAction)); | ||
|
|
||
| _triggerBehaviour.AddAction(someAction); | ||
| return _transitionConfiguration.StateConfiguration; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Adds an action to a transition. The action will be executed before the Exit action(s) (if any) are executed. | ||
| /// </summary> | ||
| /// <typeparam name="TArg">The paramter used by the action.</typeparam> | ||
| /// <param name="someAction">The action run when the trigger event is handled.</param> | ||
| public StateConfiguration Do<TArg>(Action<TArg, Transition> someAction) | ||
| { | ||
| if (someAction == null) throw new ArgumentNullException(nameof(someAction)); | ||
|
|
||
| _triggerBehaviour.AddAction((t, args) => someAction(ParameterConversion.Unpack<TArg>(args, 0), t)); | ||
| return _transitionConfiguration.StateConfiguration; | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.