27. Read the source, contribute, and grow

Goal

Why this matters

Prerequisites

1. Repository tour

Avalonia repo highlights:

2. Building the framework locally

Scripts in repo root:

Manual build:

# Restore dependencies
dotnet restore Avalonia.sln

# Build core
cd src/Avalonia.Controls
dotnet build -c Debug

# Run tests
cd tests/Avalonia.Headless.UnitTests
dotnet test -c Release

# Run sample
cd samples/ControlCatalog
 dotnet run

Follow docs/build.md for environment requirements.

3. Testing strategy overview

Avalonia's quality gates rely on multiple test layers:

When contributing, prefer adding or updating the test nearest to the code you touch. For visual bugs, a headless interaction test plus a ControlCatalog sample usually gives maintainers confidence.

4. Reading source with purpose

Common entry points:

Use IDE features (Go to Definition, Find Usages) to jump between user code and framework internals.

5. Debugging into Avalonia

6. Filing issues

Best practice checklist:

7. Contributing pull requests

Steps:

  1. Check CONTRIBUTING.md for branching/style.
  2. Fork repo, create feature branch.
  3. Implement change (small, focused scope).
  4. Add/update tests under tests/ (headless tests for controls, unit tests for logic).
  5. Run dotnet build and dotnet test (or .\build.ps1 --target Test / nuke Test).
  6. Update docs/samples if behavior changed.
  7. Submit PR with clear description, referencing issue IDs/sites.
  8. Respond to feedback promptly.

Writing tests

Doc-only or sample-only PRs

8. Docs & sample contributions

9. Community & learning

10. Sustainable contribution workflow

Checklist before submitting work:

11. Practice exercises

  1. Clone the Avalonia repo and run .\build.ps1 --target Compile (or dotnet run --project build/NukeBuild Compile). Verify the build succeeds and inspect the generated artifacts.
  2. Launch ControlCatalog from the sample folder, then step into the code for one control you use frequently.
  3. Configure symbol/source mapping in your IDE and step into TextBlock rendering while running ControlCatalog.
  4. File a sample issue in a sandbox repo (practice minimal repro). Outline expected vs actual behavior clearly.
  5. Write a headless unit test for a simple control (e.g., verifying a custom control draws expected output) and run it locally.
  6. Draft a doc-only PR in avalonia-docs describing a workflow you improved (link back to the code sample or issue).

Look under the hood (source bookmarks)

Check yourself

What's next