Source-generated XAML stack
XamlToCSharpGenerator
Make XAML compilation, semantics, editing, preview, and automation one coherent source-generated system.
Overview
An Avalonia XAML compiler stack with typed bindings, runtime loading, hot reload and design, language services, editor controls, LSP, MCP, preview, and VS Code tooling.
XamlToCSharpGenerator is a complete source-generated XAML platform rather than a single emitter. Compiler, runtime, semantic tooling, preview, hot reload, hot design, LSP, MCP, editor, and VS Code layers share the same view of Avalonia markup and inline C#.
Source-generated Avalonia XAML
x:Bind and inline C# semantics
VS Code, LSP, editor, and preview
Hot reload, hot design, and MCP hosts
Built for
Where it fits.
- Avalonia application and framework authors
- IDE, editor, and language-tool developers
- Teams building agent-driven XAML workflows
Compatibility & status
SourceGen backend
Typed semantics
Integrated
Shipped
In the work
Real output,
not a mockup.

Architecture
Clear layers.
Replaceable seams.
Compiler
Framework-neutral parsing and semantics feed Avalonia binding and C# emission.
Runtime
URI registries, loaders, hot reload, and migration weaving connect generated views to applications.
Language tools
One semantic engine powers VS Code, LSP, preview, and an embeddable Avalonia editor.
Live protocol
Workspace, runtime, and preview MCP hosts expose structured authoring and design state.
Inside XamlToCSharpGenerator
One repository.
Multiple serious systems.
Explore the focused capabilities, their package boundaries, architecture, installation, and smallest useful example.
A Roslyn incremental pipeline parses, binds, validates, and emits Avalonia XAML as generated C#, with framework-neutral compiler layers and an Avalonia semantic adapter.
3 modules→02 · Semantic expressions inside markupTyped Bindings & Inline C#Compiled binding, x:Bind, C# expressions, interpolation, inline code blocks, event lambdas, bind-back, and dependency analysis share Roslyn-backed semantics.
2 modules→03 · One semantic engine, many editorsLanguage & Preview ToolingCompletion, diagnostics, definitions, references, hover, inlay hints, rename, semantic highlighting, inline C# intelligence, and Avalonia preview power a VS Code extension, LSP tool, and embeddable editor control.
3 modules→04 · Live tooling for humans and agentsHot Reload, Hot Design & MCPWorkspace, runtime, and preview MCP hosts expose semantic queries, preview lifecycle, source-generated hot reload, hot design, studio state, and remote protocol contracts.
3 modules→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 XamlToCSharpGenerator<PackageReference Include="XamlToCSharpGenerator" Version="VERSION" /><PackageVersion Include="XamlToCSharpGenerator" Version="VERSION" />AppBuilder.Configure<App>() .UsePlatformDetect() .UseAvaloniaSourceGeneratedXaml();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.