Sundew.Xaml.Optimization 3.0.1

This package has a SemVer 2.0.0 package version: 3.0.1+54151a3927.
dotnet add package Sundew.Xaml.Optimization --version 3.0.1
                    
NuGet\Install-Package Sundew.Xaml.Optimization -Version 3.0.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="Sundew.Xaml.Optimization" Version="3.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sundew.Xaml.Optimization" Version="3.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Sundew.Xaml.Optimization" />
                    
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 Sundew.Xaml.Optimization --version 3.0.1
                    
#r "nuget: Sundew.Xaml.Optimization, 3.0.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 Sundew.Xaml.Optimization@3.0.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=Sundew.Xaml.Optimization&version=3.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Sundew.Xaml.Optimization&version=3.0.1
                    
Install as a Cake Tool

Sundew.Xaml.Optimization

The interface project for Sundew.Xaml.Optimizer.BuildTask - A framework for creating Xaml optimizers for WPF, Avalonia, Maui, WinUI, UWP and Xamarin.Forms.

Implementing an optimizer:

  1. Create a new .NET Standard 2.0 project.
  2. Reference Sundew.Xaml.Optimization e.g. via Nuget.
  3. Create the optimizer class and implement IXamlOptimizer. Currently WPF, Maui, Avalonia, WinUI, UWP and Xamarin.Forms are supported and each optimizer have to indicate which platforms they support.
  4. If the optimization requires code to work at runtime, this will have to be included in an additional dll or package dependency.
  5. Build and distribute dll(s), e.g. via NuGet

Usage sample:

Refer to the sample: https://github.com/sundews/Sundew.Xaml.Optimizer.Sample

Implementing IXamlOptimizer:

The IXamlOptimizer interface should be implemented to create a xaml optimizer.

Constructors:

Constructors in xaml optimizer can accept an optional settings object:

  • Additionally, a JObject (Json.NET) is accepted. This represents the settings for a particular optimizer in the "settings.sxos" file. Instead of JObject, a custom type, deserializing the settings is also permitted.

Optimize method:

The Optimize method is called gets called with the following information:

  • A list of all xaml files in the project as XDocument.
  • XamlPlatformInfo contains some basic information about the current xaml platform.
  • ProjectInfo, which contains information about the project, e.g. target framework, output type, assembly name etc..

The Optimize method should return an OptimizationResult containing the results of the optimization. When rewriting the xaml, it is recommended to not change the line ordering, because the optimized Xaml will be compiled and after compilation not be visible to the programmer (unless using a decompiler).

Xaml Namespaces:

When modifying Xaml it might be necessary to add xmlns declarations. This can be done via the XNamespaceInserter class, which ensures that prefixes are unique and that the same namespace is not added multiple times.

Returning additional files:

When returning a successful optimization, additional files may also be passed to the result, which allows for creating more advanced optimizations, e.g. with generated code.

Implementing a Xaml Analyzer:

An IXamlOptimizer can implement code analysis, in this case it does not modify the xaml, but returns a list of diagnostics in the OptimizationResult, which are then reported to MSBuild.

Packaging the optimizer:

Generally, an optimizer can be packaged in any way, e.g. as a NuGet package. When packaging the following rules are recommended:

  • Merge assemblies into a single dll to avoid assembly resolution issues. Example with ILRepack:
  • Do not merge Sundew.Xaml.Optimization.dll, System.*dlls as they are already loaded.
  • The analyzer should be packaged into the "build" folder
  • If the optimizer requires runtime code, this should be packaged into the "lib" folder or provided as a NuGet package dependency.

In Solution optimizers:

Adding an optimizer from within the solution is possible similar to how Roslyn analyzers work:
Refer to lines in the sample here

  • Assuming an optionally IL merged analyzer the dll path is determined.
  • Analyzer added to Sxo MSBuild Item
  • Anlyzer project is referenced with ReferenceOutputAssembly="False" to ensure build order, but not depending on the analyzer at runtime.

Sample optimizers:

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
3.0.1 52 10/17/2026
3.0.0 113 2/1/2026
3.0.0-u20251123-223615-ci 123 11/23/2025
3.0.0-u20251117-010621-ci 144 11/17/2025
3.0.0-u20251117-005126-ci 103 11/17/2025
3.0.0-u20251117-001116-ci 101 11/17/2025
3.0.0-u20251116-224913-ci 104 11/16/2025
3.0.0-u20251116-021731-ci 130 11/16/2025
3.0.0-u20251108-214911-ci 147 11/8/2025
3.0.0-u20251108-174754-ci 104 11/8/2025
3.0.0-u20251005-213009-ci 164 10/5/2025
3.0.0-u20250921-215125-ci 175 9/21/2025
3.0.0-u20250914-162907-ci 106 9/14/2025
3.0.0-u20250914-162821-ci 99 9/14/2025
3.0.0-u20250914-133414-ci 100 9/14/2025
3.0.0-u20250907-220120-ci 109 9/7/2025
3.0.0-u20250823-215006-ci 110 8/23/2025
3.0.0-u20250822-222054-ci 103 8/22/2025
3.0.0-u20250818-004537-ci 111 8/18/2025
3.0.0-u20250817-212711-ci 85 8/17/2025
Loading failed

3.0.0 - Platform update
2.0.0 - Extended XamlPlatformInfo, added XNamespaceInserter and IAssemblyReference.
1.0.0 - Initial version