Scaffold AvParser: Avalonia 12 shell with adaptive layout

Greenfield skeleton for a parser desktop app. The domain is deliberately a
placeholder — IParser<TIn,TOut> plus two sample parsers — so the shell is
runnable and verifiable end to end before real logic lands.

Layers run one way: Core (no Avalonia, no IO) <- Infrastructure <- UI <- Desktop.
UI is a class library rather than the exe so headless tests build real views
without dragging in Program.cs, Serilog or the container.

Adaptive layout is built from what Avalonia actually offers, since it has no
AdaptiveTrigger or media queries: ResponsiveLayout observes Visual.Bounds and
projects a breakpoint onto both an attached property and :compact/:medium/
:expanded pseudoclasses, with 24px hysteresis so dragging a window edge cannot
make the layout flap. Pane state lives in the view model because a style setter
loses to a local value permanently; styles own only the visual variance.

Stack notes worth remembering: Avalonia.ReactiveUI is deprecated in favour of
ReactiveUI.Avalonia, and ReactiveUI 24 runs on the Primitives engine (RxVoid,
ISequencer, Signal<T>) and no longer self-initialises. Avalonia.Headless.XUnit
12.x requires xUnit v3. InvariantGlobalization must stay false or Semi.Avalonia
throws in its static constructor.

102 tests across three projects, including headless guards for the two failures
that are otherwise completely silent: a stylesheet whose selectors match nothing,
and a light palette too low-contrast for cards to read.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Leonid Pershin
2026-08-13 16:07:08 +03:00
co-authored by Claude Opus 5
commit 3db9d4dfc6
94 changed files with 5966 additions and 0 deletions
@@ -0,0 +1,57 @@
using AvParser.Core.Parsing;
using AvParser.Infrastructure.Storage;
using AvParser.UI.Navigation;
using Microsoft.Extensions.DependencyInjection;
using ReactiveUI;
using ReactiveUI.Primitives;
namespace AvParser.UI.ViewModels;
/// <summary>Landing page: what is registered, where data lives, and shortcuts into the app.</summary>
public sealed class DashboardViewModel : PageViewModel
{
private readonly IServiceProvider _services;
/// <summary>Creates the dashboard.</summary>
/// <param name="catalog">Registered parsers, shown as cards.</param>
/// <param name="paths">Where the app writes settings and logs.</param>
/// <param name="services">
/// Used to resolve <see cref="INavigationService"/> at click time rather than at construction
/// time. Injecting it directly would be a cycle: the navigation service is built from every
/// page, so a page cannot also depend on it up front.
/// </param>
public DashboardViewModel(IParserCatalog catalog, IAppPaths paths, IServiceProvider services)
{
ArgumentNullException.ThrowIfNull(catalog);
ArgumentNullException.ThrowIfNull(paths);
_services = services ?? throw new ArgumentNullException(nameof(services));
Parsers = catalog.Parsers;
DataDirectory = paths.DataDirectory;
GoToParseCommand = ReactiveCommand.Create(() => Navigate<ParseViewModel>());
GoToSettingsCommand = ReactiveCommand.Create(() => Navigate<SettingsViewModel>());
}
/// <inheritdoc />
public override string Title => "Dashboard";
/// <inheritdoc />
public override string IconKey => "IconHome";
/// <summary>Registered parsers, shown as cards.</summary>
public IReadOnlyList<ITextParser> Parsers { get; }
/// <summary>Where settings and logs are written.</summary>
public string DataDirectory { get; }
/// <summary>Jumps to the Parse page.</summary>
public ReactiveCommand<RxVoid, RxVoid> GoToParseCommand { get; }
/// <summary>Jumps to the Settings page.</summary>
public ReactiveCommand<RxVoid, RxVoid> GoToSettingsCommand { get; }
private void Navigate<TPage>()
where TPage : PageViewModel => _services.GetRequiredService<INavigationService>().NavigateTo<TPage>();
}