CsWinRT 2.1.1
This is a stable release of C#/WinRT focused on bringing .NET AOT support and improved trimming support to both the runtime and generated projections. This version requires the following Windows SDK projection package from below or later which can be consumed by setting the below property in your C# project file or by updating to September's .NET SDK servicing build once available.
More details on the effect of these improvements and known issues can be found here: https://github.com/microsoft/CsWinRT/blob/2.1.1.240807.2/docs/aot-trimming.md
C#/WinRT package:
https://www.nuget.org/packages/Microsoft.Windows.CsWinRT/2.1.1
.NET Windows SDK targeting packages for .NET 6:
<WindowsSdkPackageVersion>10.0.xxxxx.38</WindowsSdkPackageVersion>
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.26100.38
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.22621.38
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.22000.38
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.20348.38
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.19041.38
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.18362.38
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.17763.38
.NET Windows SDK targeting packages for .NET 8:
<WindowsSdkPackageVersion>10.0.xxxxx.41</WindowsSdkPackageVersion>
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.26100.41
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.22621.41
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.22000.41
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.20348.41
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.19041.41
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.18362.41
https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref/10.0.17763.41
As part of these Windows SDK projection builds, there were several types in the Windows.UI
namespace that were moved from the WinUI projection to the Windows SDK projection to avoid long-term type conflict issues. Most of them have Microsoft.UI
versions of them which are used in WinUI scenarios. There are a couple used in WinUI scenarios such as TextDecorations
, BindableAttribute
, and ContentPropertyAttribute
. If you do use one of them and run into a type conflict issue between Microsoft.WinUI
and Microsoft.Windows.SDK.NET
, it can be resolved by moving to Microsoft.WindowsAppSDK 1.6
or by using the WindowsSdkPackageVersion
property to use an older version of the Windows SDK projection such as .34
if you can't move forward your Microsoft.WindowsAppSDK
version yet.
Thank you again to @dongle-the-gadget, @Gaoyifei1011, @hez2010, @jevansaks, @Jeremy-Price, @jlaanstra, @jkoritzinsky, @Sergio0694 for your community contributions to this significant release and for everyone who reported issues with the previews.
What's Changed
- Initial changes to make vtable generation trimming safe for AOT by @manodasanW in #1352
- Update staging with latest by @manodasanW in #1361
- Revert "Update staging with latest" by @manodasanW in #1362
- Update staging again with latest without squash by @manodasanW in #1363
- Update staging with latest by @manodasanW in #1374
- Remove the need for GuidGenerator/IIDOptimizer for all ABI interfaces. by @jlaanstra in #1360
- Merge master to staging by @manodasanW in #1378
- Use Marshal.AddRef/Release/QueryInterface. by @jlaanstra in #1379
- Run benchmarks against .NET 6 dll. by @jlaanstra in #1382
- Cache StringBuilder per thread and remove Lazy from GetRuntimeClassName. by @jlaanstra in #1381
- Addressing issues with generics on AOT by @manodasanW in #1377
- Skip interfaces not publicly accessible in authoring scenarios by @Sergio0694 in #1394
- Add MarshalString.FromAbiUnsafe API by @Sergio0694 in #1400
- Use hardcoded IIDs for all well known IReferenceArray types by @Sergio0694 in #1402
- Small tweaks to Marshaler's static cctor by @Sergio0694 in #1413
- Fix issue with properties implemented across multiple static interfaces by @manodasanW in #1415
- Move generic delegates vtable generation into projections by @manodasanW in #1411
- Minor trimming optimizations for authoring by @Sergio0694 in #1396
- Allow dropping native host for NativeAOT WinRT components by @Sergio0694 in #1395
- Fixing issues discovered during validation by @manodasanW in #1436
- Skip unnecessary lookup in EventRegistrationTokenTable by @Sergio0694 in #1440
- Optimize EventRegistrationTokenTable removal by @Sergio0694 in #1445
- Add support for feature switches, add option to disable dynamic objects support by @Sergio0694 in #1435
- Remove LINQ expression dependencies on NativeAOT by @Sergio0694 in #1429
- Rewrite event registration token logic to improve performance, trimming by @Sergio0694 in #1448
- Rewrite MarshalGeneric to minimize binary size on NativeAOT by @Sergio0694 in #1437
- Omit non public methods from preserved metadata by @Sergio0694 in #1442
- Fix IL2091 warnings in generated activation factories by @Sergio0694 in #1449
- Improve Marshaler trimming for blittable types by @Sergio0694 in #1455
- Drop [DynamicallyAccessedMembers] from Marshaler.AbiType by @Sergio0694 in #1461
- Remove unnecessary lambda expression stubs by @Sergio0694 in #1462
- Make marshalling 'System.Type' AOT-safe by @Sergio0694 in #1459
- Stop using ThreadLocal, use [ThreadStatic] by @Sergio0694 in #1460
- Move EventRegistrationTokenTable to WinRT.Runtime by @Sergio0694 in #1456
- Drop all delegates and closures in MarshalInterface on NAOT by @Sergio0694 in #1450
- Expose api's for Context on ObjectReference. by @jlaanstra in #1466
- Reduce enum stubs codegen with NativeAOT by @Sergio0694 in #1441
- Move ActivationFactory into WinRT.Runtime.dll by @jlaanstra in #1390
- Reduce binary size in agile reference context cache by @Sergio0694 in #1468
- Optimize ContextCallback on modern .NET by @Sergio0694 in #1464
- Seal IObjectReference.TryAs method by @Sergio0694 in #1454
- Move private delegate extensions to WinRT.Runtime by @Sergio0694 in #1457
- Make exported DllGetActivationFactory zero-alloc (take 2) by @Sergio0694 in #1401
- Remove generated VftblPtr type by @Sergio0694 in #1397
- Cherry-pick #1380 (remove resurrect logic) by @Sergio0694 in #1469
- Trim out more legacy projections fallback paths by @Sergio0694 in #1443
- Skip unnecessary method group delegate cache by @Sergio0694 in #1470
- Remove object field and allocation from ObjectReference by @Sergio0694 in #1458
- Stop preserving interfaces from MarshalInspectable by @Sergio0694 in #1452
- Remove Lazy uses on NativeAOT by @Sergio0694 in #1473
- Move all Platform APIs to WinRT.Runtime, remove leftover ones by @Sergio0694 in #1472
- Use typeof(DllModule).Assembly for faster resolution by @Sergio0694 in #1475
- Support nested types in AOT generator by @Sergio0694 in #1479
- Hard-code the numeric scalar types in CoerceValue and simplify enum marshalling to remove any usage of Convert.ChangeType. by @jkoritzinsky in #1487
- Remove/move internal vftbl types by @Sergio0694 in #1493
- Move DynamicInvokeAbi into WinRT.Runtime by @Sergio0694 in #1490
- Move IActivationFactoryMethods.ActivateInstance into WinRT.Runtime by @Sergio0694 in #1489
- Add 'EnableDefaultCustomTypeMappings' switch by @Sergio0694 in #1483
- Remove ComponentActivationFactory types by @Sergio0694 in #1491
- Remove almost all LINQ uses by @Sergio0694 in #1486
- Add net8.0 as target in help by @dongle-the-gadget in #1498
- Move InterfaceIIDs to WinRT.Runtime, rename it to IID by @Sergio0694 in #1494
- Fix TFM check in generated activation factories by @Sergio0694 in #1484
- Minor performance improvements to MarshalBlittable by @Sergio0694 in #1502
- Simplify and optimize exception helpers by @Sergio0694 in #1495
- Add [WinRTImplementationTypeRcwFactory] type by @Sergio0694 in #1505
- Suppress incorrect CA2257 warnings by @Sergio0694 in #1509
- Fix some warnings by @Sergio0694 in #1506
- Remove [ObjectReferenceWrapper] on .NET 6+ by @Sergio0694 in #1507
- Allow authoring scenarios to make use of abstract classes in their implementation by @manodasanW in #1512
- Remove managed vtable support on .NET 6+ by @Sergio0694 in #1504
- Fix, obsolete and hide AsType() on .NET 6 by @Sergio0694 in #1513
- Remove [Serializable] support from exceptions by @Sergio0694 in #1453
- Merge master to staging branch by @manodasanW in #1516
- Fix issue where RuntimeConfiguration defaults are not used by @manodasanW in #1530
- Obsolete Marshaler.RefAbiType on .NET 6+ by @Sergio0694 in #1520
- Enable IsAotCompatible for CsWinRT, fix all AOT warnings by @Sergio0694 in #1463
- Suppress useless IL2080 warnings in fallback paths by @Sergio0694 in #1515
- Add DataTransferManger interop APIs by @Gaoyifei1011 in #1528
- Fix bug in the AsStream extensions where the Length isn't properly updated on the IBuffer. by @jlaanstra in #1536
- Add ActivationHandler to match the C++/WinRT winrt_activation_handler. by @jlaanstra in #1532
- Add additional tests and benchmarks for async. by @jlaanstra in #1538
- Fix ShowShareUIForWindow method name. by @dongle-the-gadget in #1540
- Make AsyncInfoToTaskBridge lock free and more responsive to cancellation. by @jlaanstra in #1539
- Optimize AsTask when the underlying IAsyncOperation is wrapping a task. by @jlaanstra in #1537
- Move EventSource and associated types to WinRT.Runtime by @Sergio0694 in #1497
- Addressed a couple missed out on unmanaged function pointers by @manodasanW in #1549
- Stop rooting nested types for helper types by @Sergio0694 in #1521
- Use supported ILC patterns in projections by @Sergio0694 in #1471
- Fix remaining scenarios still calling FindVftblType by @manodasanW in #1545
- Merge master to staging branch by @manodasanW in #1552
- Adding diagnostics and code fix for adding partial keyword by @manodasanW in #1554
- Stop generating explicit interface implementations when not needed. by @jlaanstra in #1553
- Add overloads for CopyTo for Span. by @jlaanstra in #1541
- Use MethodInvoker in MarshalGenericFallback by @Sergio0694 in #1561
- Add RcwReflectionFallbackGenerator type by @Sergio0694 in #1555
- Fixing various crashes discovered with latest builds and removing vftbl by @manodasanW in #1560
- Strong name sign source generator by @manodasanW in #1558
- Add 'CsWinRTEnableICustomPropertyProviderSupport' feature switch by @Sergio0694 in #1565
- Fix more warnings in WinRT.Runtime by @Sergio0694 in #1557
- Add AsInterface support for generated COM interfaces. by @dongle-the-gadget in #1534
- Fix trim warnings in 'AdaptiveFromAbiHelper' by @Sergio0694 in #1566
- Fix an incorrect IL3050 warning suppression for ILC by @Sergio0694 in #1568
- Add WinRTRuntimeClassName attribute for use in scenarios where we previously used interface name by @manodasanW in #1573
- Add 3 missing trimming suppressions by @Sergio0694 in #1574
- Add 'CsWinRTEnableIReferenceSupport' feature switch by @Sergio0694 in #1575
- Disable runtime marshalling for the CsWinRT repo. by @jlaanstra in #1431
- Add missed test changes from previous PR by @manodasanW in #1579
- Don't cache 'RegisterTypeRuntimeClassNameLookup' by @Sergio0694 in #1586
- Fix CCW for boxing scenarios of generic types by @manodasanW in #1585
- Add 'CsWinRTEnableIDynamicInterfaceCastableSupport' feature switch by @Sergio0694 in #1583
- Add convenience methods directly on IAsyncAction/Operation to facilitate future optimizations and custom Awaiter/Task types. by @jlaanstra in #1580
- Remove more closures in lambda expressions by @Sergio0694 in #1588
- Fix IL2087 trim warning in 'ObjectReferenceWithContext' by @Sergio0694 in #1577
- Pass more explicit IIDs in more places by @Sergio0694 in #1594
- Set 'TreatWarningsAsErrors' almost everywhere by @Sergio0694 in #1592
- Seal and tweak 'IWinRTObject' members by @Sergio0694 in #1591
- Add 'CsWinRTRcwFactoryFallbackGeneratorForceOptOut' property by @Sergio0694 in #1567
- Pass IID for 'IBufferByteAccess.FromAbi' by @Sergio0694 in #1596
- Small optimization in 'GetAuthoringMetadataType' by @Sergio0694 in #1599
- Obsolete reflection-based 'ObjectReference' APIs by @Sergio0694 in #1595
- Remove 'Marshal.StructureToPtr' calls by @Sergio0694 in #1600
- Strip generated authoring metadata types by @Sergio0694 in #1598
- Reduce 'ObjectReference' generic instantiations in WinRT.Runtime by @Sergio0694 in #1597
- Remove leftover implicit operators on .NET target by @Sergio0694 in #1601
- Add WindowsRuntimeMarshal.TryGetDataUnsafe and use it in various places. by @jlaanstra in #1556
- Add missing check for 'IReference' support by @Sergio0694 in #1603
- Avoid closure in 'CreateReferenceCachingFactory' by @Sergio0694 in #1605
- Fixing couple reported issues by @manodasanW in #1604
- Optimize 'IGlobalInterfaceTable' on .NET by @Sergio0694 in #1607
- Add WindowsRuntimeMarshal.TryGetArray(IBuffer, out ArraySegment) by @jlaanstra in #1542
- Add missing check for nullable delegates by @Sergio0694 in #1608
- Merge master to staging/AOT by @manodasanW in #1614
- Fixing issues from GetObjectReferenceFromInterface change by @manodasanW in #1616
- Update baseline in staging/AOT by @manodasanW in #1618
- Fix edge cases with .NET Standard embedded support by @manodasanW in #1621
- Adding known issues for AOT staging branch by @manodasanW in #1627
- Don't cache 'RegisterTypeComInterfaceEntriesLookup' by @Sergio0694 in #1622
- Minor changes to IIDOptimizer and AOTOptimizer by @manodasanW in #1626
- Fix marshaling in AOT source generator by @manodasanW in #1628
- Unify all IIDs into 'IID' type by @Sergio0694 in #1620
- Add missing 'readonly' modifiers to static (P)IID fields by @Sergio0694 in #1612
- Trim 'ABI.System.EventHandler' when not needed by @Sergio0694 in #1619
- Fix .NET Standard authoring support by @manodasanW in #1632
- Fix 'CsWinRTIncludes' check in .targets file by @Sergio0694 in #1625
- WUX/MUX prototype by @jkoritzinsky in #1421
- Merge master into staging branch by @manodasanW in #1652
- Add 'CsWinRTMergeReferencedActivationFactories' option by @Sergio0694 in #1637
- Add WUX 'DispatcherQueueSynchronizationContext' type by @Sergio0694 in #1647
- Fixing various AOT bugs by @manodasanW in #1648
- Fix boxing of types by @manodasanW in #1646
- Fix invalid cast exception with stream APIs and make code fixer emit diagnostics as warnings by @manodasanW in #1654
- Fix IDIC casts to invalid WinRT interfaces by @manodasanW in #1659
- Fix incorrect AOT runtime feature check by @Sergio0694 in #1665
- Skip checking COM objects on AOT by @Sergio0694 in #1662
- Add missing 'readonly' modifiers by @Sergio0694 in #1664
- Improve codegen for merged activation factories by @Sergio0694 in #1660
- Simplify WUX feature switch property by @Sergio0694 in #1658
- Add -public_exclusiveto flag to enable implementing exclusiveto interfaces in consuming projects by @jevansaks in #1670
- Add 'TryGetDataUnsafe' overload for 'IMemoryBufferReference' by @Sergio0694 in #1673
- Fix IDIC casts throwing exceptions for is operator checks by @manodasanW in #1676
- Fix class name mapping for WUX types by @Sergio0694 in #1679
- Make ICustomPropertyProvider AOT safe by @manodasanW in #1677
- Fix property initializers and derived ObservableCollection by @manodasanW in #1686
- Fix merged component support in non-WinRT component projects by @Sergio0694 in #1680
- Fix nullable scenarios when xaml asks for type and fix vtable for event handlers by @manodasanW in #1684
- Remove redundant items in .targets by @Sergio0694 in #1687
- Fix source generator for exception types and fix is operator by @manodasanW in #1682
- Fix errors when consumers are using InternalsVisisbleTo by @manodasanW in #1688
- Fix GetGuidSignature for event args by @manodasanW in #1692
- Fix regression in IBindableIterator by @manodasanW in #1690
- Rename BindableCustomProperty attribute to include Generated prefix by @manodasanW in #1691
- Updating manifest which was forgotten when type was added by @manodasanW in #1694
- Fix scenario where generic implementation type doesn't have type factory intialized by @manodasanW in #1693
- Guard against potential null for RCW type by @manodasanW in #1695
- Fix source link with mirror repos by @manodasanW in #1699
- Make contracts internal when using embedded by @manodasanW in #1698
- Merge master to staging/AOT branch by @manodasanW in #1700
- Fix get type for nullable enums and fix WUX projections by @manodasanW in #1701
- Add .NET 8 version to nuget package by @manodasanW in #1704
- Allow projecting
Windows.UI.ColorHelper
type by @Sergio0694 in #1706 - Add some more missing 'readonly' modifiers by @Sergio0694 in #1707
- Add 'Windows.UI.Xaml.*' exception types by @Sergio0694 in #1705
- Merge AOT changes to master by @manodasanW in #1708
- Make generator compatible with older version of projections by @manodasanW in #1710
- Fix diagnostic rule to be warning and not error by @manodasanW in #1711
Full Changelog: 2.0.8.240703.1...2.1.1.240807.2