Compile-time view factories

Convention Mapping

Make view discovery a compiler result instead of a runtime search.

Explore source
Parent systemStaticViewLocator
StatusMaintained
Modules1
RepositoryStaticViewLocator/StaticViewLocatorGenerator.cs

The source generator maps ViewModel namespaces and suffixes to Avalonia views and emits direct Type-to-factory lookup tables without runtime reflection.

  1. 01

    ViewModels-to-Views namespace replacement

  2. 02

    ViewModel-to-View suffix convention

  3. 03

    Direct control factories

  4. 04

    Missing-view metadata without blocking fallback

From intent
to working system.

01

Scan

Compilation symbols identify eligible view models and Avalonia views.

02

Transform

Namespace, suffix, generic, and interface rules derive candidate view names.

03

Resolve

Accessible matches become direct factories; misses become diagnostic metadata.

04

Emit

The partial locator receives static lookup tables and helpers.

Adopt this
capability.

Start with the primary module, then add the related packages only when the application needs those layers. Replace VERSION with the current NuGet version.

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();
public bool Match(object? data) => data is ViewModelBase;
}

Use one layer.
Compose the rest.

Read the module beside the complete system.

The implementation, samples, issues, and release notes stay in the parent repository so module details remain connected to the product architecture.

StaticViewLocator

Search everything.

Loading the index…

move open esc close

Preparing metadata and full-text search…