Upgrade to ktsu.Semantics 2.8.0 and simplify path access - #280
Merged
Conversation
2.8.0 fixes SemanticString<T>.CompareTo(object) so it unwraps ISemanticString rather than handing another semantic string to string.CompareTo(object) (ktsu-dev/Semantics#140), and exposes WeakString on IPath, IFileName, IFileExtension and IDirectoryName. Nothing here was required by the upgrade — ImGuiApp implements none of those interfaces, so the added members break nothing, and the build passes untouched against 2.8.0. These are the simplifications the new surface allows: - DrawContentRow read the display path by testing for two concrete types and falling back to string.Empty, a branch that could never legitimately be reached. IAbsolutePath now carries WeakString directly. - SortContents and its tests used ToString(), which returns string? and cost a null-forgiving operator at every call site. SortContents still sorts on the string value rather than the entry. The IComparable<IPath> that 2.8.0 declares only helps collections typed as IPath exactly; CurrentContents is a Collection<IAbsolutePath>, which implements IComparable<T> of neither itself nor IPath, so sorting by the entry would still box through the non-generic CompareTo(object). Sorting on the string value also keeps case-insensitive display order. All four Semantics packages move together since that repo versions in lockstep. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WFRwYRHhEmVMGvrH2BbtbW
|
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.


Follow-up to #279.
What 2.8.0 brings
ktsu-dev/Semantics#140 fixed
SemanticString<T>.CompareTo(object)so it unwrapsISemanticStringinstead of handing another semantic string tostring.CompareTo(object)— the root cause of #273 — and addedWeakStringtoIPath,IFileName,IFileExtensionandIDirectoryName.Nothing here was required
I verified this before writing any of it: ImGuiApp implements none of those interfaces, so the added interface members break nothing, and the existing code builds and passes all 604 tests against 2.8.0 untouched. Everything below is optional cleanup the new surface makes possible.
DrawContentRowread the display path by testing for two concrete types and falling back tostring.Empty— a branch that could never legitimately be reached, since every entry is one of the two:IAbsolutePathnow carriesWeakStringdirectly. (Thedirectorycast stays — it still drives the trailing-separator and navigation branches.)SortContentsand its tests usedToString(), which returnsstring?and cost a null-forgiving operator at each of four call sites.What deliberately did not change
SortContentsstill sorts on the string value rather than the entry itself. TheIComparable<IPath>added in 2.8.0 only helps collections typed asIPathexactly —CurrentContentsis aCollection<IAbsolutePath>, which implementsIComparable<T>of neither itself norIPath, so.ThenBy(p => p)would still box through the non-genericCompareTo(object). It would no longer throw, but it would be slower and would lose the case-insensitive display order. The<remarks>on the method now records this.All four Semantics packages move together, since that repo versions in lockstep.
Verification
Restored, built and tested against the real
ktsu.Semantics.*2.8.0 from nuget.org (not a local build): 603 passed, 1 skipped (the Windows-only drive assertion).🤖 Generated with Claude Code
https://claude.ai/code/session_01WFRwYRHhEmVMGvrH2BbtbW