Skip to content

Upgrade to ktsu.Semantics 2.8.0 and simplify path access - #280

Merged
matt-edmondson merged 1 commit into
mainfrom
chore/upgrade-semantics
Jul 30, 2026
Merged

Upgrade to ktsu.Semantics 2.8.0 and simplify path access#280
matt-edmondson merged 1 commit into
mainfrom
chore/upgrade-semantics

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Follow-up to #279.

What 2.8.0 brings

ktsu-dev/Semantics#140 fixed SemanticString<T>.CompareTo(object) so it unwraps ISemanticString instead of handing another semantic string to string.CompareTo(object) — the root cause of #273 — and added WeakString to IPath, IFileName, IFileExtension and IDirectoryName.

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.

  • 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, since every entry is one of the two:
    AbsoluteDirectoryPath? directory = path as AbsoluteDirectoryPath;
    AbsoluteFilePath? file = path as AbsoluteFilePath;
    string displayPath = directory?.WeakString ?? file?.WeakString ?? string.Empty;
    IAbsolutePath now carries WeakString directly. (The directory cast stays — it still drives the trailing-separator and navigation branches.)
  • SortContents and its tests used ToString(), which returns string? and cost a null-forgiving operator at each of four call sites.

What deliberately did not change

SortContents still sorts on the string value rather than the entry itself. The IComparable<IPath> added in 2.8.0 only helps collections typed as IPath exactlyCurrentContents is a Collection<IAbsolutePath>, which implements IComparable<T> of neither itself nor IPath, so .ThenBy(p => p) would still box through the non-generic CompareTo(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

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
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@matt-edmondson
matt-edmondson merged commit ac804b5 into main Jul 30, 2026
5 of 7 checks passed
@matt-edmondson
matt-edmondson deleted the chore/upgrade-semantics branch July 30, 2026 08:11
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.

1 participant