Repository navigation
Keep a NavigationItem's CreatedAt and Metadata through a JSON round trip [minor] - #65
Merged
Merged
Conversation
…rip [minor] NavigationItem's only constructor took the id and display name, so System.Text.Json dropped the saved Metadata (a get-only computed property) and gave every loaded item the load time as its CreatedAt. A new [JsonConstructor] overload takes createdAt and metadata and restores both. Metadata values come back as JsonElement, which the constructor docs and docs/API.md now say. Fixes #56 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ScKzvHsZwsrSifP4Mbp1jW
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ScKzvHsZwsrSifP4Mbp1jW
…son-round-trip # Conflicts: # Navigation.Test/JsonFilePersistenceProviderTests.cs
|
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 #56
What changed
NavigationItemhad only the(id, displayName)constructor. When System.Text.Json deserialized an item, it dropped the savedMetadata, because that is a get-only computed property. It also stampedCreatedAtwith the load time.[JsonConstructor]overload,NavigationItem(string id, string displayName, DateTime createdAt, IReadOnlyDictionary<string, object>? metadata). It chains to the existing constructor, so validation is unchanged, then restoresCreatedAtand copies the metadata. Entries with a null or blank key, or a null value, are skipped, which keepsSetMetadata's rules.JsonElementrather than their original CLR types. This is in the XML docs anddocs/API.md, and follows the triage note to keepobjectvalues instead of narrowing tostring, which would break the API.[minor].Tests
NavigationItem_JsonRoundTrip_KeepsCreatedAtAndMetadataruns the issue's repro directly.SaveThenLoad_KeepsItemCreatedAtAndMetadataround-trips throughJsonFilePersistenceProvider. LoadStateAsync with JsonFilePersistenceProvider always throws InvalidOperationException, so saved navigation can never be restored #53 is already fixed, so this covers the issue's second acceptance criterion.mainand pass with this change. The full suite passes locally (16/16), and the library builds on every target framework (net8.0/9.0/10.0, netstandard2.0/2.1).🤖 Generated with Claude Code
https://claude.ai/code/session_01ScKzvHsZwsrSifP4Mbp1jW
Generated by Claude Code