|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Build Commands |
| 6 | + |
| 7 | +All commands run from the repo root. There is no .sln file; use the `src` directory directly. |
| 8 | + |
| 9 | +```bash |
| 10 | +dotnet build src --configuration Release |
| 11 | +dotnet test src --configuration Release --no-build --no-restore |
| 12 | +dotnet publish src/EmptyFiles.AotTests --configuration Release |
| 13 | +``` |
| 14 | + |
| 15 | +Run a single test: |
| 16 | +```bash |
| 17 | +dotnet test src/Tests --configuration Release --filter "FullyQualifiedName~Tests.TestClassName.MethodName" |
| 18 | +``` |
| 19 | + |
| 20 | +## Project Structure |
| 21 | + |
| 22 | +- **src/EmptyFiles/** — Main library (NuGet: `EmptyFiles`). Targets net462/net472/net48 + net6.0 through net11.0. |
| 23 | +- **src/EmptyFiles.Tool/** — CLI global tool (`emptyfile` command). Targets net10.0. |
| 24 | +- **src/Tests/** — NUnit tests with Verify snapshot testing. Targets net48 + net8.0 through net11.0. |
| 25 | +- **src/EmptyFiles.AotTests/** — AOT/trimming compatibility tests (net9.0, PublishAot). |
| 26 | +- **files/** — The actual empty template files organized by category: `archive/`, `document/`, `image/`, `sheet/`, `slide/`, `binary/`. |
| 27 | +- **buildTransitive/EmptyFiles.targets** — MSBuild targets included in the NuGet package; copies empty files to output directory on build. |
| 28 | + |
| 29 | +## Architecture |
| 30 | + |
| 31 | +Single namespace `EmptyFiles` with four public static API classes: |
| 32 | + |
| 33 | +- **AllFiles** — Main facade. Discovers and loads empty template files from the `files/` directory at static init. Provides file creation (`CreateFile`/`TryCreateFile`), lookup (`GetPathFor`/`TryGetPathFor`), validation (`IsEmptyFile`), and registration (`UseFile`). Files are stored in `FrozenDictionary<string, EmptyFile>` per `Category` enum (Archive, Document, Image, Sheet, Slide, Binary). |
| 34 | +- **FileExtensions** — Text file detection. Maintains a set of ~443 known text extensions and supports custom conventions via `AddTextFileConvention(Func<CharSpan, bool>)`. |
| 35 | +- **ContentTypes** — MIME type mapping between extensions and media types (200+ mappings). |
| 36 | +- **EmptyFile** — Data class holding `Path`, `LastWriteTime`, and `Category` for each template file. |
| 37 | + |
| 38 | +## Key Conventions |
| 39 | + |
| 40 | +- **C# LangVersion: preview** with `TreatWarningsAsErrors` and `EnforceCodeStyleInBuild` enabled. |
| 41 | +- **Global using alias:** `CharSpan` = `ReadOnlySpan<char>` (defined in `Directory.Build.props`). Many APIs have both `string` and `CharSpan` overloads. |
| 42 | +- **Immutable collections:** Uses `FrozenDictionary` and `FrozenSet` for thread-safe, post-initialization data. |
| 43 | +- **Try pattern:** Non-throwing variants (`TryCreateFile`, `TryGetPathFor`) alongside throwing versions. |
| 44 | +- **Central package management:** Versions in `src/Directory.Packages.props`, shared config in `src/Directory.Build.props`. |
| 45 | +- **CLS Compliant:** Assembly-level attribute enforced. |
| 46 | +- **Snapshot testing:** Tests use Verify for snapshot assertions — expect `.verified.` files alongside tests. |
| 47 | +- **.editorconfig:** Strict ReSharper rules enforced. |
0 commit comments