All projects

Reflection-free Avalonia views

StaticViewLocator

Resolve view models to views at compile time and keep runtime discovery AOT-friendly.

StatusMaintained
TierMaintained
DomainAvalonia
Repositorywieslawsoltes/StaticViewLocator

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.

01

Compile-time factory tables

02

Generic and inheritance fallback

03

Configurable naming conventions

04

Optional referenced-assembly scanning

Where it fits.

  • Avalonia MVVM applications
  • NativeAOT-conscious desktop teams
  • Modular applications with inherited or interface view models
Avalonia

IDataTemplate

NativeAOT

Reflection-free path

Referenced assemblies

Opt-in scan

Open generics

Supported

Real output,
not a mockup.

StaticViewLocator GitHub repository preview
The repository pairs the generator with runtime, snapshot, generic, inheritance, and interface-resolution tests.

Clear layers.
Replaceable seams.

01

Discovery

The generator scans eligible view models and accessible Avalonia view types.

02

Convention

Namespace, suffix, generic, and interface transforms derive candidate views.

03

Index

Resolved types become static factories; misses remain useful fallback metadata.

04

Lookup

Exact, generic, base, and interface helpers resolve runtime view-model types.

4 stepsexact to interface fallback
MSBuildcompiler-visible configuration
Staticdirect view factories
LiveGitHub metadata

One repository.
Multiple serious systems.

Explore the focused capabilities, their package boundaries, architecture, installation, and smallest useful example.

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.

01 · Install
Terminal
dotnet add package StaticViewLocator
02 · Use · csharp
QuickStart.cs
[StaticViewLocator]
public partial class ViewLocator : IDataTemplate
{
public Control? Build(object? data) =>
data is null ? null : TryGetFactory(data.GetType())?.Invoke();
}

Start focused.
Compose as needed.

The repository is the source of truth.

Use the current documentation and samples, inspect changes, report issues, or support continued open-source maintenance.

XamlToCSharpGenerator

Search everything.

Loading the index…

move open esc close

Preparing metadata and full-text search…