MarkupDeclarative.Roslyn4 12.1.0

dotnet add package MarkupDeclarative.Roslyn4 --version 12.1.0
                    
NuGet\Install-Package MarkupDeclarative.Roslyn4 -Version 12.1.0
                    
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="MarkupDeclarative.Roslyn4" Version="12.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MarkupDeclarative.Roslyn4" Version="12.1.0" />
                    
Directory.Packages.props
<PackageReference Include="MarkupDeclarative.Roslyn4" />
                    
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 MarkupDeclarative.Roslyn4 --version 12.1.0
                    
#r "nuget: MarkupDeclarative.Roslyn4, 12.1.0"
                    
#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 MarkupDeclarative.Roslyn4@12.1.0
                    
#: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=MarkupDeclarative.Roslyn4&version=12.1.0
                    
Install as a Cake Addin
#tool nuget:?package=MarkupDeclarative.Roslyn4&version=12.1.0
                    
Install as a Cake Tool

MarkupDeclarative.Roslyn4

A Roslyn 4.x–compatible rebuild of the Avalonia.Markup.Declarative source generator.

Why

Avalonia.Markup.Declarative (12.1.0) ships a source generator built against Roslyn 5.3. A Roslyn analyzer/generator loads only when it targets a compiler ≤ the host's version, so on common hosts it is refused with warning CS9057 and generates nothing — the C# markup extension methods (.Margin(6), .Text(...), …) don't exist, breaking build and IntelliSense:

Host Roslyn Loads the 5.3 generator?
Visual Studio 2022 17.14 language service (IntelliSense) 4.14 ❌
.NET SDK 10.0.1xx build compiler 5.0 ❌

This package contains the same generator built against Roslyn 4.14.0, the lowest common denominator every current host can load, so both the build and IntelliSense work.

Usage

Reference it alongside Avalonia.Markup.Declarative (which still provides the runtime library — ViewBase, ViewFactory, …):

<PackageReference Include="Avalonia.Markup.Declarative" Version="12.1.0" />
<PackageReference Include="MarkupDeclarative.Roslyn4" Version="12.1.0" PrivateAssets="all" />

A build target in this package automatically removes the stock package's Roslyn-5.3 generator from the analyzer set, so only the 4.x one runs (no CS9057, no duplicate generation). No ExcludeAssets juggling required.

Update Visual Studio / the SDK to a build whose Roslyn ≥ 5.3 and you can drop this package again.

Attribution & license

Community rebuild of the MIT-licensed AvaloniaUI/Avalonia.Markup.Declarative. Not an official Avalonia package. Distributed under the MIT license; original copyright © Avalonia Team and contributors.

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
12.1.0 127 7/21/2026