Skip to content

Add a LoadOrCreate overload that takes an absolute root directory #316

Description

@matt-edmondson

Problem

The root of AppData<T> is computed, not injected. AppData.Path is AppDataPath / AppDomain, which is %AppData%/<AppDomain.CurrentDomain.FriendlyName>. Both properties are read-only and expression-bodied. Every LoadOrCreate overload (AppData.cs:498, :538, :545, :552) takes only a RelativeDirectoryPath, which is joined beneath AppData.Path. A caller has no way to ask for an arbitrary absolute root.

That blocks adopting AppData<T> in libraries that expose their data directory as public API. For example, ktsu-dev/Keybinding#93 has four public entry points that accept an absolute dataDirectory, and its test suite isolates each test in its own temp directory.

Proposal

Add a LoadOrCreate overload that takes an AbsoluteDirectoryPath root, alongside the optional file name. It should use the same atomic tmp/.bk write and the same recovery path as the existing overloads. The Get() singleton does not need to change. Callers that pass an explicit root keep the returned instance themselves.

Acceptance criteria

  • LoadOrCreate(AbsoluteDirectoryPath root, FileName? fileName = null) (exact shape is open) loads, saves and recovers from .bk under root. The FriendlyName segment is not inserted.
  • Two instances of the same T with different roots do not share a file.
  • Tests cover per-root isolation and backup recovery under a custom root.

Context

The maintainer decided on 2026-09-28 that Keybinding should adopt ktsu.AppDataStorage, and that the missing absolute-root support should be fixed upstream here (option 1 in Keybinding#93). This follows the org-wide reuse rule "prefer reuse, accept costs; fix gaps upstream" (ktsu-dev/.github#15).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions