Fixes 4331 Handle null load state; add tests#4349
Merged
ChrisPulman merged 1 commit intomainfrom May 4, 2026
Merged
Conversation
Do not assign a potentially-null loaded state directly to AppState/AppStateValue. Capture the result of ISuspensionDriver.LoadState into a local (object? / TAppState?) and assign item.AppState/item.AppStateValue to the loaded value or fallback to CreateNewAppState/CreateNewAppStateTyped. Add tests in SuspensionHostExtensionsTests and SuspensionHostExtensionsAotTests that verify GetAppState creates and stores a new app state when no persisted state exists. Add ReturnNullOnLoad to TestSuspensionDriver to simulate drivers returning null. Change SuspensionHostTestExecutor to inherit from AppBuilderTestExecutor and delegate ExecuteTest to the base implementation (and add the required using). These changes ensure null-returning drivers are handled safely and covered by tests.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4349 +/- ##
==========================================
+ Coverage 89.64% 89.67% +0.02%
==========================================
Files 253 253
Lines 9631 9633 +2
Branches 1473 1473
==========================================
+ Hits 8634 8638 +4
+ Misses 756 753 -3
- Partials 241 242 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
glennawatson
approved these changes
May 4, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What kind of change does this PR introduce?
Fix
What is the current behavior?
Closes #4331
What is the new behavior?
Do not assign a potentially-null loaded state directly to AppState/AppStateValue.
Capture the result of ISuspensionDriver.LoadState into a local (object? / TAppState?) and assign item.AppState/item.AppStateValue to the loaded value or fallback to CreateNewAppState/CreateNewAppStateTyped.
Add tests in SuspensionHostExtensionsTests and SuspensionHostExtensionsAotTests that verify GetAppState creates and stores a new app state when no persisted state exists.
Add ReturnNullOnLoad to TestSuspensionDriver to simulate drivers returning null.
Change SuspensionHostTestExecutor to inherit from AppBuilderTestExecutor and delegate ExecuteTest to the base implementation (and add the required using).
These changes ensure null-returning drivers are handled safely and covered by tests.
What might this PR break?
Checklist
mainbranchAdditional information