From 4d86540766b69db11f5d400d43b9888c910a4cd5 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 14 Dec 2025 12:12:32 -0800 Subject: [PATCH 1/8] Update ICommand TypeReference creation method Replaces the use of _corLibTypeFactory.CorLibScope with SystemObjectModel for creating the TypeReference for System.Windows.Input.ICommand. This change may improve consistency or correctness in type reference creation. --- src/WinRT.Interop.Generator/References/InteropReferences.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WinRT.Interop.Generator/References/InteropReferences.cs b/src/WinRT.Interop.Generator/References/InteropReferences.cs index 821893b33..348103964 100644 --- a/src/WinRT.Interop.Generator/References/InteropReferences.cs +++ b/src/WinRT.Interop.Generator/References/InteropReferences.cs @@ -251,7 +251,7 @@ public InteropReferences( /// /// Gets the for . /// - public TypeReference ICommand => field ??= _corLibTypeFactory.CorLibScope.CreateTypeReference("System.Windows.Input"u8, "ICommand"u8); + public TypeReference ICommand => field ??= SystemObjectModel.CreateTypeReference("System.Windows.Input"u8, "ICommand"u8); /// /// Gets the for . From aca6336e18b2597cc5635ea58613bf6c9bcef14a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 14 Dec 2025 12:12:47 -0800 Subject: [PATCH 2/8] Add IVectorChangedEventArgs to WellKnownInterfaceIIDs Added support for mapping the IVectorChangedEventArgs interface to its well-known IID string in WellKnownInterfaceIIDs. This improves interface recognition for Windows.Foundation.Collections.IVectorChangedEventArgs. --- .../References/WellKnownInterfaceIIDs.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs b/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs index a040c1244..a090a10e2 100644 --- a/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs +++ b/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs @@ -86,6 +86,8 @@ _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.I => "Windows_Foundation_IAsyncInfo", _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IAsyncAction) => "Windows_Foundation_IAsyncAction", + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IVectorChangedEventArgs) + => "Windows_Foundation_Collections_IVectorChangedEventArgs", // XAML types _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.INotifyCollectionChanged) && useWindowsUIXamlProjections From c48be70a5185f7738b3ff907f91650de1bea1db4 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 14 Dec 2025 12:25:45 -0800 Subject: [PATCH 3/8] Move IDisposable and IServiceProvider IID mappings Relocated the IID mappings for IDisposable and IServiceProvider to an earlier position in the switch statement within WellKnownInterfaceIIDs.cs. This change ensures these interfaces are matched before others, likely to address precedence or matching issues. --- .../References/WellKnownInterfaceIIDs.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs b/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs index a090a10e2..6e9ed6ebd 100644 --- a/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs +++ b/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs @@ -127,6 +127,10 @@ public static bool TryGetGUID( { guid = interfaceType switch { + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IDisposable) + => new Guid("1BFCA4F6-2C4E-5174-9869-B39D35848FCC"), + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IServiceProvider) + => new Guid("68B3A2DF-8173-539F-B524-C8A2348F5AFB"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.EventHandler) => new Guid("9DE1C535-6AE1-11E0-84E1-18A905BCC53F"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.EventHandler1) @@ -181,8 +185,6 @@ _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.A => new Guid("C261D8D0-71BA-5F38-A239-872342253A18"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IVectorChangedEventArgs) => new Guid("575933DF-34FE-4480-AF15-07691F3D5D9B"), - _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IDisposable) - => new Guid("1BFCA4F6-2C4E-5174-9869-B39D35848FCC"), _ => Guid.Empty }; From 386504ed10a7e44e50f198c63e53fbe7f101b0dc Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 14 Dec 2025 12:45:41 -0800 Subject: [PATCH 4/8] Add useWindowsUIXamlProjections to IID resolution Updated GuidGenerator and WellKnownInterfaceIIDs to support resolving interface IIDs based on the useWindowsUIXamlProjections flag. This enables correct GUID selection for interfaces that differ between Windows.UI.Xaml and Microsoft.UI.Xaml projections, improving compatibility and correctness in generated interop signatures. --- .../Helpers/GuidGenerator.cs | 13 ++++++-- .../Helpers/SignatureGenerator.Projections.cs | 30 +++++++++++++++---- .../References/WellKnownInterfaceIIDs.cs | 29 ++++++++++++++---- 3 files changed, 60 insertions(+), 12 deletions(-) diff --git a/src/WinRT.Interop.Generator/Helpers/GuidGenerator.cs b/src/WinRT.Interop.Generator/Helpers/GuidGenerator.cs index 32261265f..49493ab62 100644 --- a/src/WinRT.Interop.Generator/Helpers/GuidGenerator.cs +++ b/src/WinRT.Interop.Generator/Helpers/GuidGenerator.cs @@ -44,13 +44,22 @@ public static Guid CreateIID(TypeSignature type, InteropReferences interopRefere /// interfaces and, if necessary, the type's . /// /// The type descriptor to try to get the IID for. + /// Whether to use Windows.UI.Xaml projections. /// The instance to use. /// The resulting value, if found. /// Whether was succesfully retrieved. - public static bool TryGetIIDFromWellKnownInterfaceIIDsOrAttribute(ITypeDescriptor type, InteropReferences interopReferences, out Guid iid) + public static bool TryGetIIDFromWellKnownInterfaceIIDsOrAttribute( + ITypeDescriptor type, + bool useWindowsUIXamlProjections, + InteropReferences interopReferences, + out Guid iid) { // First try to get the IID from the custom-mapped types mapping - if (WellKnownInterfaceIIDs.TryGetGUID(type, interopReferences, out iid)) + if (WellKnownInterfaceIIDs.TryGetGUID( + interfaceType: type, + useWindowsUIXamlProjections: useWindowsUIXamlProjections, + interopReferences: interopReferences, + guid: out iid)) { return true; } diff --git a/src/WinRT.Interop.Generator/Helpers/SignatureGenerator.Projections.cs b/src/WinRT.Interop.Generator/Helpers/SignatureGenerator.Projections.cs index a314c959b..0ebce8c72 100644 --- a/src/WinRT.Interop.Generator/Helpers/SignatureGenerator.Projections.cs +++ b/src/WinRT.Interop.Generator/Helpers/SignatureGenerator.Projections.cs @@ -24,7 +24,11 @@ internal partial class SignatureGenerator private static string? GenericInstance(GenericInstanceTypeSignature typeSignature, InteropReferences interopReferences, bool useWindowsUIXamlProjections) { // If we fail to get the IID of the generic interface, we can't do anything else - if (!GuidGenerator.TryGetIIDFromWellKnownInterfaceIIDsOrAttribute(typeSignature.GenericType, interopReferences, out Guid interfaceIid)) + if (!GuidGenerator.TryGetIIDFromWellKnownInterfaceIIDsOrAttribute( + type: typeSignature.GenericType, + useWindowsUIXamlProjections: useWindowsUIXamlProjections, + interopReferences: interopReferences, + iid: out Guid interfaceIid)) { return null; } @@ -129,7 +133,11 @@ internal partial class SignatureGenerator private static string? Delegate(TypeDefinition typeDefinition, InteropReferences interopReferences, bool useWindowsUIXamlProjections) { // Just like for generic instantiations, we need to resolve the IID for the type first - if (!GuidGenerator.TryGetIIDFromWellKnownInterfaceIIDsOrAttribute(typeDefinition, interopReferences, out Guid iid)) + if (!GuidGenerator.TryGetIIDFromWellKnownInterfaceIIDsOrAttribute( + type: typeDefinition, + useWindowsUIXamlProjections: useWindowsUIXamlProjections, + interopReferences: interopReferences, + iid: out Guid iid)) { return null; } @@ -159,7 +167,11 @@ internal partial class SignatureGenerator } // Otherwise, get the IID from the type definition and use it - if (!GuidGenerator.TryGetIIDFromWellKnownInterfaceIIDsOrAttribute(typeDefinition, interopReferences, out Guid iid)) + if (!GuidGenerator.TryGetIIDFromWellKnownInterfaceIIDsOrAttribute( + type: typeDefinition, + useWindowsUIXamlProjections: useWindowsUIXamlProjections, + interopReferences: interopReferences, + iid: out Guid iid)) { return null; } @@ -176,7 +188,11 @@ internal partial class SignatureGenerator private static string? Interface(TypeDefinition typeDefinition, InteropReferences interopReferences, bool useWindowsUIXamlProjections) { // For all interface types, we should always be able to resolve their IID - if (!GuidGenerator.TryGetIIDFromWellKnownInterfaceIIDsOrAttribute(typeDefinition, interopReferences, out Guid iid)) + if (!GuidGenerator.TryGetIIDFromWellKnownInterfaceIIDsOrAttribute( + type: typeDefinition, + useWindowsUIXamlProjections: useWindowsUIXamlProjections, + interopReferences: interopReferences, + iid: out Guid iid)) { return null; } @@ -206,7 +222,11 @@ internal partial class SignatureGenerator } // Get the IID for 'Nullable', which is the one we use for 'IReference' - _ = WellKnownInterfaceIIDs.TryGetGUID(interopReferences.Nullable1, interopReferences, out Guid iid); + _ = WellKnownInterfaceIIDs.TryGetGUID( + interfaceType: interopReferences.Nullable1, + useWindowsUIXamlProjections: useWindowsUIXamlProjections, + interopReferences: interopReferences, + guid: out Guid iid); // Construct the signature for the boxed delegate (the base type will be the possibly constructed delegate) return $"pinterface({{{iid}}};{GetSignature(typeSignature.BaseType, interopReferences, useWindowsUIXamlProjections)})"; diff --git a/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs b/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs index 6e9ed6ebd..2a4ebbe32 100644 --- a/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs +++ b/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs @@ -67,7 +67,9 @@ internal static class WellKnownInterfaceIIDs /// The for the get_IID_... method for . /// /// - /// The types handled by this method should be kept in sync with . + /// The types handled by this method should be kept in sync with + /// and + /// . /// public static MemberReference get_IID( ITypeDescriptor interfaceType, @@ -80,8 +82,6 @@ public static MemberReference get_IID( // Shared types _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IDisposable) => "Windows_Foundation_IClosable", - _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IServiceProvider) - => "Microsoft_UI_Xaml_IXamlServiceProvider", _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IAsyncInfo) => "Windows_Foundation_IAsyncInfo", _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IAsyncAction) @@ -104,6 +104,8 @@ _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.I => "Microsoft_UI_Xaml_Input_ICommand", _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.INotifyDataErrorInfo) => "Microsoft_UI_Xaml_Data_INotifyDataErrorInfo", + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IServiceProvider) + => "Microsoft_UI_Xaml_IXamlServiceProvider", _ => throw WellKnownInteropExceptions.InvalidCustomMappedTypeForWellKnownInterfaceIIDs(interfaceType) }; @@ -117,20 +119,21 @@ _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.I /// Attempts to resolve a well-known Windows Runtime interface GUID for the specified type signature. /// /// The representing the managed type to inspect + /// Whether to use Windows.UI.Xaml projections. /// The instance to use. /// Out parameter for the resolved of the type. /// true if a matching GUID was found; otherwise, false. public static bool TryGetGUID( ITypeDescriptor interfaceType, + bool useWindowsUIXamlProjections, InteropReferences interopReferences, out Guid guid) { guid = interfaceType switch { + // Shared types _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IDisposable) => new Guid("1BFCA4F6-2C4E-5174-9869-B39D35848FCC"), - _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IServiceProvider) - => new Guid("68B3A2DF-8173-539F-B524-C8A2348F5AFB"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.EventHandler) => new Guid("9DE1C535-6AE1-11E0-84E1-18A905BCC53F"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.EventHandler1) @@ -185,6 +188,22 @@ _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.A => new Guid("C261D8D0-71BA-5F38-A239-872342253A18"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IVectorChangedEventArgs) => new Guid("575933DF-34FE-4480-AF15-07691F3D5D9B"), + + // XAML types + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.INotifyCollectionChanged) && useWindowsUIXamlProjections + => new Guid("28B167D5-1A31-465B-9B25-D5C3AE686C40"), + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.INotifyCollectionChanged) + => new Guid("530155E1-28A5-5693-87CE-30724D95A06D"), + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.INotifyPropertyChanged) && useWindowsUIXamlProjections + => new Guid("CF75D69C-F2F4-486B-B302-BB4C09BAEBFA"), + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.INotifyPropertyChanged) + => new Guid("90B17601-B065-586E-83D9-9ADC3A695284"), + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.ICommand) + => new Guid("E5AF3542-CA67-4081-995B-709DD13792DF"), + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.INotifyDataErrorInfo) + => new Guid("0EE6C2CC-273E-567D-BC0A-1DD87EE51EBA"), + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IServiceProvider) + => new Guid("68B3A2DF-8173-539F-B524-C8A2348F5AFB"), _ => Guid.Empty }; From 2c87941d34d5a7842060ba08f5b930b1301af2b7 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 13 Dec 2025 14:22:13 -0800 Subject: [PATCH 5/8] Add Guid attributes to WinRT interface definitions Added [Guid] attributes to several Windows.Foundation and Windows.Foundation.Collections interface definitions to specify their interface IDs. This change improves COM interop and aligns the interfaces with their corresponding WinRT specifications. --- .../Windows.Foundation/Collections/IMapChangedEventArgs{K}.cs | 2 ++ .../Windows.Foundation/Collections/IObservableMap{K, V}.cs | 2 ++ .../Windows.Foundation/Collections/IObservableVector{T}.cs | 2 ++ .../Windows.Foundation/Collections/IVectorChangedEventArgs.cs | 2 ++ src/WinRT.Runtime2/Windows.Foundation/IAsyncAction.cs | 2 ++ .../Windows.Foundation/IAsyncActionWithProgress{TProgress}.cs | 2 ++ src/WinRT.Runtime2/Windows.Foundation/IAsyncInfo.cs | 2 ++ .../IAsyncOperationWithProgress{TResult, TProgress}.cs | 2 ++ .../Windows.Foundation/IAsyncOperation{TResult}.cs | 2 ++ 9 files changed, 18 insertions(+) diff --git a/src/WinRT.Runtime2/Windows.Foundation/Collections/IMapChangedEventArgs{K}.cs b/src/WinRT.Runtime2/Windows.Foundation/Collections/IMapChangedEventArgs{K}.cs index 3fd530e26..10f8bad5d 100644 --- a/src/WinRT.Runtime2/Windows.Foundation/Collections/IMapChangedEventArgs{K}.cs +++ b/src/WinRT.Runtime2/Windows.Foundation/Collections/IMapChangedEventArgs{K}.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using System.Runtime.InteropServices; using Windows.Foundation.Metadata; using WindowsRuntime; @@ -11,6 +12,7 @@ namespace Windows.Foundation.Collections; /// /// The type of keys in the map. [WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")] +[Guid("9939F4DF-050A-4C0F-AA60-77075F9C4777")] [ContractVersion(typeof(FoundationContract), 65536u)] public interface IMapChangedEventArgs { diff --git a/src/WinRT.Runtime2/Windows.Foundation/Collections/IObservableMap{K, V}.cs b/src/WinRT.Runtime2/Windows.Foundation/Collections/IObservableMap{K, V}.cs index 0ccb2c01b..921e0fd22 100644 --- a/src/WinRT.Runtime2/Windows.Foundation/Collections/IObservableMap{K, V}.cs +++ b/src/WinRT.Runtime2/Windows.Foundation/Collections/IObservableMap{K, V}.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; +using System.Runtime.InteropServices; using Windows.Foundation.Metadata; using WindowsRuntime; @@ -14,6 +15,7 @@ namespace Windows.Foundation.Collections; /// The type of keys in the observable map. /// The type of values in the observable map. [WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")] +[Guid("65DF2BF5-BF39-41B5-AEBC-5A9D865E472B")] [ContractVersion(typeof(FoundationContract), 65536u)] public interface IObservableMap : IDictionary, ICollection>, IEnumerable>, IEnumerable { diff --git a/src/WinRT.Runtime2/Windows.Foundation/Collections/IObservableVector{T}.cs b/src/WinRT.Runtime2/Windows.Foundation/Collections/IObservableVector{T}.cs index f82edbcbc..31df8a627 100644 --- a/src/WinRT.Runtime2/Windows.Foundation/Collections/IObservableVector{T}.cs +++ b/src/WinRT.Runtime2/Windows.Foundation/Collections/IObservableVector{T}.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; +using System.Runtime.InteropServices; using Windows.Foundation.Metadata; using WindowsRuntime; @@ -13,6 +14,7 @@ namespace Windows.Foundation.Collections; /// /// The type of elements in the observable vector. [WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")] +[Guid("5917EB53-50B4-4A0D-B309-65862B3F1DBC")] [ContractVersion(typeof(FoundationContract), 65536u)] public interface IObservableVector : IList, ICollection, IEnumerable, IEnumerable { diff --git a/src/WinRT.Runtime2/Windows.Foundation/Collections/IVectorChangedEventArgs.cs b/src/WinRT.Runtime2/Windows.Foundation/Collections/IVectorChangedEventArgs.cs index 239e48693..9f07ae237 100644 --- a/src/WinRT.Runtime2/Windows.Foundation/Collections/IVectorChangedEventArgs.cs +++ b/src/WinRT.Runtime2/Windows.Foundation/Collections/IVectorChangedEventArgs.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using System.Runtime.InteropServices; using Windows.Foundation.Metadata; using WindowsRuntime; @@ -10,6 +11,7 @@ namespace Windows.Foundation.Collections; /// Provides data for the changed event of a vector. /// [WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")] +[Guid("575933DF-34FE-4480-AF15-07691F3D5D9B")] [ContractVersion(typeof(FoundationContract), 65536u)] public interface IVectorChangedEventArgs { diff --git a/src/WinRT.Runtime2/Windows.Foundation/IAsyncAction.cs b/src/WinRT.Runtime2/Windows.Foundation/IAsyncAction.cs index b77cba5c1..3fac041f9 100644 --- a/src/WinRT.Runtime2/Windows.Foundation/IAsyncAction.cs +++ b/src/WinRT.Runtime2/Windows.Foundation/IAsyncAction.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using System.Runtime.InteropServices; using Windows.Foundation.Metadata; using WindowsRuntime; @@ -17,6 +18,7 @@ namespace Windows.Foundation; /// /// [WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")] +[Guid("5A648006-843A-4DA9-865B-9D26E5DFAD7B")] [ContractVersion(typeof(FoundationContract), 65536u)] [ABI.Windows.Foundation.IAsyncActionComWrappersMarshaller] public interface IAsyncAction : IAsyncInfo diff --git a/src/WinRT.Runtime2/Windows.Foundation/IAsyncActionWithProgress{TProgress}.cs b/src/WinRT.Runtime2/Windows.Foundation/IAsyncActionWithProgress{TProgress}.cs index a5c066def..7c4c0a86d 100644 --- a/src/WinRT.Runtime2/Windows.Foundation/IAsyncActionWithProgress{TProgress}.cs +++ b/src/WinRT.Runtime2/Windows.Foundation/IAsyncActionWithProgress{TProgress}.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using System.Runtime.InteropServices; using Windows.Foundation.Metadata; using WindowsRuntime; @@ -18,6 +19,7 @@ namespace Windows.Foundation; /// /// [WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")] +[Guid("1F6DB258-E803-48A1-9546-EB7353398884")] [ContractVersion(typeof(FoundationContract), 65536u)] public interface IAsyncActionWithProgress : IAsyncInfo { diff --git a/src/WinRT.Runtime2/Windows.Foundation/IAsyncInfo.cs b/src/WinRT.Runtime2/Windows.Foundation/IAsyncInfo.cs index caea59409..5bb3b01a9 100644 --- a/src/WinRT.Runtime2/Windows.Foundation/IAsyncInfo.cs +++ b/src/WinRT.Runtime2/Windows.Foundation/IAsyncInfo.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System; +using System.Runtime.InteropServices; using Windows.Foundation.Metadata; using WindowsRuntime; @@ -11,6 +12,7 @@ namespace Windows.Foundation; /// Provides support for asynchronous operations. /// [WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")] +[Guid("00000036-0000-0000-C000-000000000046")] [ContractVersion(typeof(FoundationContract), 65536u)] public interface IAsyncInfo { diff --git a/src/WinRT.Runtime2/Windows.Foundation/IAsyncOperationWithProgress{TResult, TProgress}.cs b/src/WinRT.Runtime2/Windows.Foundation/IAsyncOperationWithProgress{TResult, TProgress}.cs index 25fe3cfb8..99c857573 100644 --- a/src/WinRT.Runtime2/Windows.Foundation/IAsyncOperationWithProgress{TResult, TProgress}.cs +++ b/src/WinRT.Runtime2/Windows.Foundation/IAsyncOperationWithProgress{TResult, TProgress}.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using System.Runtime.InteropServices; using Windows.Foundation.Metadata; using WindowsRuntime; @@ -20,6 +21,7 @@ namespace Windows.Foundation; /// /// [WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")] +[Guid("B5D036D7-E297-498F-BA60-0289E76E23DD")] [ContractVersion(typeof(FoundationContract), 65536u)] public interface IAsyncOperationWithProgress : IAsyncInfo { diff --git a/src/WinRT.Runtime2/Windows.Foundation/IAsyncOperation{TResult}.cs b/src/WinRT.Runtime2/Windows.Foundation/IAsyncOperation{TResult}.cs index 104f4e6e9..a6ec54b5f 100644 --- a/src/WinRT.Runtime2/Windows.Foundation/IAsyncOperation{TResult}.cs +++ b/src/WinRT.Runtime2/Windows.Foundation/IAsyncOperation{TResult}.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using System.Runtime.InteropServices; using Windows.Foundation.Metadata; using WindowsRuntime; @@ -18,6 +19,7 @@ namespace Windows.Foundation; /// /// [WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")] +[Guid("9FC2B0BB-E446-44E2-AA61-9CAB8F636AF2")] [ContractVersion(typeof(FoundationContract), 65536u)] public interface IAsyncOperation : IAsyncInfo { From ae1b866496d97461dfe82951ea0d7589bff05243 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 17 Dec 2025 17:40:48 -0800 Subject: [PATCH 6/8] Add IEnumerable, IEnumerator, and IList to type checks Extended the type comparison logic to include IEnumerable, IEnumerator, and IList interfaces in WindowsRuntimeExtensions. This ensures these interfaces are now considered in relevant type checks. --- .../Extensions/WindowsRuntimeExtensions.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/WinRT.Interop.Generator/Extensions/WindowsRuntimeExtensions.cs b/src/WinRT.Interop.Generator/Extensions/WindowsRuntimeExtensions.cs index b78b155bf..791bc3859 100644 --- a/src/WinRT.Interop.Generator/Extensions/WindowsRuntimeExtensions.cs +++ b/src/WinRT.Interop.Generator/Extensions/WindowsRuntimeExtensions.cs @@ -199,6 +199,9 @@ public bool IsCustomMappedWindowsRuntimeNonGenericInterfaceType(InteropReference SignatureComparer.IgnoreVersion.Equals(type, interopReferences.IDisposable) || SignatureComparer.IgnoreVersion.Equals(type, interopReferences.IServiceProvider) || SignatureComparer.IgnoreVersion.Equals(type, interopReferences.ICommand) || + SignatureComparer.IgnoreVersion.Equals(type, interopReferences.IEnumerable) || + SignatureComparer.IgnoreVersion.Equals(type, interopReferences.IEnumerator) || + SignatureComparer.IgnoreVersion.Equals(type, interopReferences.IList) || SignatureComparer.IgnoreVersion.Equals(type, interopReferences.INotifyCollectionChanged) || SignatureComparer.IgnoreVersion.Equals(type, interopReferences.INotifyDataErrorInfo) || SignatureComparer.IgnoreVersion.Equals(type, interopReferences.INotifyPropertyChanged); From 869d2ef75d398e5dcb0087e7d7328e936ef9c0a2 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 17 Dec 2025 17:56:56 -0800 Subject: [PATCH 7/8] Add type mappings for IEnumerator and IBindableIterator Added mappings from System.Collections.IEnumerator to Microsoft.UI.Xaml.Interop.IBindableIterator and from Microsoft.UI.Xaml.Interop.IBindableIterator to Windows.UI.Xaml.Interop.IBindableIterator. This improves type translation support for collection interfaces. --- src/WinRT.Interop.Generator/Helpers/TypeMapping.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/WinRT.Interop.Generator/Helpers/TypeMapping.cs b/src/WinRT.Interop.Generator/Helpers/TypeMapping.cs index c4a3ba39d..deec11afb 100644 --- a/src/WinRT.Interop.Generator/Helpers/TypeMapping.cs +++ b/src/WinRT.Interop.Generator/Helpers/TypeMapping.cs @@ -51,6 +51,7 @@ private readonly record struct MappedType( new("System.ComponentModel.PropertyChangedEventHandler", new("Microsoft.UI.Xaml.Data", "PropertyChangedEventHandler")), new("System.Windows.Input.ICommand", new("Microsoft.UI.Xaml.Input", "ICommand")), new("System.Collections.IEnumerable", new("Microsoft.UI.Xaml.Interop", "IBindableIterable")), + new("System.Collections.IEnumerator", new("Microsoft.UI.Xaml.Interop", "IBindableIterator")), new("System.Collections.IList", new("Microsoft.UI.Xaml.Interop", "IBindableVector")), new("System.Collections.Specialized.INotifyCollectionChanged", new("Microsoft.UI.Xaml.Interop", "INotifyCollectionChanged")), new("System.Collections.Specialized.NotifyCollectionChangedAction", new("Microsoft.UI.Xaml.Interop", "NotifyCollectionChangedAction", "enum(Microsoft.UI.Xaml.Interop.NotifyCollectionChangedAction;i4)")), @@ -94,6 +95,7 @@ private readonly record struct MappedType( new("Microsoft.UI.Xaml.Interop.NotifyCollectionChangedAction", new("Windows.UI.Xaml.Interop", "NotifyCollectionChangedAction", "enum(Windows.UI.Xaml.Interop.NotifyCollectionChangedAction;i4)")), new("Microsoft.UI.Xaml.Interop.INotifyCollectionChanged", new("Windows.UI.Xaml.Interop", "INotifyCollectionChanged")), new("Microsoft.UI.Xaml.Interop.IBindableIterable", new("Windows.UI.Xaml.Interop", "IBindableIterable")), + new("Microsoft.UI.Xaml.Interop.IBindableIterator", new("Windows.UI.Xaml.Interop", "IBindableIterator")), new("Microsoft.UI.Xaml.Interop.IBindableVector", new("Windows.UI.Xaml.Interop", "IBindableVector")), new("Microsoft.UI.Xaml.Interop.NotifyCollectionChangedEventHandler", new("Windows.UI.Xaml.Interop", "NotifyCollectionChangedEventHandler")), new("Microsoft.UI.Xaml.Input.ICommand", new("Windows.UI.Xaml.Input", "ICommand")), From c8f7d9b3d53801951f05c845b2747a45f08d3cfd Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 17 Dec 2025 17:57:02 -0800 Subject: [PATCH 8/8] Add XAML IBindable interface mappings and adjust GUIDs Added mappings for IBindableIterable, IBindableIterator, and IBindableVector interfaces for both Windows.UI.Xaml and Microsoft.UI.Xaml projections. Moved the corresponding GUID assignments for IEnumerable, IEnumerator, and IList to the XAML section to ensure correct interface resolution. --- .../References/WellKnownInterfaceIIDs.cs | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs b/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs index 2a4ebbe32..e95112ff3 100644 --- a/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs +++ b/src/WinRT.Interop.Generator/References/WellKnownInterfaceIIDs.cs @@ -90,6 +90,18 @@ _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.I => "Windows_Foundation_Collections_IVectorChangedEventArgs", // XAML types + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IEnumerable) && useWindowsUIXamlProjections + => "Windows_UI_Xaml_Interop_IBindableIterable", + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IEnumerable) + => "Microsoft_UI_Xaml_Interop_IBindableIterable", + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IEnumerator) && useWindowsUIXamlProjections + => "Windows_UI_Xaml_Interop_IBindableIterator", + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IEnumerator) + => "Microsoft_UI_Xaml_Interop_IBindableIterator", + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IList) && useWindowsUIXamlProjections + => "Windows_UI_Xaml_Interop_IBindableVector", + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IList) + => "Microsoft_UI_Xaml_Interop_IBindableVector", _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.INotifyCollectionChanged) && useWindowsUIXamlProjections => "Windows_UI_Xaml_Interop_INotifyCollectionChanged", _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.INotifyCollectionChanged) @@ -142,12 +154,8 @@ _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.E => new Guid("9DE1C535-6AE1-11E0-84E1-18A905BCC53F"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.KeyValuePair2) => new Guid("02B51929-C1C4-4A7E-8940-0312B5C18500"), - _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IEnumerable) - => new Guid("FAA585EA-6214-4217-AFDA-7F46DE5869B3"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IEnumerable1) => new Guid("FAA585EA-6214-4217-AFDA-7F46DE5869B3"), - _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IEnumerator) - => new Guid("6A79E863-4300-459A-9966-CBB660963EE1"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IEnumerator1) => new Guid("6A79E863-4300-459A-9966-CBB660963EE1"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.AsyncOperationWithProgressCompletedHandler2) @@ -156,8 +164,6 @@ _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.A => new Guid("9D534225-231F-55E7-A6D0-6C938E2D9160"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.MapChangedEventHandler2) => new Guid("19046F0B-CF81-5DEC-BBB2-7CC250DA8B8B"), - _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IList) - => new Guid("393DE7DE-6FD0-4C0D-BB71-47244A113E93"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IList1) => new Guid("0E3F106F-A266-50A1-8043-C90FCF3844F6"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IReadOnlyList1) @@ -190,6 +196,12 @@ _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.I => new Guid("575933DF-34FE-4480-AF15-07691F3D5D9B"), // XAML types + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IEnumerable) + => new Guid("FAA585EA-6214-4217-AFDA-7F46DE5869B3"), + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IEnumerator) + => new Guid("6A79E863-4300-459A-9966-CBB660963EE1"), + _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.IList) + => new Guid("393DE7DE-6FD0-4C0D-BB71-47244A113E93"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.INotifyCollectionChanged) && useWindowsUIXamlProjections => new Guid("28B167D5-1A31-465B-9B25-D5C3AE686C40"), _ when SignatureComparer.IgnoreVersion.Equals(interfaceType, interopReferences.INotifyCollectionChanged)