dotnet-state-machine / stateless

A simple library for creating state machines in C# code
Other
5.6k stars 766 forks source link

Fix StateInfo.Transitions NullReferenceException for states without transitions #441

Closed EraYaN closed 3 years ago

EraYaN commented 3 years ago

This returns Enumerable.Empty<TransitionInfo>() if both are null and still works if either of the IEnumerable's are null. When both are not null behaviour is unchanged.

Closes #440

HenningNT commented 3 years ago

Hi, do you have a unit test that demonstrates this, I'm unable to reproduce it?

EraYaN commented 3 years ago

I have to admit that I can't really figure out anymore how I broke it. I'll give it a couple more tries. I think at some point the StateInfo objects didn't get the AddRelationships functions called, so there were nulls for certain states and that broke trying to serialize to json.

HenningNT commented 3 years ago

OK, so if we can't reproduce it then I'd rather not merge it. Don't fix it if it's working, you know...

EraYaN commented 3 years ago

It's been too long and I can't recall how we broke it, and the change was before the initial commit. So I'll close this PR and the issue.