Development
Run everything inside nix develop.
Build and test
dotnet build
dotnet test
The tests use xUnit v3 on Microsoft.Testing.Platform (set in global.json). They don’t need
MariaDB or a real dump: they write small WGRF files to a temporary directory.
The test folders mirror the source folders: the tests of Analyze/Paths/Algorithms/PathSearch.cs
are in Analyze/Paths/Algorithms/PathSearchTests.cs. Shared helpers live in Support/:
TestGraph writes WGRF files to a temporary directory, and SampleGraphs holds the small graphs
that several test files use.
WikipediaPath.GraphBuilder.Tests/Support/WgrfFile.cs is a small WGRF reader written from the spec only,
separate from WgrfReader. Writer tests use it, so a bug shared by the writer and the reader
still fails a test.
Formatting
Before you commit, check the formatting:
dotnet format --verify-no-changes
Run dotnet format to fix the files.
Warnings
Both projects set TreatWarningsAsErrors. The tool is published with native AOT
(PublishAot), so avoid code that needs runtime reflection. JSON goes through source-generated
contexts, like DumpStatusJsonContext.
NuGet dependencies and Nix
Nix builds offline, so it needs a lock of every NuGet package: deps.json. After you add or
update a package, regenerate it:
nix run .#update-deps
Native build
nix build # result/bin/WikipediaPath.GraphBuilder
Or without Nix:
dotnet publish WikipediaPath.GraphBuilder -c Release -r linux-x64 -o out
Running the build output outside the dev shell
A dotnet build output needs to find the .NET runtime. Outside the dev shell, set
DOTNET_ROOT:
export DOTNET_ROOT=$(dirname "$(readlink -f "$(which dotnet)")")
The AOT binary from nix build does not need it.
Profiling
The dev shell has dotnet-trace, dotnet-counters and perf:
dotnet tool run dotnet-counters monitor -n WikipediaPath.GraphBuilder
dotnet tool run dotnet-trace collect -- ./result/bin/WikipediaPath.GraphBuilder path "Tour Eiffel" "Pikachu"
build --verbose also prints rates, ETA and memory use every few seconds.
Changing the file format
docs/src/spec/wgrf.spec.md is the source of truth. Code that reads or writes WGRF follows it
exactly. If you change the format, change the spec in the same commit, and bump the version when
old files can no longer be read.
Documentation
This book lives in docs/. Preview it with:
mdbook serve docs --open
mdbook build docs writes the HTML to docs/book/, which is ignored by git.