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

Fix disable autofill issue #120

Merged

Conversation

joshhanley
Copy link
Collaborator

The scenario

Currently if you have a property that has a StateId set to null, Verbs will generate an ID for it.

But there are some scenarios where a property should actually be set to null and no new ID/ state should get generated for it, as it's an optional reference to another state.

To solve this, we can use the autofill: false property on the StateId attribute.

#[StateId(StateIdTestState::class, autofill: false)]
public ?int $other_state_id = null;

The problem

The problem is that at the moment, doing the above code throws the following error:

image

The solution

This PR fixes it by ensuring that when the EventStateRegistry discovers states, that it has actually found a state before trying to process the aliases.

I couldn't see any unit tests for StateId so I have added a basic test and added 2 tests that cover the autofill: false scenarios.

@DanielCoulbourne DanielCoulbourne merged commit 842f5ea into hirethunk:main Apr 18, 2024
41 checks passed
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