- DbBase.FindRequired / Client.FindByNameRequired now throw the domain-specific ObjectNotFoundException (NHibernate lineage; Rails equivalent: ActiveRecord::RecordNotFound) on a lookup miss; the no-context case stays InvalidOperationException (configuration error) - Console demo catches the new type; tests (18)/(21) assert it, (19)/(23) keep InvalidOperationException with rationale comments - scripts/run-console.sh delegates to dotnet.sh; run-console.ps1 is the Windows/PowerShell counterpart (mise-first, repo-root cd) Yak: objectnotfoundexception-run-console-wrappers-3p8b
3.0 KiB
AGENTS.md
Exercise repo: illustrating the transition from DB-backed domain classes
(DbBase inheritance) to plain domain objects + DTOs + mappers.
Diagrams: before-after-dto.mmd, after-dto.mmd (source sketch:
before-after-dto-sketch.png).
Rendering diagrams (mermaid → svg)
Mermaid diagrams can be rendered to SVG with the mmdc CLI (mermaid-cli,
installed via npm): mmdc -i <input> writes <input>.svg next to the
source, i.e. <name>.mmd becomes <name>.mmd.svg.
mmdc -i before-after-dto.mmd # -> before-after-dto.mmd.svg
mmdc -i after-dto.mmd # -> after-dto.mmd.svg
Running dotnet
dotnet SDK 10 is installed via mise (see mise.toml). It is NOT on PATH in
agent/sandbox shells, and SDK 10 additionally fails without
DOTNET_CLI_HOME in some shells. Always use the wrappers:
scripts/dotnet.sh build db-subclass-to-dto.sln
scripts/dotnet.sh test db-subclass-to-dto.sln
scripts/run-tests.sh # full test suite, from repo root
scripts/run-console.sh # run the Before.Console demo (bash; delegates
# to dotnet.sh); app args go after `--`
Windows/PowerShell counterpart:
scripts\run-console.ps1 # run the Before.Console demo; app args go
# directly (the script inserts `--` for
# dotnet run); needs no DOTNET_CLI_HOME setup
The wrappers cd to the repo root (the test runner must run from the parent
directory of the test project), export DOTNET_CLI_HOME, and invoke
mise exec -- dotnet .... Do not call bare dotnet.
If the first-time-use setup fails with The file ... '.dotnet-cli/.dotnet' already exists or Operation not permitted (some
agent/sandbox shells block $HOME/.dotnet-cli), point the wrapper at a
repo-local home: DOTNET_CLI_HOME="$PWD/.dotnet-cli" scripts/dotnet.sh ...
(add .dotnet-cli/ to .gitignore).
Yaks (task management with yx)
Tasks are managed with the yx CLI; yaks live in git (event store), snapshot
in .yaks/ (gitignored). Work one yak at a time:
yx list # all yaks and states
yx show "<yak name>" # full yak context (the task instructions)
yx start "<yak name>" # set state to wip
yx done "<yak name>" # set state to done (only after acceptance
# criteria pass and changes are committed)
- The yak context in
yx showis the authoritative task description; follow its acceptance criteria beforeyx done. - Children block their parent: do prerequisites (nested under a yak) first.
- Add new tasks:
yx add "<name>"(nest with--under "<parent>"). - If yx complains
.yaks is not gitignored, keep.yaksin.gitignore.
Conventions
- Target framework: net10.0 (SDK pinned by mise).
- Tests: xUnit, one
tests/BeforeAfter.Tests/project. - No EF Core / SQLite / AutoMapper — the DB layer is a small hand-rolled fake (pure managed code, cross-platform).
- Commit per yak with a message referencing the yak.