MarkupDeclarative.Roslyn4
12.1.0
dotnet add package MarkupDeclarative.Roslyn4 --version 12.1.0
NuGet\Install-Package MarkupDeclarative.Roslyn4 -Version 12.1.0
<PackageReference Include="MarkupDeclarative.Roslyn4" Version="12.1.0" />
<PackageVersion Include="MarkupDeclarative.Roslyn4" Version="12.1.0" />
<PackageReference Include="MarkupDeclarative.Roslyn4" />
paket add MarkupDeclarative.Roslyn4 --version 12.1.0
#r "nuget: MarkupDeclarative.Roslyn4, 12.1.0"
#:package MarkupDeclarative.Roslyn4@12.1.0
#addin nuget:?package=MarkupDeclarative.Roslyn4&version=12.1.0
#tool nuget:?package=MarkupDeclarative.Roslyn4&version=12.1.0
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.
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 |