Skip to content
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

Expose unmet guard conditions #581

Conversation

andrewmckaskill
Copy link

This change adds a method to expose the unmet guard conditions.

I'm using this to show validation messages to users as to WHY they are unable to take a certain action within the workflow.

While it is possible to get the entire set of guard condition descriptions through the StateMachine.GetInfo() method, the info object exposes all guard conditions for a Trigger, without reporting back which ones are unmet.

Please let me know if this needs additional changes, and what kind of tests would be appropriate.

I'm also happy to change the return value IEnumerable<Tuple<TTrigger, string[]>> with Dictionary<TTrigger, ICollection<string[]> if that more closely aligns with other types in use - please let me know.

Add a method to return list of non-permissible triggers from the current state, along with the descriptions of the un-met guard conditions.
@mclift
Copy link
Member

mclift commented Jun 13, 2024

Thanks for taking the time to contribute!

From what you've described, it looks like the overloads of CanFire with out ICollection<string> unmetGuards are a close fit, although they differ in that you need to provide the trigger you want to test. Would CanFire meet your needs here?

Some feedback on the PR: as it is now, if the current state is configured with multiple triggers that expect different parameters from each other, GetTriggersWithUnmetGuardConditions throws an exception as it attempts to invoke all the guards with the same parameters, so there might need to be some additional parameter/overload to decide how mismatched parameters would be handled.

Mike

@andrewmckaskill
Copy link
Author

Thanks for the feedback Mike. I've had a review of the code and yes, CanFire does meet my needs. I thought I had scoured the codebase thoroughly, but I guess I missed it. I'll go ahead and cancel this PR.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants