Skip to content

Add Avalonia UI visual tree plugin#5

Merged
asklar merged 4 commits intomainfrom
avalonia
Feb 26, 2026
Merged

Add Avalonia UI visual tree plugin#5
asklar merged 4 commits intomainfrom
avalonia

Conversation

@asklar
Copy link
Copy Markdown
Owner

@asklar asklar commented Feb 26, 2026

Summary

Add an lvt plugin that detects and dumps the visual tree of Avalonia UI desktop applications.

Components

  • Plugin DLL (lvt_avalonia_plugin.dll) - C ABI plugin detecting Avalonia.Base.dll in the target process, injecting the TAP DLL, reading tree JSON via named pipe
  • TAP DLL (lvt_avalonia_tap_x64.dll) - native DLL injected into the target process; hosts .NET CLR via hostfxr to call the managed tree walker; unloads itself via FreeLibraryAndExitThread after collection
  • Managed tree walker (LvtAvaloniaTreeWalker.dll) - walks Avalonia's Visual.VisualChildren via reflection, serializes type names, bounds, text content, visibility to JSON
  • Test app (tests/avalonia_test_app/) - simple Hello World Avalonia desktop app with TextBlock, Button, TextBox
  • Documentation - docs/avalonia-plugin.md with installation/usage; README and architecture docs updated

Bug fix

Updated plugin_loader.cpp graft code to prefer the text over name JSON field when setting element text, matching how the WPF provider's graft works.

Testing

  • All 44 unit tests pass (including 8 PluginGraft tests)
  • End-to-end tested: detects Avalonia 11.2.7, dumps a 37-element visual tree with correct element types, text content, and screen bounds

asklar and others added 4 commits February 26, 2026 09:55
Add an lvt plugin that detects and dumps the visual tree of Avalonia
desktop applications. The plugin follows the same injection pattern as
the WPF provider:

1. Plugin DLL (lvt_avalonia_plugin.dll) - detects Avalonia.Base.dll in
   the target process, injects the TAP DLL, reads tree JSON via named
   pipe.

2. TAP DLL (lvt_avalonia_tap_x64.dll) - native DLL injected into the
   target process. Hosts .NET CLR via hostfxr and calls the managed
   tree walker.

3. Managed tree walker (LvtAvaloniaTreeWalker.dll) - walks the Avalonia
   visual tree via Visual.VisualChildren (using reflection), serializes
   type names, bounds, text content, visibility, and element names to
   JSON.

Also includes:
- Simple Hello World Avalonia test app (tests/avalonia_test_app/)
- CMake build targets for the plugin and TAP DLL
- Fix plugin graft code to prefer 'text' over 'name' JSON field

Tested end-to-end: detects Avalonia 11.2.7, dumps 37-element tree with
TextBlock ('Hello World'), Button ('Click Me'), TextBox elements.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add docs/avalonia-plugin.md with installation, usage, and architecture
- Update README.md: mention Avalonia in framework list, add Optional
  plugins table under Plugin system section
- Update docs/architecture.md: add Avalonia to framework detection table

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The POST_BUILD copy command for the Avalonia TAP DLL expects the
managed LvtAvaloniaTreeWalker.dll to already exist. Add a dotnet build
step before cmake --build in both CI and release workflows. Also
include the plugins/ directory in CI artifacts and release packages.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace copy_if_different with 'dotnet publish -o <dir>' to place the
managed assembly directly in the build output. This avoids failures
when the bin/Release/ output path doesn't match expectations across
different .NET SDK versions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@asklar asklar merged commit 8a9c7bc into main Feb 26, 2026
1 check passed
@asklar asklar deleted the avalonia branch February 26, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant