AngelSix.ThemeEngine.SourceGen 1.1.1

dotnet add package AngelSix.ThemeEngine.SourceGen --version 1.1.1
                    
NuGet\Install-Package AngelSix.ThemeEngine.SourceGen -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AngelSix.ThemeEngine.SourceGen" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AngelSix.ThemeEngine.SourceGen" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="AngelSix.ThemeEngine.SourceGen" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AngelSix.ThemeEngine.SourceGen --version 1.1.1
                    
#r "nuget: AngelSix.ThemeEngine.SourceGen, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AngelSix.ThemeEngine.SourceGen@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AngelSix.ThemeEngine.SourceGen&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=AngelSix.ThemeEngine.SourceGen&version=1.1.1
                    
Install as a Cake Tool

AngelSix.ThemeEngine.SourceGen

A Roslyn source generator that emits strongly-typed Avalonia markup extensions for every public property on classes marked with [Theme] (from the AngelSix.ThemeEngine runtime library).

Most users want AngelSix.ThemeEngine instead. That package bundles this analyzer along with the runtime types — one install gets you both. Install this standalone only if you ship your own runtime side.

What it does

For a theme like:

using AngelSix.ThemeEngine;
using Avalonia;
using Avalonia.Media;

[Theme]
public class DefaultTheme
{
    public Color ThemeColor1 => Color.Parse("#FFFFFFFF");
    public SolidColorBrush ThemeColor1Brush => new(ThemeColor1);
    public CornerRadius ControlCornerRadius => new(3);
    // ...
}

the generator emits, at compile time:

public sealed class ThemeColor1Extension : ThemeValueExtension { /* ... */ }
public sealed class ThemeColor1BrushExtension : ThemeValueExtension { /* ... */ }
public sealed class ControlCornerRadiusExtension : ThemeValueExtension { /* ... */ }

So your XAML can bind theme values directly:

xmlns:theme="using:AngelSix.ThemeEngine.Generated"
...
<Setter Property="Background" Value="{theme:ThemeColor1Brush}" />
<Setter Property="CornerRadius" Value="{theme:ControlCornerRadius}" />

Each extension returns an Avalonia.Data.Binding whose source is ThemeContext.Active, so swapping ThemeContext.Active = new DarkTheme() re-themes every bound value instantly.

Install

dotnet add package AngelSix.ThemeEngine.SourceGen

NuGet wires the generator automatically — no OutputItemType="Analyzer" attribute needed. You also need a reference to the AngelSix.ThemeEngine runtime library (which defines ThemeAttribute, ThemeContext, and the ThemeValueExtension base — emitted at build time by this generator).

Verification

The generator emits a marker type AngelSix.ThemeEngine.Generated.__ThemeEngineGenerated unconditionally on first run. The runtime ThemeContext constructor reflects for it and throws an actionable error if the analyzer didn't load, so wiring problems surface immediately rather than as obscure XAML errors.

Changelog

  • 1.1.0 — Switched to attribute-based discovery ([Theme]) instead of detecting subclasses of the previous Theme base class. The marker + ThemeValueExtension base are now emitted unconditionally so the runtime wiring check passes the moment the analyzer is loaded, even before any [Theme] class is added.

License

MIT

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 54 5/29/2026
1.1.0 87 5/17/2026
1.0.0 95 5/17/2026