Compile-time view factories
Convention Mapping
Make view discovery a compiler result instead of a runtime search.
Explore source ↗Capability
The source generator maps ViewModel namespaces and suffixes to Avalonia views and emits direct Type-to-factory lookup tables without runtime reflection.
- 01
ViewModels-to-Views namespace replacement
- 02
ViewModel-to-View suffix convention
- 03
Direct control factories
- 04
Missing-view metadata without blocking fallback
How it composes
From intent
to working system.
Scan
Compilation symbols identify eligible view models and Avalonia views.
Transform
Namespace, suffix, generic, and interface rules derive candidate view names.
Resolve
Accessible matches become direct factories; misses become diagnostic metadata.
Emit
The partial locator receives static lookup tables and helpers.
Quick start
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.
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(); public bool Match(object? data) => data is ViewModelBase;}Modules in this capability
Use one layer.
Compose the rest.
Source of truth
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.