|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Solution |
| 6 | + |
| 7 | +`src/DiffEngine.slnx` |
| 8 | + |
| 9 | +## Build and Test Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +# Build (from repo root) |
| 13 | +dotnet build src --configuration Release |
| 14 | + |
| 15 | +# Run all tests |
| 16 | +dotnet test src --configuration Release |
| 17 | + |
| 18 | +# Run a single test file |
| 19 | +dotnet test src/DiffEngine.Tests --filter "FullyQualifiedName~ClassName" |
| 20 | + |
| 21 | +# Run a specific test |
| 22 | +dotnet test src/DiffEngine.Tests --filter "FullyQualifiedName=DiffEngine.Tests.ClassName.TestMethod" |
| 23 | +``` |
| 24 | + |
| 25 | +**SDK Requirements:** .NET 10 SDK (see `src/global.json`). The project uses preview/prerelease SDK features. |
| 26 | + |
| 27 | +**Target Frameworks:** |
| 28 | +- DiffEngine library: net462, net472, net48, net6.0, net7.0, net8.0, net9.0, net10.0 (Windows also includes .NET Framework targets) |
| 29 | +- DiffEngineTray: net10.0 Windows Forms application |
| 30 | +- Tests: net10.0 (net48 on Windows) |
| 31 | + |
| 32 | +## Architecture Overview |
| 33 | + |
| 34 | +DiffEngine is a library that manages launching and cleanup of diff tools for snapshot/approval testing. It's used by ApprovalTests, Shouldly, and Verify. |
| 35 | + |
| 36 | +### Core Components |
| 37 | + |
| 38 | +**DiffEngine Library (`src/DiffEngine/`):** |
| 39 | +- `DiffRunner` - Main entry point. Launches diff tools via `Launch`/`LaunchAsync` methods and kills them via `Kill`. Handles process lifecycle. |
| 40 | +- `DiffTools` - Registry of available diff tools. Maintains lookups by extension and path. Initialized from `Definitions` and ordered by `OrderReader`. |
| 41 | +- `Definitions` - Static collection of all supported diff tool definitions. Each tool is defined in `Implementation/` folder. |
| 42 | +- `Definition` - Record type describing a diff tool: executable paths, command arguments, supported extensions, OS support, MDI behavior, auto-refresh capability. |
| 43 | +- `DiffTool` - Enum of all supported diff tools (BeyondCompare, P4Merge, VS Code, etc.) |
| 44 | +- `ResolvedTool` - A diff tool that was found on the system with its resolved executable path. |
| 45 | +- `BuildServerDetector` - Detects CI/build server environments to disable diff tool launching. |
| 46 | + |
| 47 | +**DiffEngineTray (`src/DiffEngineTray/`):** |
| 48 | +- Windows Forms tray application that handles pending file diffs |
| 49 | +- `PiperServer` - TCP server (localhost) receiving move/delete payloads from DiffEngine library |
| 50 | +- `Tracker` - Manages pending file moves and deletes with concurrent dictionaries |
| 51 | +- Allows accepting/discarding diffs from system tray |
| 52 | + |
| 53 | +### Adding a New Diff Tool |
| 54 | + |
| 55 | +1. Add enum value to `DiffTool.cs` |
| 56 | +2. Create implementation in `src/DiffEngine/Implementation/` following existing patterns (see `BeyondCompare.cs`) |
| 57 | +3. Register in `Definitions.cs` collection |
| 58 | +4. The `Definition` record specifies: |
| 59 | + - Executable name and search paths per OS (`OsSupport`) |
| 60 | + - Argument builders for temp/target file positioning |
| 61 | + - Binary file extensions supported |
| 62 | + - Whether tool supports auto-refresh, is MDI, requires target file to exist |
| 63 | + |
| 64 | +### Key Patterns |
| 65 | + |
| 66 | +- Tool discovery uses wildcard path matching (`WildcardFileFinder`) to find executables in common install locations |
| 67 | +- Tool order can be customized via `DiffEngine_ToolOrder` environment variable |
| 68 | +- `DisabledChecker` respects `DiffEngine_Disabled` env var |
| 69 | +- Tests use xUnit with XunitContext and Verify for snapshot testing |
0 commit comments