Executive Summary
At .NET Conf 2026, Mano and Sergio Pedri officially unveiled CsWinRT 3.0, a ground-up re-architecture of the C#/WinRT projection toolchain that bridges modern .NET applications with native Windows Runtime (WinRT) APIs.
Originally introduced during the .NET 5 era, CsWinRT evolved across multiple .NET versions, retrofitting trimming and Native AOT support while preserving strict backwards compatibility. Over time, this backward-compatibility commitment created major developer friction: version coupling and diamond dependency hell across NuGet packages, heavy Roslyn source generator overhead that froze Visual Studio during editing, and awkward code annotations ([DynamicWindowsRuntimeCast], mandatory partial classes, and array allocation workarounds).
CsWinRT 3.0 breaks through these architectural ceilings by introducing:
- Reference Projections Architecture: Libraries now ship reference-only assemblies alongside raw WinMD metadata. The consumer application's chosen CsWinRT toolchain dynamically generates unified
WinRT.Projection.dllandWinRT.Interop.dllassemblies at publish/build time, putting the app developer in 100% control of the projection version and eliminating package version mismatches. - Massive Binary Size Savings on Native AOT:
- Microsoft Store Client: Reduced executable footprint from 129 MB down to 107 MB (-22 MB, >16% reduction).
- Contoso Camera App: Down from 5.6 MB to 5.08 MB (~10% reduction).
- IDE Inner-Loop Acceleration: Removed expensive Roslyn source generators from the daily IntelliSense loop. Clean build generator execution dropped from 115 seconds to 9 seconds (13x faster); incremental builds dropped from 24 seconds to 4 seconds (6x faster).
- TFM Opt-in via the
.1Suffix: Non-breaking opt-in via Target Framework Monikers (e.g.,net11.0-windows10.0.26100.1vs.0). - Modern C# Array Projections via Spans: WinRT Pass Arrays project as
ReadOnlySpan<T>, Fill Arrays project asSpan<T>, enabling zero-allocation slicing, stackalloc, and eliminating temporary array allocations. - Native ABI Precision: WinRT
Point,Rect, andSizenow use nativefloatinstead of legacydouble, eliminating thousands of implicit conversions.
1. History & Motivation: Why Rebuild CsWinRT?

When CsWinRT shipped in .NET 5, neither trimming nor Native AOT existed in modern .NET. As trimming arrived in .NET 6 and Native AOT in .NET 7/8, the team retrofitted compatibility incrementally. However, to avoid breaking existing binary NuGet packages, they could not alter generated ABI structures, assembly forwarding mechanisms, or type mappings.

This accumulated significant technical debt:
- Applications were forced into specific CsWinRT runtime versions by third-party UI controls.
- Developers had to sprinkle internal attributes (
[DynamicWindowsRuntimeCast]) across everyday business logic. - Roslyn analyzers evaluated massive projection metadata inside Visual Studio, causing noticeable typing stutter and delayed IntelliSense.
CsWinRT 3.0 resets this baseline by leveraging .NET 11 and C# 14 features natively.
2. Production Performance: Microsoft Store Client Benchmarks

Sergio shared real-world telemetry from the production Microsoft Store Client app running on Native AOT:
| Metric | CsWinRT 2.x (.NET 10 AOT) | CsWinRT 3.0 (.NET 10/11 AOT) | Impact / Speedup |
|---|---|---|---|
| Microsoft Store Executable Size | 129 MB | 107 MB | -22 MB (-16.2% reduction) |
| Contoso Camera Executable Size | 5.6 MB | 5.08 MB | -0.52 MB (-9.3% reduction) |
| Store Clean Interop Gen CPU Time | 115 seconds | 9 seconds | 12.8x faster |
| Store Incremental Build Time | 24 seconds | 4 seconds | 6x faster |

Why Build Times Plummeted
In CsWinRT 2.x, a heavy Roslyn Source Generator scanned every syntax tree on every keystroke to determine marshalling requirements. In CsWinRT 3.0:
- The Roslyn source generator is completely removed from the IDE design-time loop.
- A standalone, native compiled interop generator runs exclusively when pressing F5 or publishing.
- Visual Studio remains responsive with instantaneous IntelliSense.
3. How WinRT & Projections Work

Windows Runtime (WinRT) APIs are described in language-agnostic .winmd (Windows Metadata) files. A language projection parses this metadata and produces types that feel native to that programming language:
// Consuming WinRT via .NET TFM
// csproj: <TargetFramework>net11.0-windows10.0.26100.1</TargetFramework>
using Windows.Devices.Geolocation;
var locator = new Geolocator();
var pos = await locator.GetGeopositionAsync();
Console.WriteLine($"Latitude: {pos.Coordinate.Point.Position.Latitude}");
Developers can also author WinRT components in C# for consumption by C++, Rust, or JavaScript using CsWinRTComponent=true:


Projections map WinRT types into native C# idioms:
Windows.Foundation.IAsyncOperation<T>maps directly toawait Task<T>.IVectorView<T>maps toIReadOnlyList<T>, allowing immediate use of LINQ (Where,FirstOrDefault).- WinRT property bags accept modern C# Collection Expressions (
[ "Title", "Author" ]).
4. Solving the Major Pain Points
Pain Point 1: Version Coupling & Diamond Dependency Hell

In CsWinRT 2.x, NuGet component packages (e.g., UI controls, charting libraries) compiled and packaged concrete projection assemblies. If Package A was compiled with CsWinRT 2.0.8 and Package B with 2.1.0, the consuming application suffered assembly mismatch compilation errors. Even if a bug was fixed in CsWinRT 2.2, developers could not benefit until all upstream package authors recompiled and republished their packages.
Pain Point 2: Trimming & AOT Boilerplate Friction

To satisfy trimming and AOT compilers in 2.x, developers were forced to write awkward, unnatural C#:
// CsWinRT 2.x: Unnatural boilerplate
public partial class TagButton : Button // Forced to be partial!
{
[DynamicWindowsRuntimeCast(typeof(FrameworkElement))] // Required internal attribute!
public void ProcessTags(object element)
{
if (element is FrameworkElement fe)
{
// Explicit array cast required to prevent compiler-generated hidden types
TagHelper.ApplyTags((string[])[ "Tag1", "Tag2" ]);
}
}
}
In CsWinRT 3.0, all of this boilerplate is eliminated:

// CsWinRT 3.0: Clean, idiomatic C#
public class TagButton : Button // No partial required
{
public void ProcessTags(object element)
{
if (element is FrameworkElement fe) // Clean pattern match
{
TagHelper.ApplyTags([ "Tag1", "Tag2" ]); // Pure collection expression
}
}
}
5. The Reference Projections Architecture

flowchart TD
subgraph NuGetPackages["NuGet Packages / Component Libraries"]
PkgA["Package A (ref/PackageA.dll + metadata/PackageA.winmd)"]
PkgB["Package B (ref/PackageB.dll + metadata/PackageB.winmd)"]
WinSDK["Windows SDK Targeting Pack (WinMDs)"]
end
subgraph AppBuild["Consumer Application Build Pipeline"]
App["App Project (Chooses CsWinRT 3.0)"]
Collector["WinMD Metadata Collector"]
ProjGen["Projection Generator"]
InteropGen["Native Compiled Interop Generator"]
end
subgraph EmittedAssemblies["Unified Emitted Assemblies"]
WinRTProj["WinRT.Projection.dll (Unified Types)"]
WinRTInterop["WinRT.Interop.dll (Analyzed App Interop)"]
end
PkgA --> Collector
PkgB --> Collector
WinSDK --> Collector
Collector --> ProjGen
App --> InteropGen
ProjGen --> WinRTProj
InteropGen --> WinRTInterop
How Reference Projections Work:
- Reference-Only Packages: Component packages only ship API signatures in
ref/assemblies and raw metadata in ametadata/folder. - App-Driven Compilation: When the application builds, it gathers all referenced
.winmdfiles. - Unified Assemblies: The app’s selected CsWinRT generator emits a single
WinRT.Projection.dll(containing all projected types) and a singleWinRT.Interop.dll(containing custom marshalling for classes implementing WinRT interfaces). - Zero Diamond Dependencies: Upstream package authors never lock consumers to a specific projection version.
6. The .1 TFM Opt-In & Multi-Targeting

To avoid breaking existing applications, Microsoft and the NuGet team introduced an explicit revision scheme in the Windows Target Framework Moniker (TFM):
| Target Framework Moniker | Projection Version | Compatibility Target |
|---|---|---|
net11.0-windows10.0.26100.0 |
CsWinRT 2.x | Legacy applications, existing controls |
net11.0-windows10.0.26100.1 |
CsWinRT 3.0 | Modern reference projections, zero boilerplate |
For component authors who need to support both 2.x and 3.0 consumers, CsWinRT 3.0 provides the #if CSWINRT3_0 preprocessor symbol:
#if CSWINRT3_0
// Uses .NET standard System.EventHandler<TTarget, TArgs>
public event System.EventHandler<Timer, TickEventArgs> Tick;
#else
// Legacy CsWinRT 2.x projection type
public event Windows.Foundation.TypedEventHandler<Timer, TickEventArgs> Tick;
#endif
7. High-Performance Array Marshalling with Span<T>

WinRT defines three array semantics:
- Pass Arrays (Input only): Callee only reads from the array.
- Fill Arrays (Output buffer): Caller passes an allocated buffer; callee populates it.
- Receive Arrays (Return array): Callee allocates and returns an array.
Historically, all three mapped to T[], causing severe allocation waste. CsWinRT 3.0 modernizes this mapping:
| WinRT Array Type | CsWinRT 2.x Mapping | CsWinRT 3.0 Mapping | Performance Advantage |
|---|---|---|---|
| Pass Array | T[] |
ReadOnlySpan<T> |
Supports stackalloc, span slicing, zero allocation |
| Fill Array | T[] |
Span<T> |
Direct slicing into existing memory buffers |
| Receive Array | T[] |
T[] |
Native array return retained |

// CsWinRT 2.x: Mandatory temporary allocation and copy
byte[] temp = new byte[16];
dataReader.ReadBytes(temp);
Array.Copy(temp, 0, destinationBuffer, offset, 16);
// CsWinRT 3.0: Zero-allocation direct span slice
dataReader.ReadBytes(destinationBuffer.AsSpan(offset, 16));
8. Live Migration Walkthrough (Contoso Camera App)

Mano walked through migrating the Contoso Camera sample app to CsWinRT 3.0:
- Update TFM: Changed
net10.0-windows10.0.26100.0tonet11.0-windows10.0.26100.1. - Package References: Updated
Microsoft.Windows.CsWinRTto3.0.0-previewand targeting pack to88-preview. - Remove Legacy Interop Usings:
using System.Runtime.InteropServices.WindowsRuntime;is no longer required because extension methods (AsTask,AsStream) now live inWindows.Foundation. - Strip AOT Attributes: Deleted hundreds of
[DynamicWindowsRuntimeCast]attributes across the codebase. - Float Coordinates: Updated Point/Rect coordinates to use native
floatvalues, matching native DirectX/WinUI math without hidden float-double conversions.
Key Takeaways
| Feature | CsWinRT 2.x | CsWinRT 3.0 |
|---|---|---|
| Projection Delivery | Concrete assemblies in packages | Reference projections + on-the-fly merge |
| Version Ownership | Dictated by third-party packages | 100% owned by app developer |
| Store App Size | 129 MB | 107 MB (-16%) |
| IntelliSense Build | 115s CPU time (Roslyn generator) | 9s CPU time (13x faster) |
| Array Marshalling | T[] only |
ReadOnlySpan<T> and Span<T> |
| Syntax Overhead | partial, custom cast attributes |
Pure standard C# syntax |
| Opt-in TFM | ...26100.0 |
...26100.1 |