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 and generic MVVM-contract mapping, exact factories, generated ReactiveUI and IDataTemplate adapters, inheritance fallbacks, and configurable MSBuild rules.

StaticViewLocator resolves conventions and configured generic MVVM contracts during compilation, then emits exact factories plus optional ReactiveUI IViewLocator and Avalonia IDataTemplate adapters. It removes reflection-heavy discovery while retaining deterministic generic, inherited, interface-based, and modular application fallbacks.

01

Compile-time exact factory tables

02

Generic MVVM contract mappings

03

Generated ReactiveUI and Avalonia adapters

04

Configurable naming conventions

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.

3 adaptersexact, ReactiveUI, IDataTemplate
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…