Skip to content

Fixes 4331 Handle null load state; add tests#4349

Merged
ChrisPulman merged 1 commit intomainfrom
Chris_fix-getappstate-default-state
May 4, 2026
Merged

Fixes 4331 Handle null load state; add tests#4349
ChrisPulman merged 1 commit intomainfrom
Chris_fix-getappstate-default-state

Conversation

@ChrisPulman
Copy link
Copy Markdown
Member

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

  • I have read the Contribute guide
  • Tests have been added or updated (for bug fixes / features)
  • Docs have been added or updated (for bug fixes / features)
  • Changes target the main branch
  • PR title follows Conventional Commits

Additional information

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
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.67%. Comparing base (2be6785) to head (25f08f3).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ChrisPulman ChrisPulman enabled auto-merge (squash) May 4, 2026 00:35
@ChrisPulman ChrisPulman merged commit 03ccb2e into main May 4, 2026
10 checks passed
@ChrisPulman ChrisPulman deleted the Chris_fix-getappstate-default-state branch May 4, 2026 00:39
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.

[Bug]: GetAppState<TAppState>(…) Returns Null

2 participants