Repository navigation
Keep a NavigationState's CreatedAt through a JSON round trip [minor] - #70
Merged
Merged
Conversation
The JSON constructor took only items and currentIndex, so the createdAt that JsonFilePersistenceProvider writes was ignored and a loaded state reported the time it was loaded. A new JSON constructor takes createdAt and keeps it when it is set. The existing (IReadOnlyList<T>, int) constructor stays, without the attribute. Fixes #62 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EdrcmpMTNHSnACRgnNGs8v
|
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.



Fixes #62
What was wrong
The
[JsonConstructor]overload ofNavigationState<T>took onlyitemsandcurrentIndex. It chained to the public constructor, which setsCreatedAt = DateTime.UtcNow.JsonFilePersistenceProviderwritescreatedAtto disk, but loading ignored it, so a restored state reported the time it was loaded rather than the time it was saved.Change
This mirrors the fix for
NavigationItemin #65.[JsonConstructor]overload,NavigationState(IReadOnlyList<T> items, int currentIndex, DateTime createdAt), keepscreatedAtwhen it is not the default value.(IReadOnlyList<T>, int)constructor stays public but loses the attribute, so no caller breaks. Adding a public constructor is why this is[minor].(IEnumerable<T>, int)constructor still stampsDateTime.UtcNow.Tests
Two tests are added to
JsonFilePersistenceProviderTests:LoadStateAsync_KeepsSavedStateCreatedAtloads a file with a knowncreatedAtof 2020-01-01 and asserts that value.SaveThenLoad_KeepsStateCreatedAtsaves a state, waits, loads it, and asserts thatCreatedAtequals the saved value.Both fail with the fix reverted. With the fix, the full suite passes (
dotnet test: 20 passed, 0 failed), andNavigation.csprojbuilds with 0 warnings.🤖 Generated with Claude Code
https://claude.ai/code/session_01EdrcmpMTNHSnACRgnNGs8v
Generated by Claude Code