Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

When adding .PermitDynamicIf, call .PermitTriggers throw NullReferenceException #416

Closed
yuyixg opened this issue Jan 11, 2021 · 4 comments
Closed
Labels

Comments

@yuyixg
Copy link

yuyixg commented Jan 11, 2021

When adding .PermitDynamicIf, call .PermitTriggers throw System.NullReferenceException:“Object reference not set to an instance of an object.”
class ParameterConversion
public static TArg Unpack(object[] args, int index)
{
return (TArg)Unpack(args, typeof(TArg), index); // args=[]
}

@HenningNT HenningNT added the bug label Jan 11, 2021
@HenningNT
Copy link
Contributor

Oh dear, that should probably not happen!

Would you mind demonstrating this bug in a unit test?

@yuyixg
Copy link
Author

yuyixg commented Jan 11, 2021

        var sm = new StateMachine<State, Trigger>(State.A);
        var trigger = sm.SetTriggerParameters<int>(Trigger.X);
        sm.Configure(State.A)
            .PermitDynamicIf(trigger, (i) => i == 1 ? State.C : State.B,(i)=>i==1?true:false) ;

        foreach(var permittedTrigger in sm.GetPermittedTriggers())
        {
            
        }
        sm.Fire(trigger, 1);

But there is no error when modified as shown below

       sm.Configure(State.A)
            .PermitDynamicIf(trigger, (i) => i == 1 ? State.C : State.B,()=>true) ;

@HenningNT
Copy link
Contributor

I see, those dynamic methods are a bit fiddly. Thanks for the bug report, I'll see if I can do something about it.

@HenningNT
Copy link
Contributor

Fixed in 5.1.8

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

No branches or pull requests

2 participants