Reflection-free Avalonia views
StaticViewLocator
Resolve view models to views at compile time and keep runtime discovery AOT-friendly.
Overview
A compile-time Avalonia view locator with convention mapping, generic, base-class, and interface fallbacks, and configurable MSBuild rules.
StaticViewLocator resolves Avalonia view-model-to-view conventions during compilation and emits direct factories plus deterministic fallback helpers. It removes reflection-heavy discovery while still supporting generic, inherited, interface-based, and modular application models.
Compile-time factory tables
Generic and inheritance fallback
Configurable naming conventions
Optional referenced-assembly scanning
Built for
Where it fits.
- Avalonia MVVM applications
- NativeAOT-conscious desktop teams
- Modular applications with inherited or interface view models
Compatibility & status
IDataTemplate
Reflection-free path
Opt-in scan
Supported
In the work
Real output,
not a mockup.

Architecture
Clear layers.
Replaceable seams.
Discovery
The generator scans eligible view models and accessible Avalonia view types.
Convention
Namespace, suffix, generic, and interface transforms derive candidate views.
Index
Resolved types become static factories; misses remain useful fallback metadata.
Lookup
Exact, generic, base, and interface helpers resolve runtime view-model types.
Inside StaticViewLocator
One repository.
Multiple serious systems.
Explore the focused capabilities, their package boundaries, architecture, installation, and smallest useful example.
The source generator maps ViewModel namespaces and suffixes to Avalonia views and emits direct Type-to-factory lookup tables without runtime reflection.
1 module→02 · Map real application hierarchiesFallback & ConfigurationExact types, generic definitions, base classes, and interfaces participate in a deterministic fallback order controlled by compiler-visible MSBuild properties.
1 module→Quick start
From package
to first frame.
Choose the package workflow used by your repository, then start from the smallest working example. Replace VERSION with the current stable or prerelease version shown on NuGet.
dotnet add package StaticViewLocator<PackageReference Include="StaticViewLocator" Version="VERSION" /><PackageVersion Include="StaticViewLocator" Version="VERSION" />[StaticViewLocator]public partial class ViewLocator : IDataTemplate{ public Control? Build(object? data) => data is null ? null : TryGetFactory(data.GetType())?.Invoke();}Package surface
Start focused.
Compose as needed.
Source, docs, samples, and releases
The repository is the source of truth.
Use the current documentation and samples, inspect changes, report issues, or support continued open-source maintenance.