From 51b8e843ef0a240a43b3299e112c5ee8e9a7ee3c Mon Sep 17 00:00:00 2001 From: Martin Scholz Date: Thu, 26 Nov 2026 14:21:48 +0100 Subject: [PATCH] Remove the .NET/WPF app; the Rust app replaces it Delete src/FolderCompare.App, src/FolderCompare.Core, tests/FolderCompare.Core.Tests, FolderCompare.sln, Directory.Build.props and the original WPF requirements document. Move the Explorer shell extension to crates/foldercompare/shellext and the app icon sources to crates/foldercompare/assets, and update build.rs, make-icon.ps1, make-app.sh, .gitignore, README, CLAUDE.md and the manual test checklist accordingly. --- .gitignore | 2 - CLAUDE.md | 82 +- Directory.Build.props | 11 - FolderCompare.sln | 43 - README.md | 91 +- REQUIREMENTS_CompareTool.md | 291 ----- build/macos/make-app.sh | 2 +- crates/fc-core/src/lib.rs | 2 +- crates/fc-core/src/shell_layout.rs | 2 +- .../foldercompare/assets}/app-icon.svg | 0 .../foldercompare/assets}/app.ico | Bin crates/foldercompare/build.rs | 6 +- .../foldercompare/shellext}/ShellExt.cpp | 0 .../foldercompare/shellext}/ShellExt.def | 0 .../foldercompare/shellext}/build.ps1 | 4 +- crates/foldercompare/src/actions.rs | 2 +- crates/foldercompare/src/settings.rs | 2 +- docs/MANUAL_TESTS.md | 19 +- src/FolderCompare.App/App.xaml | 13 - src/FolderCompare.App/App.xaml.cs | 110 -- src/FolderCompare.App/AssemblyInfo.cs | 10 - .../Converters/VisibilityConverters.cs | 30 - .../FolderCompare.App.csproj | 57 - src/FolderCompare.App/MainWindow.xaml | 316 ----- src/FolderCompare.App/MainWindow.xaml.cs | 460 ------- src/FolderCompare.App/Services/AppSettings.cs | 99 -- .../Services/CommandLineOptions.cs | 42 - .../Services/DialogService.cs | 90 -- .../Services/ExplorerIntegrationService.cs | 189 --- .../Services/IDialogService.cs | 27 - src/FolderCompare.App/Services/RecycleBin.cs | 13 - .../Services/SettingsService.cs | 69 - .../Services/ShellService.cs | 25 - .../Services/TextCompareLauncher.cs | 107 -- src/FolderCompare.App/Themes/Colors.xaml | 25 - src/FolderCompare.App/Themes/Styles.xaml | 114 -- .../ViewModels/MainViewModel.cs | 1149 ----------------- .../ViewModels/RangeObservableCollection.cs | 36 - .../ViewModels/RowViewModel.cs | 129 -- .../Views/DeleteSideDialog.xaml | 15 - .../Views/DeleteSideDialog.xaml.cs | 21 - src/FolderCompare.App/Views/InputDialog.xaml | 19 - .../Views/InputDialog.xaml.cs | 55 - .../Views/OverwriteDialog.xaml | 43 - .../Views/OverwriteDialog.xaml.cs | 40 - .../Views/PreviewDialog.xaml | 45 - .../Views/PreviewDialog.xaml.cs | 74 -- .../Views/SettingsDialog.xaml | 97 -- .../Views/SettingsDialog.xaml.cs | 48 - .../Views/SummaryDialog.xaml | 15 - .../Views/SummaryDialog.xaml.cs | 30 - .../TextCompare/DiffBackgroundRenderer.cs | 100 -- .../Views/TextCompare/DiffColors.cs | 31 - .../Views/TextCompare/DiffMargins.cs | 194 --- .../Views/TextCompare/DocumentLineSource.cs | 17 - .../TextCompare/FillerElementGenerator.cs | 84 -- .../Views/TextCompare/TextCompareWindow.xaml | 147 --- .../TextCompare/TextCompareWindow.xaml.cs | 714 ---------- src/FolderCompare.App/Views/TreeListView.cs | 10 - src/FolderCompare.App/app.manifest | 23 - .../Comparison/ByteContentComparer.cs | 59 - .../Comparison/DiffEngine.cs | 251 ---- .../Comparison/DirectoryScanner.cs | 255 ---- .../Comparison/FileComparer.cs | 53 - .../Comparison/IContentComparer.cs | 12 - .../Comparison/PathPatternMatcher.cs | 81 -- .../Comparison/ProgressTracker.cs | 69 - .../Comparison/TimestampComparer.cs | 19 - .../FolderCompare.Core.csproj | 17 - .../Models/CompareOptions.cs | 32 - src/FolderCompare.Core/Models/DiffNode.cs | 61 - src/FolderCompare.Core/Models/DiffResult.cs | 19 - src/FolderCompare.Core/Models/DiffStatus.cs | 18 - .../Models/FileInfoSnapshot.cs | 6 - src/FolderCompare.Core/Models/ScanProgress.cs | 7 - .../Operations/FileOperationExecutor.cs | 353 ----- .../Operations/IRecycleBin.cs | 8 - .../Operations/OperationModels.cs | 138 -- .../Operations/OperationPlanner.cs | 134 -- .../Operations/SafetyValidator.cs | 64 - .../Reporting/ReportExporter.cs | 48 - .../Shell/ExplorerMenuLayout.cs | 109 -- src/FolderCompare.Core/TextDiff/BlockCopy.cs | 98 -- .../TextDiff/InlineDiffer.cs | 71 - src/FolderCompare.Core/TextDiff/LineDiffer.cs | 133 -- src/FolderCompare.Core/TextDiff/MyersDiff.cs | 139 -- .../TextDiff/TextComparison.cs | 141 -- .../TextDiff/TextFileCodec.cs | 118 -- .../DiffEngineTests.cs | 383 ------ .../ExplorerIntegrationTests.cs | 93 -- .../FileComparerTests.cs | 178 --- .../FileOperationTests.cs | 438 ------- .../FolderCompare.Core.Tests.csproj | 25 - .../PathPatternMatcherTests.cs | 38 - .../RealFileSystemTests.cs | 82 -- .../SafetyValidatorTests.cs | 57 - tests/FolderCompare.Core.Tests/TestFs.cs | 35 - .../FolderCompare.Core.Tests/TextDiffTests.cs | 313 ----- .../TimestampComparerTests.cs | 49 - tools/make-icon.ps1 | 4 +- 100 files changed, 105 insertions(+), 9594 deletions(-) delete mode 100644 Directory.Build.props delete mode 100644 FolderCompare.sln delete mode 100644 REQUIREMENTS_CompareTool.md rename {src/FolderCompare.App/Assets => crates/foldercompare/assets}/app-icon.svg (100%) rename {src/FolderCompare.App/Assets => crates/foldercompare/assets}/app.ico (100%) rename {src/FolderCompare.ShellExt => crates/foldercompare/shellext}/ShellExt.cpp (100%) rename {src/FolderCompare.ShellExt => crates/foldercompare/shellext}/ShellExt.def (100%) rename {src/FolderCompare.ShellExt => crates/foldercompare/shellext}/build.ps1 (92%) delete mode 100644 src/FolderCompare.App/App.xaml delete mode 100644 src/FolderCompare.App/App.xaml.cs delete mode 100644 src/FolderCompare.App/AssemblyInfo.cs delete mode 100644 src/FolderCompare.App/Converters/VisibilityConverters.cs delete mode 100644 src/FolderCompare.App/FolderCompare.App.csproj delete mode 100644 src/FolderCompare.App/MainWindow.xaml delete mode 100644 src/FolderCompare.App/MainWindow.xaml.cs delete mode 100644 src/FolderCompare.App/Services/AppSettings.cs delete mode 100644 src/FolderCompare.App/Services/CommandLineOptions.cs delete mode 100644 src/FolderCompare.App/Services/DialogService.cs delete mode 100644 src/FolderCompare.App/Services/ExplorerIntegrationService.cs delete mode 100644 src/FolderCompare.App/Services/IDialogService.cs delete mode 100644 src/FolderCompare.App/Services/RecycleBin.cs delete mode 100644 src/FolderCompare.App/Services/SettingsService.cs delete mode 100644 src/FolderCompare.App/Services/ShellService.cs delete mode 100644 src/FolderCompare.App/Services/TextCompareLauncher.cs delete mode 100644 src/FolderCompare.App/Themes/Colors.xaml delete mode 100644 src/FolderCompare.App/Themes/Styles.xaml delete mode 100644 src/FolderCompare.App/ViewModels/MainViewModel.cs delete mode 100644 src/FolderCompare.App/ViewModels/RangeObservableCollection.cs delete mode 100644 src/FolderCompare.App/ViewModels/RowViewModel.cs delete mode 100644 src/FolderCompare.App/Views/DeleteSideDialog.xaml delete mode 100644 src/FolderCompare.App/Views/DeleteSideDialog.xaml.cs delete mode 100644 src/FolderCompare.App/Views/InputDialog.xaml delete mode 100644 src/FolderCompare.App/Views/InputDialog.xaml.cs delete mode 100644 src/FolderCompare.App/Views/OverwriteDialog.xaml delete mode 100644 src/FolderCompare.App/Views/OverwriteDialog.xaml.cs delete mode 100644 src/FolderCompare.App/Views/PreviewDialog.xaml delete mode 100644 src/FolderCompare.App/Views/PreviewDialog.xaml.cs delete mode 100644 src/FolderCompare.App/Views/SettingsDialog.xaml delete mode 100644 src/FolderCompare.App/Views/SettingsDialog.xaml.cs delete mode 100644 src/FolderCompare.App/Views/SummaryDialog.xaml delete mode 100644 src/FolderCompare.App/Views/SummaryDialog.xaml.cs delete mode 100644 src/FolderCompare.App/Views/TextCompare/DiffBackgroundRenderer.cs delete mode 100644 src/FolderCompare.App/Views/TextCompare/DiffColors.cs delete mode 100644 src/FolderCompare.App/Views/TextCompare/DiffMargins.cs delete mode 100644 src/FolderCompare.App/Views/TextCompare/DocumentLineSource.cs delete mode 100644 src/FolderCompare.App/Views/TextCompare/FillerElementGenerator.cs delete mode 100644 src/FolderCompare.App/Views/TextCompare/TextCompareWindow.xaml delete mode 100644 src/FolderCompare.App/Views/TextCompare/TextCompareWindow.xaml.cs delete mode 100644 src/FolderCompare.App/Views/TreeListView.cs delete mode 100644 src/FolderCompare.App/app.manifest delete mode 100644 src/FolderCompare.Core/Comparison/ByteContentComparer.cs delete mode 100644 src/FolderCompare.Core/Comparison/DiffEngine.cs delete mode 100644 src/FolderCompare.Core/Comparison/DirectoryScanner.cs delete mode 100644 src/FolderCompare.Core/Comparison/FileComparer.cs delete mode 100644 src/FolderCompare.Core/Comparison/IContentComparer.cs delete mode 100644 src/FolderCompare.Core/Comparison/PathPatternMatcher.cs delete mode 100644 src/FolderCompare.Core/Comparison/ProgressTracker.cs delete mode 100644 src/FolderCompare.Core/Comparison/TimestampComparer.cs delete mode 100644 src/FolderCompare.Core/FolderCompare.Core.csproj delete mode 100644 src/FolderCompare.Core/Models/CompareOptions.cs delete mode 100644 src/FolderCompare.Core/Models/DiffNode.cs delete mode 100644 src/FolderCompare.Core/Models/DiffResult.cs delete mode 100644 src/FolderCompare.Core/Models/DiffStatus.cs delete mode 100644 src/FolderCompare.Core/Models/FileInfoSnapshot.cs delete mode 100644 src/FolderCompare.Core/Models/ScanProgress.cs delete mode 100644 src/FolderCompare.Core/Operations/FileOperationExecutor.cs delete mode 100644 src/FolderCompare.Core/Operations/IRecycleBin.cs delete mode 100644 src/FolderCompare.Core/Operations/OperationModels.cs delete mode 100644 src/FolderCompare.Core/Operations/OperationPlanner.cs delete mode 100644 src/FolderCompare.Core/Operations/SafetyValidator.cs delete mode 100644 src/FolderCompare.Core/Reporting/ReportExporter.cs delete mode 100644 src/FolderCompare.Core/Shell/ExplorerMenuLayout.cs delete mode 100644 src/FolderCompare.Core/TextDiff/BlockCopy.cs delete mode 100644 src/FolderCompare.Core/TextDiff/InlineDiffer.cs delete mode 100644 src/FolderCompare.Core/TextDiff/LineDiffer.cs delete mode 100644 src/FolderCompare.Core/TextDiff/MyersDiff.cs delete mode 100644 src/FolderCompare.Core/TextDiff/TextComparison.cs delete mode 100644 src/FolderCompare.Core/TextDiff/TextFileCodec.cs delete mode 100644 tests/FolderCompare.Core.Tests/DiffEngineTests.cs delete mode 100644 tests/FolderCompare.Core.Tests/ExplorerIntegrationTests.cs delete mode 100644 tests/FolderCompare.Core.Tests/FileComparerTests.cs delete mode 100644 tests/FolderCompare.Core.Tests/FileOperationTests.cs delete mode 100644 tests/FolderCompare.Core.Tests/FolderCompare.Core.Tests.csproj delete mode 100644 tests/FolderCompare.Core.Tests/PathPatternMatcherTests.cs delete mode 100644 tests/FolderCompare.Core.Tests/RealFileSystemTests.cs delete mode 100644 tests/FolderCompare.Core.Tests/SafetyValidatorTests.cs delete mode 100644 tests/FolderCompare.Core.Tests/TestFs.cs delete mode 100644 tests/FolderCompare.Core.Tests/TextDiffTests.cs delete mode 100644 tests/FolderCompare.Core.Tests/TimestampComparerTests.cs diff --git a/.gitignore b/.gitignore index 1c56dd0..5e6e0c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,7 @@ bin/ obj/ .vs/ -*.user publish/ -TestResults/ CLAUDE.local.md exampleDiff/ docs/promo/ diff --git a/CLAUDE.md b/CLAUDE.md index 330ca64..ca9328c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,62 +1,44 @@ # FolderCompare – notes for Claude See README.md for features, shortcuts and layout. This file holds working knowledge only. - -## Build & test -- `dotnet build`, `dotnet test` (xUnit, all tests must pass before committing). -- Release exe: `dotnet publish src/FolderCompare.App -c Release -o publish` → single-file self-contained - `publish\FolderCompare.exe` (~156 MB). Delete `publish\` first so no stale files are left. - -## Architecture rules -- `FolderCompare.Core` has no WPF reference. All file access goes through `System.IO.Abstractions.IFileSystem` - so it stays testable with the mock file system. New logic goes into Core with unit tests where possible. -- App is MVVM (CommunityToolkit.Mvvm, `[ObservableProperty]` / `[RelayCommand]`), services registered via DI in - `App.xaml.cs`. After changing state that affects a command, update `RefreshCommandStates` in `MainViewModel`. -- Colors live only in `Themes/Colors.xaml` (prepared for a later dark theme), never hard-coded in XAML/C#. -- Settings: `AppSettings` → `%APPDATA%\FolderCompare\settings.json`; keep new properties backward compatible (defaults). +FolderCompare is a Rust + egui/eframe app for Windows, Linux and macOS (2.x). It replaced the Windows-only .NET/WPF +app (1.x, removed from the repo; still in the git history up to tag `v1.5.0`). ## Safety invariants (do not weaken) -- Scanning never writes. Every copy/delete target must be checked to be strictly inside its root after `GetFullPath`. +- Scanning never writes. Every copy/delete/rename target must be checked to be strictly inside its root. - Copies write to `.tmpcopy` then rename; preserve and verify timestamp/size/attributes. -- Delete goes to the Recycle Bin by default; overwriting a newer file always asks. -- Log every file operation (Serilog). - -## Text compare (src/FolderCompare.Core/TextDiff, src/FolderCompare.App/Views/TextCompare) -- Diff: own Myers implementation (`MyersDiff`, `LineDiffer`, `InlineDiffer`), AvalonEdit only for display/editing. -- Pane alignment relies on **every visual row being exactly one line height**: filler rows come from - `FillerElementGenerator` (zero-length element with a custom height). Don't enable word wrap or variable line heights - without reworking scroll sync, `DiffMargins` and `DiffBackgroundRenderer`. -- Block copies are computed by `BlockCopy` (tested on strings) and applied inside `BeginUpdate/EndUpdate` so each - copy is one undo step. -- `TextFileCodec` must round-trip encoding, BOM and line endings unchanged. -- Name clashes seen before: `TextRange` (WPF vs. Core – use an alias), `Window.RestoreBounds`. +- Delete goes to the Recycle Bin / Trash by default; overwriting a newer file always asks. +- Log every file operation. +- `settings.json` stays compatible with 1.x: new properties need defaults, unknown fields are kept. -## Explorer context menu (src/FolderCompare.ShellExt) -- Native C++ `IExplorerCommand` DLL (WRL, x64, static CRT), built by `build.ps1` with the MSVC Build Tools from an - incremental target in `FolderCompare.App.csproj`, then embedded in the exe. `dotnet build` of the App needs MSVC. +## Explorer context menu (Windows, `crates/foldercompare/shellext`) +- Native C++ `IExplorerCommand` DLL (WRL, x64, static CRT), built by `build.ps1` with the MSVC Build Tools and + embedded in the exe. - Registered per user via `ExplorerCommandHandler` verbs (classic menu, no package). The DLL decides visibility and titles (`GetState`/`GetTitle`), stores the left item in `HKCU\Software\FolderCompare\LeftSelection` and starts - `FolderCompare.exe "left" "right" --compare`. CLSIDs and registry names in `ExplorerMenuLayout` must match `ShellExt.cpp`. + `FolderCompare.exe "left" "right" --compare`. CLSIDs and registry names in `fc_core::shell_layout` must match `ShellExt.cpp`. - The DLL is extracted as `%LOCALAPPDATA%\FolderCompare\ShellExt\FolderCompare.ShellExt..dll` because Explorer - keeps it loaded; `EnsureCurrentPath` re-registers on start when exe or DLL hash changed. Restart Explorer to test changes. + keeps it loaded; on start the app re-registers when the exe path or DLL hash changed. Restart Explorer to test changes. - `Shell.Application` → `Namespace(dir).ParseName(name).Verbs()` lists the visible entries for single-item checks. ## Releasing -1. Bump `` in `src/FolderCompare.App/FolderCompare.App.csproj` (semver; new feature → minor). -2. Test, clean Release publish, check the exe's ProductVersion. -3. Commit, push `main`, create annotated tag `vX.Y.Z`, push tag. -4. `gh release create vX.Y.Z publish/FolderCompare.exe --title "FolderCompare X.Y.Z" --notes ...` - Release notes describe user-visible changes; no mention of Claude. +1. Bump `version` in the root `Cargo.toml` (semver; new feature → minor). The release workflow fails if it differs + from the tag. +2. Tests, fmt, clippy pass; CI on `main` is green. +3. Push `main`, create an annotated tag `vX.Y.Z` with the message `FolderCompare X.Y.Z`, push the tag. +4. `.github/workflows/rust-release.yml` builds all platforms and creates a **draft** release titled + `FolderCompare X.Y.Z` (notes = tag message, or `docs/release-notes/X.Y.Z.md` if present). +5. Set the notes (`gh release edit vX.Y.Z --notes-file …`) in the style of earlier releases (short intro, bullet + list of user-visible changes, a *Downloads* list) and publish with `--draft=false --latest`. + Release notes and commit messages never mention Claude. ## Verifying UI changes There are no automated UI tests. Run the Debug build, check the relevant items in `docs/MANUAL_TESTS.md`, -and add new checklist items for new features. When automating with SendKeys use the grouped form `^(n)`. +and add new checklist items for new features. -## Rust port (branch `rust-port`) -Full reimplementation in Rust + egui/eframe for Windows, Linux and macOS (plan: `PLAN-rust-port.md`, untracked). -The C# projects stay untouched on this branch until the Rust app reaches parity. +## Code notes - Cargo workspace at the repo root (edition 2024, shared `[workspace.dependencies]`): - - `crates/fc-core` – library without UI dependencies (counterpart of `FolderCompare.Core`). + - `crates/fc-core` – library without UI dependencies. - `crates/foldercompare` – the egui app, binary `FolderCompare`. - `cargo build`, `cargo test --workspace`, `cargo fmt --all --check`, `cargo clippy --workspace --all-targets -- -D warnings` – all must pass before committing, on Windows and Linux. @@ -67,12 +49,12 @@ The C# projects stay untouched on this branch until the Rust app reaches parity. `DiffTree` with `NodeId`; refresh grafts new nodes and marks replaced ones `alive = false`), `compare/` (`scanner`, `engine` = `DiffEngine::compare`/`prepare_refresh` + `DiffResult::apply_refresh`, `content`, `glob`, `timestamp`, `path_comparison`), `ops/` (safety, planner, executor). -- Same cross-platform rules as the C# Core: relative paths use the OS separator (`model::join_relative`), names are +- Cross-platform rules: relative paths use the OS separator (`model::join_relative`), names are matched through `PathComparison` (`DiffResult::paths()`), dotfiles count as hidden on Unix. Cancellation is an `AtomicBool`; scans run on two scoped threads with a large stack (recursion per folder level, max 512). - Tests in `crates/fc-core/tests/` run on the real file system (`tempfile`, `filetime`); test paths are written with `\` and mapped by `common::p`. OS-specific cases use `#[cfg(...)]`. -- Rust safety invariants (same as above): `ops::ensure_inside_root` (lexical `..` resolution, ordinal, strictly +- Safety invariants in code: `ops::ensure_inside_root` (lexical `..` resolution, ordinal, strictly inside) guards every copy/delete/rename target; `ops::validate_roots` ignores case. `FileOperationExecutor` copies to `.tmpcopy` (1 MiB buffer), sets mtime (+ creation time on Windows/macOS) through the handle, renames over the target, copies attributes (Windows) or the mode (Unix), then verifies size/mtime/mode. Deletes go @@ -85,7 +67,7 @@ The C# projects stay untouched on this branch until the Rust app reaches parity. over the `LineSource` trait, `codec` (BOM / strict UTF-8 / Windows-1252, byte-exact round trip; a text without line breaks gets the OS newline). All offsets inside lines are **chars**, not bytes or UTF-16 units. - App crate (`crates/foldercompare`, eframe/egui **0.36** – egui-phosphor 0.14 needs it): `main.rs` (logging via - `tracing-appender`, panic hook), `cli.rs`, `settings.rs` (same `settings.json` as WPF: PascalCase, enums as + `tracing-appender`, panic hook), `cli.rs`, `settings.rs` (`settings.json` compatible with 1.x: PascalCase, enums as strings, unknown fields kept in `extra`, `FOLDERCOMPARE_SETTINGS_DIR` overrides the folder – use it for test runs so the user's settings stay untouched), `state.rs` (egui-free view model: filters, rows, sort, expansion, selection, counts, `can_*` rules; unit-tested), `app.rs` (workers send `Msg` over an mpsc channel and call @@ -94,7 +76,7 @@ The C# projects stay untouched on this branch until the Rust app reaches parity. when present, Phosphor icons, Hack for monospace), `dialogs.rs` (`egui::Modal` stack). - Run the Debug build: `target/debug/FolderCompare.exe "left" "right" --compare`. Screenshots: `shot.ps1` in the scratchpad (PrintWindow by process id). -- Operations (`actions.rs`): copy/delete/rename/rescan/export/profiles/settings follow `MainViewModel` step by step. +- Operations (`actions.rs`): copy/delete/rename/rescan/export/profiles/settings follow the former WPF `MainViewModel` (1.x) step by step. The executor runs on a worker; an overwrite question is `Msg::Overwrite` with a reply channel the dialog answers (closing it = Cancel all). Afterwards the affected rows are refreshed (`RefreshRequest`, plus `with_name` for "keep both" copies) and applied only if `MainState::generation` is unchanged. Items the trash refused are offered for a @@ -108,16 +90,16 @@ The C# projects stay untouched on this branch until the Rust app reaches parity. id, copy recompares synchronously first, shared scroll offset for both panes, overview bar, center strip, details, save/reload/close prompts). Each window is its own native window (`show_viewport_deferred`, state in `Arc>`); with two files on the command line `TextOnlyApp` runs it as the root window. -- Explorer menu (Rust, `explorer.rs`, Windows only): `build.rs` runs `src/FolderCompare.ShellExt/build.ps1` (MSVC; - a mutex serializes it with the WPF build) for `x86_64-pc-windows-msvc` and embeds the DLL with `include_bytes!` +- Explorer menu (`explorer.rs`, Windows only): `build.rs` runs `shellext/build.ps1` (MSVC; + a mutex serializes parallel cargo runs) for `x86_64-pc-windows-msvc` and embeds the DLL with `include_bytes!` (`cfg(shellext)`). Without MSVC (or with `FOLDERCOMPARE_NO_SHELLEXT`) the app builds without the integration and - the Tools entry is hidden. Same registry layout as the WPF app (`fc_core::shell_layout`); test runs with + the Tools entry is hidden. Registry layout in `fc_core::shell_layout`; test runs with `FOLDERCOMPARE_SETTINGS_DIR` skip the start-up re-registration. `build.rs` also compiles a generated `.rc` (app.ico, `windows/app.manifest`: asInvoker, longPathAware, PerMonitorV2, version info from Cargo). -- Rust release (`.github/workflows/rust-release.yml`, tags `v2.*`): bump `version` in the root `Cargo.toml` +- Release workflow (`.github/workflows/rust-release.yml`, only tags `v2.*` – widen the filter for 3.x): bump `version` in the root `Cargo.toml` (the workflow fails if it differs from the tag), push an annotated tag whose message is the release notes (or add `docs/release-notes/X.Y.Z.md`). It tests, builds win-x64 / linux-x64 / macos-arm64 / macos-x64, packages (exe, zip, tar.gz, ad-hoc signed `.app` zips via `build/macos/make-app.sh`), adds `SHA256SUMS.txt` and creates a draft release. Local release builds: `cargo build --release` → copy to `publish/rust//`. -- Verifying the Rust app: `docs/MANUAL_TESTS.md` ("Rust app" section, per OS). Linux via WSLg (`CLAUDE.local.md`), +- Verifying the app: `docs/MANUAL_TESTS.md` ("App specifics and per-OS checks"). Linux via WSLg (`CLAUDE.local.md`), macOS through CI only. diff --git a/Directory.Build.props b/Directory.Build.props deleted file mode 100644 index 7dc2074..0000000 --- a/Directory.Build.props +++ /dev/null @@ -1,11 +0,0 @@ - - - 12 - enable - enable - false - darkcoder2000 - Copyright (c) 2026 darkcoder2000 - MIT - - diff --git a/FolderCompare.sln b/FolderCompare.sln deleted file mode 100644 index 2d09d2e..0000000 --- a/FolderCompare.sln +++ /dev/null @@ -1,43 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31903.59 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{09CF6283-5B98-4982-9063-C49C1534CA1B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FolderCompare.Core", "src\FolderCompare.Core\FolderCompare.Core.csproj", "{EE1781BF-59D1-468D-BAB7-DEFD80F76732}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FolderCompare.App", "src\FolderCompare.App\FolderCompare.App.csproj", "{8CEC40AB-271A-44EF-920C-21C1A38082FA}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{65FB9460-8F23-4525-88D6-D49038148AF0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FolderCompare.Core.Tests", "tests\FolderCompare.Core.Tests\FolderCompare.Core.Tests.csproj", "{F02F61A3-013A-43CD-A186-E2770BB5053A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EE1781BF-59D1-468D-BAB7-DEFD80F76732}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EE1781BF-59D1-468D-BAB7-DEFD80F76732}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EE1781BF-59D1-468D-BAB7-DEFD80F76732}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EE1781BF-59D1-468D-BAB7-DEFD80F76732}.Release|Any CPU.Build.0 = Release|Any CPU - {8CEC40AB-271A-44EF-920C-21C1A38082FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8CEC40AB-271A-44EF-920C-21C1A38082FA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8CEC40AB-271A-44EF-920C-21C1A38082FA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8CEC40AB-271A-44EF-920C-21C1A38082FA}.Release|Any CPU.Build.0 = Release|Any CPU - {F02F61A3-013A-43CD-A186-E2770BB5053A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F02F61A3-013A-43CD-A186-E2770BB5053A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F02F61A3-013A-43CD-A186-E2770BB5053A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F02F61A3-013A-43CD-A186-E2770BB5053A}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {EE1781BF-59D1-468D-BAB7-DEFD80F76732} = {09CF6283-5B98-4982-9063-C49C1534CA1B} - {8CEC40AB-271A-44EF-920C-21C1A38082FA} = {09CF6283-5B98-4982-9063-C49C1534CA1B} - {F02F61A3-013A-43CD-A186-E2770BB5053A} = {65FB9460-8F23-4525-88D6-D49038148AF0} - EndGlobalSection -EndGlobal diff --git a/README.md b/README.md index 100eee0..ef51de9 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # FolderCompare -A fast, portable, safety-first folder comparison tool for Windows. +A fast, portable, safety-first folder comparison tool for Windows, Linux and macOS. [![Latest release](https://img.shields.io/github/v/release/darkcoder2000/FolderCompare)](https://github.com/darkcoder2000/FolderCompare/releases/latest) [![License: MIT](https://img.shields.io/github/license/darkcoder2000/FolderCompare)](LICENSE) -![.NET 8](https://img.shields.io/badge/.NET-8-512BD4) -![Platform: Windows](https://img.shields.io/badge/platform-Windows-0078D6) +![Rust](https://img.shields.io/badge/Rust-egui-B7410E) +![Platforms: Windows, Linux, macOS](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-0078D6) FolderCompare compares two directory trees **by last-write timestamp and size** (with optional byte-by-byte verification), shows the result side by side, and lets you copy, delete or rename items from a right-click menu or @@ -17,18 +17,25 @@ the keyboard. ## Download -Get `FolderCompare.exe` from the [latest release](https://github.com/darkcoder2000/FolderCompare/releases/latest) -and run it. It's a single file for Windows x64, with no installer, no admin rights and no .NET runtime needed. +Get the build for your system from the [latest release](https://github.com/darkcoder2000/FolderCompare/releases/latest): + +* **Windows x64:** `FolderCompare.exe` (or the `-win-x64.zip`). A single file, no installer, no admin rights. +* **Linux x64:** `-linux-x64.tar.gz` with the `FolderCompare` binary. +* **macOS:** `-macos-arm64.zip` (Apple Silicon) or `-macos-x64.zip` (Intel) with `FolderCompare.app`. The app is + ad-hoc signed, so open it the first time via right-click → *Open*. + +`SHA256SUMS.txt` lists the checksums. Version 2.0 replaced the earlier Windows-only .NET app (1.x); settings and +profiles carry over. ## Why FolderCompare? -* **Portable single exe.** Nothing to install, no admin rights, no .NET runtime. +* **Portable single binary.** Nothing to install, no admin rights, no runtime. Runs on Windows, Linux and macOS. * **Fast on large trees.** By default it compares timestamps and sizes and never reads file contents. Content verification is optional and only reads the files that need it. * **Timestamp tolerance.** Configurable tolerance (default 2 s) and an optional 1-hour DST tolerance for NTFS vs. FAT/exFAT/NAS copies. * **Safety-first file operations.** Copies use a temp file and rename, targets are checked against the root, deletes - go to the Recycle Bin, and every operation is logged. + go to the Recycle Bin / Trash, and every operation is logged. * **Built-in text diff.** Side-by-side, word-level highlights, editable panes, and the file's encoding and line endings are kept when you save. @@ -42,13 +49,13 @@ and run it. It's a single file for Windows x64, with no installer, no admin righ ### Command line ``` -FolderCompare.exe "C:\A" "D:\B" [--compare] [--no-recursive] [--content off|equal-time|equal-size] +FolderCompare "C:\A" "D:\B" [--compare] [--no-recursive] [--content off|equal-time|equal-size] ``` `--compare` starts the comparison immediately. `--no-recursive` compares only the top level for this session. `--content` overrides the content verification mode for this session (see [How it compares](#how-it-compares)). -### Explorer context menu +### Explorer context menu (Windows) Turn on *Tools → Explorer context menu integration* to add entries to the right-click menu of files and folders in Windows Explorer. The menu shows only the entries that make sense for the current selection: @@ -93,7 +100,8 @@ Shift+F10). The integration requires 64-bit Windows on x64. equal. Their timestamps are left as they are. * Known limitation: with verification off, a change that keeps the size and the timestamp (within the tolerance, or exactly 1 hour apart with the DST option) is not detected. Turn on verification when that matters. -* Paths match case-insensitively. Long paths and Unicode are supported. Unreadable folders are marked as errors +* Names match case-insensitively on Windows and macOS, and case-sensitively on Linux or on a case-sensitive + volume. Long paths and Unicode are supported. Unreadable folders are marked as errors and the scan continues. * Symbolic links and junctions are skipped by default. If you choose *Follow*, loops are detected. * In non-recursive mode, sub-folders that exist on both sides are shown without contents and marked `=`. @@ -101,11 +109,11 @@ Shift+F10). The integration requires 64-bit Windows on x64. ## Safety * Scanning never modifies anything. -* Every copy and delete target is checked to be strictly inside the chosen root (after `GetFullPath`). +* Every copy, delete and rename target is checked to be strictly inside the chosen root (after resolving `..`). * Comparing a folder with itself, or with a folder nested inside it, is refused. * Copies go to `.tmpcopy` first and are renamed on success. Timestamps and attributes are preserved and verified (exists, size, timestamp). A cancelled copy leaves no partial file. -* Deletes go to the Recycle Bin by default. Permanent delete needs an extra confirmation. +* Deletes go to the Recycle Bin / Trash by default. Permanent delete needs an extra confirmation. * Overwriting a file that is newer than the source always asks first, with a warning. ## Keyboard @@ -157,35 +165,40 @@ A file that exists on one side only opens against an empty pane. ## Files -* Settings: `%APPDATA%\FolderCompare\settings.json` (options, last folders, recent paths, profiles, window and columns) -* Logs: `%LOCALAPPDATA%\FolderCompare\logs` (daily, kept 14 days; every file operation is logged). Open it via *File → Open log folder*. - -## Build from source +| | Windows | Linux | macOS | +|---|---|---|---| +| Settings (`settings.json`: options, last folders, recent paths, profiles, window, columns) | `%APPDATA%\FolderCompare` | `~/.config/FolderCompare` | `~/Library/Application Support/FolderCompare` | +| Logs (daily, kept 14 days; every file operation is logged) | `%LOCALAPPDATA%\FolderCompare\logs` | `~/.local/state/FolderCompare/logs` | `~/Library/Logs/FolderCompare` | -Requires the .NET 8 SDK (Windows). +Open the log folder via *File → Open log folder*. -```powershell -dotnet build -dotnet test -dotnet run --project src/FolderCompare.App -- "C:\A" "D:\B" --compare -``` +## Build from source -To publish the single-file exe: +Requires a current stable Rust toolchain ([rustup](https://rustup.rs)). On Windows the Explorer context menu +extension is built with the MSVC Build Tools (C++ workload); without them the app is built without that +integration. On Linux, eframe needs the usual X11/Wayland development packages (see `.github/workflows/rust.yml`). -```powershell -dotnet publish src/FolderCompare.App -c Release -o publish +```sh +cargo build +cargo test --workspace +cargo run -p foldercompare -- "C:\A" "D:\B" --compare ``` -The Release configuration produces a self-contained, single-file `publish\FolderCompare.exe` (win-x64). +Release build: `cargo build --release` → `target/release/FolderCompare(.exe)`. Pushing a tag `v2.X.Y` builds and +packages all platforms in CI (`.github/workflows/rust-release.yml`). ### Project layout ``` -src/FolderCompare.Core/ comparison engine, models, file operations, text diff (no WPF dependency) -src/FolderCompare.App/ WPF app (MVVM with CommunityToolkit.Mvvm) -tests/FolderCompare.Core.Tests xUnit tests (System.IO.Abstractions mock file system + a few real-FS tests) -tools/New-ExampleDiff.ps1 creates two example folders that cover every compare case -docs/MANUAL_TESTS.md manual test checklist +crates/fc-core/ comparison engine, models, file operations, reports, text diff (no UI dependency) +crates/fc-core/tests/ integration tests on the real file system +crates/foldercompare/ the app (egui/eframe), binary FolderCompare +crates/foldercompare/shellext/ Windows Explorer context menu extension (C++, embedded in the exe) +crates/foldercompare/assets/ app icon (SVG source, .ico, PNG) +build/macos/make-app.sh builds the macOS .app bundle +tools/New-ExampleDiff.ps1 creates two example folders that cover every compare case +tools/make-icon.ps1 renders the app icon into the .ico +docs/MANUAL_TESTS.md manual test checklist ``` ## Comparison with other tools @@ -197,7 +210,7 @@ current details. | | FolderCompare | WinMerge | Beyond Compare | FreeFileSync | |---|---|---|---|---| | License | Free, MIT | Free, GPL | Commercial | Free, GPL | -| Platforms | Windows | Windows | Windows, macOS, Linux | Windows, macOS, Linux | +| Platforms | Windows, macOS, Linux | Windows | Windows, macOS, Linux | Windows, macOS, Linux | | Folder comparison | Date and size, optional contents | Contents, size, date | Contents, size, date | Date and size, or contents | | Text diff | Yes, two-way | Yes, two- and three-way | Yes, two- and three-way | No | | Focus | Quick comparison, manual copy | Diff and merge | Diff and merge | Folder synchronization | @@ -209,20 +222,20 @@ If you need byte-level folder comparison, three-way merge or automatic sync, one Planned: -* Dark theme / follow the system theme (colors already live in `Themes/Colors.xaml`) -* `.resx` localization +* Dark theme / follow the system theme (colors already live in `theme.rs`) +* Localization * Flat list view mode * Rubber-band selection -Ideas, not planned yet: content/hash comparison of whole folders, three-way compare, remote locations. The engine -works on `System.IO.Abstractions.IFileSystem`, so another file-system provider can be plugged in later. +Ideas, not planned yet: content/hash comparison of whole folders, three-way compare, remote locations. ## Contributing -Bug reports, ideas and pull requests are welcome. Please open an issue first for bigger changes. Run `dotnet test` +Bug reports, ideas and pull requests are welcome. Please open an issue first for bigger changes. Run +`cargo test --workspace`, `cargo fmt --all --check` and `cargo clippy --workspace --all-targets -- -D warnings` before submitting. For UI changes, check the relevant items in [docs/MANUAL_TESTS.md](docs/MANUAL_TESTS.md). -When reporting a bug, include your Windows version, the app version and, if possible, the log file from -`%LOCALAPPDATA%\FolderCompare\logs`. +When reporting a bug, include your OS and version, the app version and, if possible, the log file (see +[Files](#files)). ## License diff --git a/REQUIREMENTS_CompareTool.md b/REQUIREMENTS_CompareTool.md deleted file mode 100644 index fa0a2b7..0000000 --- a/REQUIREMENTS_CompareTool.md +++ /dev/null @@ -1,291 +0,0 @@ -# Project: FolderCompare – Timestamp-Based Directory Compare Tool (Windows / C# / WPF) - -> **Instructions for Claude Code:** Build the application described below. Work in the phases listed in section 12, commit after each phase, and keep the solution building at all times. Ask me before deviating from the tech stack in section 2. Where a requirement says "should", use your judgment; where it says "must", it is mandatory. - ---- - -## 1. Purpose - -A fast, portable, safety-first folder comparison tool for Windows. It compares two directory trees **by modification timestamp only** (no content or hash comparison in v1), shows the result in a side-by-side UI, and lets the user copy or delete files via a right-click context menu. - -Non-goals for v1: content/hash comparison, text diff, three-way compare, remote locations (SFTP/SMB URLs), cross-platform support. - ---- - -## 2. Tech Stack (fixed) - -| Item | Choice | -|---|---| -| Language | C# 12 | -| Runtime | .NET 8 (LTS), Windows only (`net8.0-windows`) | -| UI | WPF | -| Pattern | MVVM, with `CommunityToolkit.Mvvm` (source generators, `ObservableObject`, `RelayCommand`) | -| DI / hosting | `Microsoft.Extensions.DependencyInjection` (keep it light) | -| Logging | `Serilog` with a rolling file sink (`%LOCALAPPDATA%\FolderCompare\logs`) | -| Settings | JSON file in `%APPDATA%\FolderCompare\settings.json` (`System.Text.Json`) | -| Recycle bin delete | `Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile/DeleteDirectory` with `RecycleOption.SendToRecycleBin` | -| Tests | xUnit (+ `System.IO.Abstractions` for a mockable file system) | -| Packaging | `dotnet publish` as single-file, self-contained, `win-x64` (no installer required) | - -Solution layout (suggested): - -``` -FolderCompare.sln - ├─ src/FolderCompare.Core/ # comparison engine, models, file operations (no UI references) - ├─ src/FolderCompare.App/ # WPF project (Views, ViewModels, Converters, Resources) - └─ tests/FolderCompare.Core.Tests/ -``` - -The Core project must have **no dependency on WPF** so the engine is fully unit-testable. - ---- - -## 3. Core Comparison Engine - -### 3.1 Inputs -- Left folder path, right folder path. -- Options: recursive (default on), timestamp tolerance, DST offset handling, symlink handling, include/exclude patterns, ignore hidden/system files. - -### 3.2 Timestamp comparison rules -- Compare **last write time (UTC)** only. -- **Tolerance:** configurable, default **2 seconds** (covers FAT/exFAT rounding). Two files whose timestamps differ by ≤ tolerance are "identical". -- **DST option:** optional "ignore ±1 hour differences" setting (default off). When on, a difference of exactly 3600 s (± tolerance) counts as identical. -- File size is shown but is **not** used for the comparison result. - -### 3.3 Item classification -Each relative path gets exactly one status: - -| Status | Meaning | -|---|---| -| `OnlyLeft` | Exists only in left | -| `OnlyRight` | Exists only in right | -| `NewerLeft` | Exists in both, left is newer | -| `NewerRight` | Exists in both, right is newer | -| `Identical` | Exists in both, timestamps equal within tolerance | -| `TypeConflict` | File on one side, folder on the other | -| `Error` | Could not be read (access denied, locked, etc.) – store the error message | - -Folders get a **rolled-up status**: `Identical` only if everything inside is identical; otherwise `Differs`. A folder that exists on one side only is `OnlyLeft`/`OnlyRight`. - -### 3.4 Scanning behavior -- Use streaming enumeration (`Directory.EnumerateFileSystemEntries` / `FileSystemEnumerable`), not `GetFiles` into big arrays. -- Enumerate left and right in parallel (bounded parallelism). -- Path matching is **case-insensitive** (Windows semantics). -- Must support **long paths** (> 260 chars) and Unicode names. -- Symlinks/junctions: setting `Follow | Skip` (default `Skip`), with loop protection if following. -- Unreadable items must not abort the scan; mark them `Error` and continue. -- The scan runs on a background task with **progress reporting** (items scanned, current folder) and supports **cancellation** via `CancellationToken`. -- The scan **must never modify** anything. - -### 3.5 Result model (suggested) -```csharp -record DiffNode( - string RelativePath, string Name, bool IsDirectory, - FileInfoSnapshot? Left, FileInfoSnapshot? Right, - DiffStatus Status, string? ErrorMessage, - List Children); - -record FileInfoSnapshot(long Size, DateTime LastWriteUtc, FileAttributes Attributes, string FullPath); -``` - ---- - -## 4. UI Requirements (WPF) - -### 4.1 Main window layout -1. **Top bar:** Left folder path box + Browse button | Right folder path box + Browse button | Swap button (⇄) | Compare/Refresh button. Both path boxes accept typed paths, pasted paths, and **drag-and-drop of a folder**. Path boxes have a dropdown with recent paths (last 20). -2. **Toolbar:** filter toggles (see 4.5), search box, Copy →, ← Copy, Delete, Refresh, Options. -3. **Main area:** side-by-side comparison (see 4.2). -4. **Status bar:** counts per category (e.g. `12 only left · 5 newer right · 340 identical`), number of selected items, total size of selected items, and a progress bar while scanning or copying. - -### 4.2 Side-by-side view -**Recommended implementation:** a single virtualized tree-grid where **each row represents one relative path** and contains both a left cell group and a right cell group. This guarantees perfect row alignment and synchronized scrolling without any scroll-sync code. (WPF has no built-in TreeListView. Either flatten the tree into an `ObservableCollection` with an indent level and expand/collapse toggles, or use a `TreeView` with a custom `ControlTemplate`. The flattened-list approach is preferred for virtualization and performance.) - -Each row shows, for each side: -- Icon (file/folder), name, size, modified date/time. -- A missing item shows an empty placeholder cell. -- A center column shows a **status glyph** (e.g. `→` copy-to-right candidate, `←`, `=`, `≠`, `⚠`). - -Requirements: -- Row virtualization (`VirtualizingStackPanel`, recycling mode) – must stay smooth with **100,000+ rows**. -- Expand/collapse folders; "Expand all" / "Collapse all"; keyboard navigation (arrows, ←/→ for collapse/expand, Space to toggle selection). -- Columns sortable (name, size, date, status) and resizable. Sorting keeps folders grouped before files by default (configurable). -- **Multi-select** with Ctrl/Shift click and rubber-band not required. -- Optional **flat list mode** (toggle) showing full relative paths instead of a tree. - -### 4.3 Color coding (theme-aware, configurable in resources) -| State | Style | -|---|---| -| Newer side | Bold, green text | -| Older side | Grey text | -| Only-on-one-side | Blue text | -| Identical | Default text | -| Type conflict / Error | Red text with warning icon | -| Folder with differences | Folder icon with a small marker | - -Provide **light and dark themes** (system-follow option). Keep brushes in `ResourceDictionary` files, not hard-coded. - -### 4.4 Context menu (right-click) -Right-click acts on the **current multi-selection** (if the clicked row is not part of the selection, select it first). Items are enabled/disabled depending on the selection: - -- **Copy to Right →** (enabled if any selected item exists on the left) -- **← Copy to Left** (enabled if any selected item exists on the right) -- **Delete Left**, **Delete Right**, **Delete Both** (to Recycle Bin by default) -- **Rename…** -- **Open** (default app) / **Open containing folder** / **Show in Explorer** (`explorer.exe /select,`) -- **Copy full path** (left / right / both) to clipboard -- **Select all newer on left**, **Select all newer on right**, **Select all only-left**, **Select all only-right**, **Invert selection** -- **Expand / Collapse subtree** - -Copying a folder copies its whole contents. Copying an item creates missing parent directories on the target side. - -### 4.5 Filtering and views -- Toggle buttons to show/hide: Only Left, Only Right, Newer Left, Newer Right, Identical, Errors/Conflicts. Default: show everything except... show everything. -- **"Show differences only"** quick toggle (hides identical items and folders with no differing content). -- **Include/exclude patterns** (glob, semicolon-separated, e.g. `*.tmp;.git;node_modules;bin;obj`), applied during the scan. -- **Quick search** box: live filter by file/folder name within the displayed results. -- Option: ignore hidden and system files. - ---- - -## 5. File Operations - -### 5.1 Copy -- Copy is performed in the **background** through an **operation queue** with per-file progress, overall progress, and a Cancel button. -- **Preserve the last-write timestamp** (and creation time where possible) on the copied file so it becomes `Identical` afterwards. -- Preserve file attributes (read-only etc.). If the destination is read-only and overwrite is confirmed, clear the attribute temporarily. -- After each copy, **verify**: destination exists, size matches, timestamp matches within tolerance. Report mismatches as failures. -- Copy to a temporary name (`.tmpcopy`) in the target folder and rename on success, so partial files never replace good ones. -- After a successful operation, **update the affected rows in place** (re-stat those items) instead of rescanning the entire tree. - -### 5.2 Overwrite policy -Setting + per-operation dialog with: **Ask each time / Skip / Overwrite / Overwrite only if newer / Keep both (rename)**, plus an "Apply to all" checkbox. Overwriting a file that is **newer** than the source must trigger an explicit extra warning, since the direction might be a mistake. - -### 5.3 Delete -- Default: send to Recycle Bin. Setting for permanent delete (with a stronger confirmation). -- Confirmation dialog listing the count and total size, with a "Don't ask again" option (only for recycle-bin deletes). - -### 5.4 Dry run / preview -- Before executing copy/delete, show a **preview dialog** listing every action (source → destination, size, overwrite yes/no). Can be disabled in settings ("Skip preview for fewer than N items"). - -### 5.5 Result summary -- After every operation batch show a summary: succeeded / skipped / failed, with the failure reasons and an option to copy the report to the clipboard. All operations are logged (section 9). - -### 5.6 Safety rules (must) -- Never modify, create, or delete anything during scan/compare. -- Never operate outside the two root folders. Validate that every target path resolves (after `Path.GetFullPath`) to inside the chosen root, to guard against path-traversal bugs. -- Refuse to run if left and right resolve to the same folder, or if one is inside the other (show a clear message). -- Handle locked/in-use files gracefully (report, do not crash). - ---- - -## 6. Sessions, Settings, and Command Line - -- **Command line:** `FolderCompare.exe "C:\A" "D:\B" [--compare] [--no-recursive]` pre-fills both folders and optionally starts the comparison immediately. -- **Single-instance** not required. -- **Remember** last-used folder pair, window size/position, column widths, and all options. -- **Favorites / profiles:** save a named pair of folders plus the options (filters, tolerance) and reopen it from a dropdown or menu. -- **Keyboard shortcuts:** - -| Key | Action | -|---|---| -| F5 | Refresh / rescan | -| Ctrl+Right | Copy selection to right | -| Ctrl+Left | Copy selection to left | -| Delete | Delete (asks which side if both exist) | -| F2 | Rename | -| Ctrl+F | Focus search box | -| Ctrl+A | Select all visible | -| Ctrl+E | Export report | -| Esc | Cancel running scan/operation | - -- **Refresh options:** full rescan, or rescan only the selected folder subtree. -- **Export report** of the current (filtered) differences to **CSV** and plain text. -- **Settings dialog** covering: tolerance, DST handling, symlink mode, hidden/system files, default exclude patterns, overwrite policy, delete mode, confirmations, theme, preview threshold. - ---- - -## 7. Non-Functional Requirements - -- **Performance targets** (local SSD): scanning 100,000 files in ≈ 10 s or less; UI remains responsive at all times; memory < 500 MB for 100k files per side. -- **Responsiveness:** all I/O off the UI thread; UI updates batched (e.g. every 100 ms) during scanning. -- **Reliability:** no unhandled exceptions reaching the user; global exception handler logs and shows a friendly dialog. -- **Accessibility:** keyboard-operable, readable contrast in both themes, sensible tab order. -- **Localization:** English only for v1, but keep strings in `.resx` for later translation. -- **Portability:** produce a single-file `FolderCompare.exe`; no admin rights required. - ---- - -## 8. Error Handling - -| Situation | Behavior | -|---|---| -| Folder does not exist / not accessible | Inline message next to the path box, comparison disabled | -| Access denied on a subfolder | Mark node as `Error`, continue scan, show count in status bar | -| Disk full / copy failure | Stop that item, record failure, continue with the rest unless the user cancels | -| Path too long / invalid characters | Report as failed item with reason | -| Cancel during copy | Finish or roll back the current file (no partial files remain), then stop | - ---- - -## 9. Logging - -- Serilog rolling daily file log, keep 14 days. -- Log every file operation: timestamp, action, source, destination, result, error. -- "Open log folder" menu entry. - ---- - -## 10. Testing - -Unit tests in `FolderCompare.Core.Tests` (use `System.IO.Abstractions.TestingHelpers` for a mock file system) must cover: - -- Classification of all statuses, including tolerance edge cases (exactly at, just below, just above the threshold). -- DST ±1 hour handling on/off. -- Folder roll-up status. -- Case-insensitive path matching. -- Type conflicts (file vs. folder). -- Include/exclude pattern matching. -- Symlink loop protection. -- Copy: timestamp preserved, parent folders created, overwrite policies, verification failure path. -- Safety rules: path traversal rejection, nested/same-root rejection. -- Cancellation of scan and copy. - -Also add a small manual test checklist in `docs/MANUAL_TESTS.md`. - ---- - -## 11. Acceptance Criteria (definition of done for v1) - -1. I can pick two folders, press Compare, and see aligned side-by-side results with correct statuses. -2. Right-clicking one or more rows offers Copy to Right/Left and Delete; after copying, the affected rows become `Identical` without a full rescan. -3. Timestamps on copied files match the source. -4. Scanning 100k files does not freeze the UI and can be cancelled. -5. Filters, search, and "differences only" work and update instantly. -6. Settings, last folders, and profiles persist across restarts. -7. Command-line invocation with two folders works. -8. Unit tests pass; `dotnet publish` produces a working single-file `FolderCompare.exe`. -9. No operation ever touches a path outside the two roots. - ---- - -## 12. Suggested Build Order - -1. **Phase 1 – Core engine:** solution setup, models, scanner, timestamp comparer, roll-up, unit tests. -2. **Phase 2 – Basic UI:** main window, folder pickers, scan with progress/cancel, flattened side-by-side tree-grid with status colors. -3. **Phase 3 – File operations:** context menu, copy/delete queue, overwrite policy, preview dialog, verification, in-place row refresh, summary dialog. -4. **Phase 4 – Filtering and productivity:** filter toggles, search, include/exclude patterns, selection helpers, sorting, flat mode, keyboard shortcuts. -5. **Phase 5 – Persistence and polish:** settings dialog, recent paths, profiles, command line, themes, report export, logging, global error handling. -6. **Phase 6 – Hardening:** performance test with 100k+ files, long paths, locked files, packaging, manual test checklist, README. - -After each phase: build, run tests, and give me a short summary of what works and what is left. - ---- - -## 13. Future Ideas (out of scope for v1, keep the architecture open for them) - -- Optional comparison modes: size, content hash. -- Text diff viewer on double-click. -- Three-way compare. -- Sync rules (mirror / update / two-way). -- SFTP / SMB / cloud locations (introduce an `IFileSystemProvider` abstraction now to make this easier). diff --git a/build/macos/make-app.sh b/build/macos/make-app.sh index 8457041..ce550b9 100755 --- a/build/macos/make-app.sh +++ b/build/macos/make-app.sh @@ -15,7 +15,7 @@ mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" cp "$binary" "$app/Contents/MacOS/FolderCompare" chmod +x "$app/Contents/MacOS/FolderCompare" -# Icon: all iconset sizes scaled from the 256 px rendering of Assets/app-icon.svg (tools/make-icon.ps1). +# Icon: all iconset sizes scaled from the 256 px rendering of assets/app-icon.svg (tools/make-icon.ps1). iconset="$(mktemp -d)/FolderCompare.iconset" mkdir -p "$iconset" for size in 16 32 128 256 512; do diff --git a/crates/fc-core/src/lib.rs b/crates/fc-core/src/lib.rs index 483a536..4ae9161 100644 --- a/crates/fc-core/src/lib.rs +++ b/crates/fc-core/src/lib.rs @@ -1,5 +1,5 @@ //! FolderCompare core: folder scanning and comparison, file operations, reports and the text diff. -//! Has no UI dependencies (the counterpart of `FolderCompare.Core`). +//! Has no UI dependencies. pub mod compare; pub mod model; diff --git a/crates/fc-core/src/shell_layout.rs b/crates/fc-core/src/shell_layout.rs index 016d2f5..206ed42 100644 --- a/crates/fc-core/src/shell_layout.rs +++ b/crates/fc-core/src/shell_layout.rs @@ -1,6 +1,6 @@ //! Registry layout of the Windows Explorer context menu. The entries are `IExplorerCommand` handlers in //! FolderCompare.ShellExt.dll, which decides visibility and titles itself and keeps the selected left item. -//! The CLSIDs and the `Software\FolderCompare` value names must match src/FolderCompare.ShellExt/ShellExt.cpp. +//! The CLSIDs and the `Software\FolderCompare` value names must match crates/foldercompare/shellext/ShellExt.cpp. //! Pure data, so it is testable on every OS. use std::path::Path; diff --git a/src/FolderCompare.App/Assets/app-icon.svg b/crates/foldercompare/assets/app-icon.svg similarity index 100% rename from src/FolderCompare.App/Assets/app-icon.svg rename to crates/foldercompare/assets/app-icon.svg diff --git a/src/FolderCompare.App/Assets/app.ico b/crates/foldercompare/assets/app.ico similarity index 100% rename from src/FolderCompare.App/Assets/app.ico rename to crates/foldercompare/assets/app.ico diff --git a/crates/foldercompare/build.rs b/crates/foldercompare/build.rs index cd7262e..1fe5af0 100644 --- a/crates/foldercompare/build.rs +++ b/crates/foldercompare/build.rs @@ -1,4 +1,4 @@ -//! Windows only: builds the native Explorer extension (`src/FolderCompare.ShellExt`, MSVC) to embed it, and +//! Windows only: builds the native Explorer extension (`shellext/`, MSVC) to embed it, and //! compiles the icon, manifest and version info into the exe. use std::env; @@ -31,7 +31,7 @@ fn build_shell_extension(manifest_dir: &Path) { ); return; } - let dir = manifest_dir.join("../../src/FolderCompare.ShellExt"); + let dir = manifest_dir.join("shellext"); for f in ["ShellExt.cpp", "ShellExt.def", "build.ps1"] { println!("cargo::rerun-if-changed={}", dir.join(f).display()); } @@ -56,7 +56,7 @@ fn build_shell_extension(manifest_dir: &Path) { fn compile_resources(manifest_dir: &Path) { let out = PathBuf::from(env::var("OUT_DIR").unwrap()); - let icon = manifest_dir.join("../../src/FolderCompare.App/Assets/app.ico"); + let icon = manifest_dir.join("assets/app.ico"); let manifest = manifest_dir.join("windows/app.manifest"); println!("cargo::rerun-if-changed={}", manifest.display()); println!("cargo::rerun-if-changed={}", icon.display()); diff --git a/src/FolderCompare.ShellExt/ShellExt.cpp b/crates/foldercompare/shellext/ShellExt.cpp similarity index 100% rename from src/FolderCompare.ShellExt/ShellExt.cpp rename to crates/foldercompare/shellext/ShellExt.cpp diff --git a/src/FolderCompare.ShellExt/ShellExt.def b/crates/foldercompare/shellext/ShellExt.def similarity index 100% rename from src/FolderCompare.ShellExt/ShellExt.def rename to crates/foldercompare/shellext/ShellExt.def diff --git a/src/FolderCompare.ShellExt/build.ps1 b/crates/foldercompare/shellext/build.ps1 similarity index 92% rename from src/FolderCompare.ShellExt/build.ps1 rename to crates/foldercompare/shellext/build.ps1 index 709a4a9..0b763d2 100644 --- a/src/FolderCompare.ShellExt/build.ps1 +++ b/crates/foldercompare/shellext/build.ps1 @@ -1,5 +1,5 @@ -# Builds FolderCompare.ShellExt.dll (x64) with the MSVC Build Tools. Called by FolderCompare.App.csproj and -# FolderCompare.Avalonia.csproj; a solution build runs both in parallel, so the compile is serialized by a mutex. +# Builds FolderCompare.ShellExt.dll (x64) with the MSVC Build Tools. Called by crates/foldercompare/build.rs; +# parallel cargo runs (build, clippy, test, IDE) can start it at the same time, so the compile is serialized by a mutex. param([string]$OutDir = (Join-Path $PSScriptRoot 'bin\x64')) $ErrorActionPreference = 'Stop' diff --git a/crates/foldercompare/src/actions.rs b/crates/foldercompare/src/actions.rs index 13f0a16..16de25c 100644 --- a/crates/foldercompare/src/actions.rs +++ b/crates/foldercompare/src/actions.rs @@ -1,5 +1,5 @@ //! Commands of the main window: copy, delete, rename, rescan, export, shell actions, settings and profiles. -//! Same order and messages as the WPF `MainViewModel`. +//! Same order and messages as the former WPF `MainViewModel` (1.x). use std::path::PathBuf; use std::sync::Arc; diff --git a/crates/foldercompare/src/settings.rs b/crates/foldercompare/src/settings.rs index a338c78..aee0496 100644 --- a/crates/foldercompare/src/settings.rs +++ b/crates/foldercompare/src/settings.rs @@ -1,4 +1,4 @@ -//! `settings.json`, shared with the WPF app: PascalCase names, enums as strings, missing fields take their +//! `settings.json`, compatible with the 1.x (WPF) app: PascalCase names, enums as strings, missing fields take their //! defaults, unknown fields are kept when writing back. Written atomically through `settings.json.tmp`. use std::fs; diff --git a/docs/MANUAL_TESTS.md b/docs/MANUAL_TESTS.md index 214708f..fe24cd1 100644 --- a/docs/MANUAL_TESTS.md +++ b/docs/MANUAL_TESTS.md @@ -117,13 +117,12 @@ Restart Explorer after changing the shell extension (`Stop-Process -Name explore - [ ] A binary file shows "is not a text file". A file larger than 20 MB asks first. - [ ] Closing the window, or the main window, with unsaved changes asks Save / Don't save / Cancel, and Cancel keeps it open. -## Rust app (branch `rust-port`) -The Rust/egui app (`target/debug/FolderCompare.exe`, or `publish/rust//` for release builds) must pass every -item above. For test runs set `FOLDERCOMPARE_SETTINGS_DIR` to a scratch folder: the real `settings.json` (shared -with the WPF app) stays untouched and an existing Explorer registration of another exe is left alone. -Additional items: -- [ ] Settings written by the WPF app are read (window bounds, column widths, filters, profiles, recent paths), and - the WPF app still reads the file after the Rust app saved it (unknown fields survive). +## App specifics and per-OS checks +Run `target/debug/FolderCompare(.exe)`, or `publish/rust//` for release builds. For test runs set +`FOLDERCOMPARE_SETTINGS_DIR` to a scratch folder: the real `settings.json` stays untouched and an existing Explorer +registration of another exe is left alone. +- [ ] Settings written by the 1.x (WPF) app are read (window bounds, column widths, filters, profiles, recent + paths), and unknown fields survive when the file is saved again. - [ ] The status column stays centered under the ⇄ button while resizing the window and the size/date columns. - [ ] Keyboard in the list: Up/Down/PgUp/PgDn/Home/End move the focus (Shift extends), Ctrl+Up/Down move only the focus, Space toggles, Right/Left expand/collapse/jump to the parent, Enter toggles or opens the text compare. @@ -140,9 +139,9 @@ Additional items: - [ ] Two files on the command line open only the text compare window; closing it exits the app. ### Windows -- [ ] The exe shows the app icon, version 2.0.0 in its properties, and no console window (release build). -- [ ] Tools > Explorer context menu integration registers/unregisters; the entries work with the Rust exe and the - registry layout is the same as the WPF app's (switching between both apps re-registers on start). +- [ ] The exe shows the app icon, the current version in its properties, and no console window (debug and release). +- [ ] Tools > Explorer context menu integration registers/unregisters, and the entries work. With the integration + on in a 1.x installation, starting the 2.x exe once takes the entries over (same registry layout). - [ ] Delete goes to the Recycle Bin; long paths (> 260 chars) can be compared and copied. ### Linux (WSLg or a desktop) diff --git a/src/FolderCompare.App/App.xaml b/src/FolderCompare.App/App.xaml deleted file mode 100644 index 6bcde0b..0000000 --- a/src/FolderCompare.App/App.xaml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - diff --git a/src/FolderCompare.App/App.xaml.cs b/src/FolderCompare.App/App.xaml.cs deleted file mode 100644 index 74c469f..0000000 --- a/src/FolderCompare.App/App.xaml.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System.IO; -using System.IO.Abstractions; -using System.Windows; -using System.Windows.Threading; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Serilog; -using FolderCompare.App.Services; -using FolderCompare.App.ViewModels; -using FolderCompare.Core.Comparison; -using FolderCompare.Core.Operations; -using FolderCompare.Core.Shell; - -namespace FolderCompare.App; - -public partial class App : Application -{ - private ServiceProvider? _services; - - protected override void OnStartup(StartupEventArgs e) - { - base.OnStartup(e); - - Log.Logger = new LoggerConfiguration() - .MinimumLevel.Information() - .WriteTo.File(Path.Combine(ShellService.LogDirectory, "foldercompare-.log"), - rollingInterval: RollingInterval.Day, - retainedFileCountLimit: 14) - .CreateLogger(); - - DispatcherUnhandledException += OnDispatcherUnhandledException; - AppDomain.CurrentDomain.UnhandledException += (_, args) => - Log.Fatal(args.ExceptionObject as Exception, "Unhandled exception"); - TaskScheduler.UnobservedTaskException += (_, args) => - { - Log.Error(args.Exception, "Unobserved task exception"); - args.SetObserved(); - }; - - var services = new ServiceCollection(); - services.AddLogging(b => b.AddSerilog(dispose: true)); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - _services = services.BuildServiceProvider(); - - Log.Information("FolderCompare started with arguments {Args}", e.Args); - _services.GetRequiredService().EnsureCurrentPath(); - var options = CommandLineOptions.Parse(e.Args); - if (options.Left is not null && options.Right is not null - && ExplorerMenuLayout.Classify(_services.GetRequiredService(), options.Left, options.Right) == PairKind.BothFiles) - { - OpenTextCompare(Path.GetFullPath(options.Left), Path.GetFullPath(options.Right)); - return; - } - - var viewModel = _services.GetRequiredService(); - viewModel.ApplyCommandLine(options); - - try - { - var window = _services.GetRequiredService(); - MainWindow = window; - window.Show(); - } - catch (Exception ex) - { - Log.Fatal(ex, "Startup failed"); - MessageBox.Show($"FolderCompare could not start:\n\n{ex.Message}", "FolderCompare", MessageBoxButton.OK, MessageBoxImage.Error); - Shutdown(1); - } - } - - /// Two files on the command line (e.g. Explorer "Compare Files"): only the text compare window opens. - private void OpenTextCompare(string left, string right) - { - Log.Information("Comparing files {Left} and {Right} from the command line", left, right); - ShutdownMode = ShutdownMode.OnLastWindowClose; - var leftName = Path.GetFileName(left); - var rightName = Path.GetFileName(right); - var title = string.Equals(leftName, rightName, StringComparison.OrdinalIgnoreCase) ? rightName : $"{leftName} / {rightName}"; - _services!.GetRequiredService().Open(new TextCompareRequest(left, true, right, true, title, null)); - if (Windows.Count == 0) Shutdown(0); - } - - protected override void OnExit(ExitEventArgs e) - { - Log.Information("FolderCompare exiting"); - _services?.Dispose(); - Log.CloseAndFlush(); - base.OnExit(e); - } - - private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) - { - Log.Error(e.Exception, "Unhandled UI exception"); - MessageBox.Show( - $"Something went wrong:\n\n{e.Exception.Message}\n\nThe details were written to the log folder:\n{ShellService.LogDirectory}", - "FolderCompare", MessageBoxButton.OK, MessageBoxImage.Error); - e.Handled = true; - } -} diff --git a/src/FolderCompare.App/AssemblyInfo.cs b/src/FolderCompare.App/AssemblyInfo.cs deleted file mode 100644 index cc29e7f..0000000 --- a/src/FolderCompare.App/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Windows; - -[assembly:ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] diff --git a/src/FolderCompare.App/Converters/VisibilityConverters.cs b/src/FolderCompare.App/Converters/VisibilityConverters.cs deleted file mode 100644 index 44e2b75..0000000 --- a/src/FolderCompare.App/Converters/VisibilityConverters.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Globalization; -using System.Windows; -using System.Windows.Data; - -namespace FolderCompare.App.Converters; - -public sealed class BoolToVisibilityConverter : IValueConverter -{ - public bool UseHidden { get; set; } - public bool Invert { get; set; } - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - bool visible = value is true; - if (Invert) visible = !visible; - return visible ? Visibility.Visible : UseHidden ? Visibility.Hidden : Visibility.Collapsed; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => - throw new NotSupportedException(); -} - -public sealed class NullToVisibilityConverter : IValueConverter -{ - public object Convert(object? value, Type targetType, object parameter, CultureInfo culture) => - value is null || value is string { Length: 0 } ? Visibility.Collapsed : Visibility.Visible; - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => - throw new NotSupportedException(); -} diff --git a/src/FolderCompare.App/FolderCompare.App.csproj b/src/FolderCompare.App/FolderCompare.App.csproj deleted file mode 100644 index d527786..0000000 --- a/src/FolderCompare.App/FolderCompare.App.csproj +++ /dev/null @@ -1,57 +0,0 @@ - - - - WinExe - net8.0-windows - true - FolderCompare - FolderCompare.App - app.manifest - 1.5.0 - FolderCompare - Assets\app.ico - - - - - win-x64 - true - true - true - embedded - - - - - - - - - - - - - - - - - - - $(MSBuildThisFileDirectory)..\FolderCompare.ShellExt\ - $(ShellExtDir)bin\x64\FolderCompare.ShellExt.dll - - - - - - - - - - - - - - - - diff --git a/src/FolderCompare.App/MainWindow.xaml b/src/FolderCompare.App/MainWindow.xaml deleted file mode 100644 index 05f08e3..0000000 --- a/src/FolderCompare.App/MainWindow.xaml +++ /dev/null @@ -1,316 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -