Skip to content

Commit db3b399

Browse files
committed
Create claude.md
1 parent 3e9e07c commit db3b399

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

claude.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project
6+
7+
Verify.Xaml extends [Verify](https://github.com/VerifyTests/Verify) to snapshot-test WPF/XAML UI elements (`Window`, `Page`, `UserControl`, any `FrameworkElement`). For each verified element it produces two received/verified files: a `.xml` of the element tree (via `XamlWriter.Save`) and a `.png` rendered through `RenderTargetBitmap`.
8+
9+
## Commands
10+
11+
All commands run from the `src/` directory. Build/test target Windows only (WPF).
12+
13+
- Build: `dotnet build src --configuration Release`
14+
- Test (full): `dotnet test src --configuration Release --no-build --no-restore`
15+
- Test single: `dotnet test src/Tests/Tests.csproj --filter "FullyQualifiedName~TheTests.WindowUsage"`
16+
17+
The required .NET SDK is pinned in `src/global.json` (currently 10.0.202, prerelease allowed, `latestFeature` rollForward).
18+
19+
## Architecture
20+
21+
The library is intentionally tiny — three files do the work:
22+
23+
- `src/Verify.Xaml/VerifyXaml.cs` — single public entry point. `VerifyXaml.Initialize()` (called from a `[ModuleInitializer]`) registers two Verify `FileConverter`s: one for `Window`, one for `FrameworkElement`. Each converter returns a `ConversionResult` with two targets: `xml` + `png`.
24+
- `src/Verify.Xaml/WpfUtils.cs``ToXamlString` serializes the visual tree with `XamlWriter.Save` into an `XDocument`, then re-emits it via `XmlWriter` with `NewLineOnAttributes = true` for stable diffs. `Purge` strips attributes the screen-capture path mutates (`AllowsTransparency`, `ShowInTaskbar`, `WindowStyle`, `Opacity`, `Visibility`) so the captured XAML matches the original element. `ScreenCapture` shows the window invisibly (Opacity 0, transparent, no taskbar) to force layout, then renders to a PNG.
25+
- `src/Verify.Xaml/HostWindow.xaml(.cs)` — host used to render bare `FrameworkElement`s (non-Window content) for screen capture.
26+
27+
Because the converter mutates a real WPF window during rendering, tests must run on an STA thread — `src/Tests/TheTests.cs` is annotated `[Apartment(ApartmentState.STA)]`.
28+
29+
### Build/packaging notes
30+
31+
- `src/Verify.Xaml/Verify.Xaml.csproj` uses `MSBuild.Sdk.Extras` and multi-targets `net48;net6-Windows` with `UseWPF=true`.
32+
- `src/Directory.Build.props` sets `TreatWarningsAsErrors=true` and `EnforceCodeStyleInBuild=true` — code-style violations break the build. The package version (`<Version>`) is bumped here.
33+
- Central package versions live in `src/Directory.Packages.props` (`ManagePackageVersionsCentrally`); add new dependencies there, not in individual csprojs.
34+
- CI is AppVeyor (`src/appveyor.yml`); on test failure it uploads any `*.received.*` files as artifacts — a hint when triaging CI-only XAML/PNG diffs.
35+
36+
## Docs / readme
37+
38+
`readme.md` is generated by [MarkdownSnippets](https://github.com/SimonCropp/MarkdownSnippets) — snippet regions in source (`#region Window`, etc.) are inlined. Do not hand-edit the inlined snippet blocks; edit the source region or the `docs/*.include.md` partials and let the MSBuild task regenerate. `mdsnippets.json` configures it.

0 commit comments

Comments
 (0)