Skip to content

Code Quality: Refactor the Linux port to prepare for a cross-platform desktop head - #202

Open
lextm wants to merge 1 commit into
MemerGamer:mainfrom
lextudio:linux/cross-platform-seam
Open

lextm wants to merge 1 commit into
MemerGamer:mainfrom
lextudio:linux/cross-platform-seam

Conversation

@lextm

@lextm lextm commented Oct 17, 2026

Copy link
Copy Markdown

Resolved / Related Issues

  • Closes #

No linked issue. This is a refactor with no intended behavior change.

What changed

  • Extracts the OS-neutral desktop code into a new Files.Platform.Posix project that references only Files.Platform.Abstractions. Files.Platform.Linux keeps the Linux-only services and references it.
  • Renames Linux-prefixed types, files and namespaces to Desktop*/Posix*, so the Linux head is one implementation of a shared desktop layer.
  • Adds a FilesDesktopOS selector (defaults to Linux) and gates the Wayland/X11 targets on it. Same Uno packages, define and output for Linux.
  • Gathers the app layer's Linux entry points behind DesktopPlatform (DI registration, user directories, drag file list, display scale, FileManager1) and moves the Linux startup, single instance and Uno host code from Program.cs into Program.Linux.cs.
  • Routes the root/elevation environment through a Posix-level hook that the Linux assembly installs, and moves the "open beneath a directory handle" primitive into the Posix native layer.
  • CredentialsHelpers uses any non-Windows ISecretStore.
  • Fixes the tests left stale by the move and keeps the /usr/lib/linuxfiles helper, state and cache paths that packaging, the polkit policy and launchers use.

Steps used to test these changes

  1. dotnet build src/Files.App -f net10.0-desktop builds with 0 errors.
  2. The Files CI (Linux) workflow passes on the same commit, including the platform test projects step: https://github.com/lextudio/macOS-Files/actions/runs/39047066444

Remaining limitations

  • I did not run the app by hand, so the split Program startup, single-instance forwarding and drag and drop are only covered by the build and CI, not by a runtime check.
  • Some Linux-specific code is still in Files.Platform.Posix (for example /proc/self/fd in TrustedNativeDirectory and the freedesktop MIME and icon helpers). Moving it is left for a follow-up.

🤖 Generated with Claude Code

Extract the OS-neutral desktop code into a new Files.Platform.Posix project
that references only Files.Platform.Abstractions, and rename the Linux-prefixed
types, files and namespaces to Desktop*/Posix* so the Linux head is one
implementation of a shared desktop layer instead of the layer itself.

* Add a FilesDesktopOS selector (defaults to Linux) and gate the desktop
  Wayland/X11 targets on it. Linux behaviour is unchanged: the same Uno
  packages, the same define, the same output.
* Move the shared POSIX primitives (stat, enumeration, watching, file
  operations, permissions, archives, launching, icons, previews, search and
  settings) into Files.Platform.Posix; Files.Platform.Linux keeps the
  Linux-only services and references it.
* Route the root/elevation environment applied when starting a process through
  a Posix-level hook that the Linux assembly installs, and move the safe
  "open beneath a directory handle" primitive into the Posix native layer.
* Gather the app layer's Linux entry points behind DesktopPlatform (DI
  registration, user directories, drag file list, display scale, FileManager1)
  and move the Linux startup, single instance and Uno host code from
  Program.cs into Program.Linux.cs.
* Let CredentialsHelpers use any non-Windows ISecretStore.
* Fix the tests left stale by the move and restore the /usr/lib/linuxfiles
  helper, state and cache paths that the packaging, polkit policy and
  launchers still use.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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