Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e4f029e
Support WinRT projection/authoring assemblies
Sergio0694 Feb 10, 2026
bc9aa05
Load and track WinRT projection/authoring modules
Sergio0694 Feb 10, 2026
fee70df
Add projection/authoring modules to InteropDefinitions
Sergio0694 Feb 10, 2026
31dd7e2
Skip WinRT attributes in reference projection
Sergio0694 Feb 10, 2026
4f7a3d4
Thread InteropDefinitions into signature/guid logic
Sergio0694 Feb 10, 2026
3c5103c
Refactor IID lookup; add TryGetType
Sergio0694 Feb 10, 2026
a8e69f3
Cache top-level types and use in SignatureGenerator
Sergio0694 Feb 10, 2026
6d75d58
Rename WinRT Authoring -> Component
Sergio0694 Feb 10, 2026
7b275c8
Fix typo
Sergio0694 Feb 10, 2026
e672849
Rename WinRTAuthoring to WinRTComponent
Sergio0694 Feb 10, 2026
a24e5c0
Make WindowsRuntimeComponentModule nullable
Sergio0694 Feb 10, 2026
eb7f8ef
Fix typos
Sergio0694 Feb 10, 2026
0efecf6
Clarify GUIDAttribute IID doc comment
Sergio0694 Feb 10, 2026
3522c17
Rename interop name constants and update usages
Sergio0694 Feb 10, 2026
8443d71
Reject reserved WinRT.* DLL references
Sergio0694 Feb 10, 2026
d959fd7
Create merged projection before interop dll and pass merged projectio…
manodasanW Feb 13, 2026
e9ebe56
Validate reserved DLL paths and repro generation
Sergio0694 Feb 13, 2026
1251ebc
Defer assembly copy until after validation
Sergio0694 Feb 13, 2026
a81970f
Make IID retrieval helper methods private
Sergio0694 Feb 13, 2026
4de36c2
Emit GUID attribute for delegates (conditional)
Sergio0694 Feb 17, 2026
0443081
Merge branch 'staging/3.0' into user/sergiopedri/cswinrtgen-authoring…
manodasanW Feb 17, 2026
4367242
Negate IID lookup condition
Sergio0694 Feb 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions nuget/Microsoft.Windows.CsWinRT.CsWinRTGen.targets
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<UsingTask Condition="'$(CsWinRTGeneratorTasksOverriden2)' != 'true'" TaskName="RunCsWinRTInteropGenerator" AssemblyFile="$(CsWinRTGenTasksAssembly)" />
<Target
Name="_RunCsWinRTInteropGenerator"
DependsOnTargets="CoreCompile;$(GetTargetPathDependsOn);$(GetTargetPathWithTargetPlatformMonikerDependsOn);_ComputeRunCsWinRTGeneratorCache"
DependsOnTargets="CoreCompile;$(GetTargetPathDependsOn);$(GetTargetPathWithTargetPlatformMonikerDependsOn);_ComputeRunCsWinRTGeneratorCache;_RunCsWinRTMergedProjectionGenerator"
BeforeTargets="GetTargetPath;GetTargetPathWithTargetPlatformMoniker;GenerateBuildDependencyFile;GeneratePublishDependencyFile;GetCopyToOutputDirectoryItems;GetCopyToPublishDirectoryItems"
Inputs="@(ReferencePathWithRefAssemblies);@(IntermediateAssembly);$(_RunCsWinRTGeneratorPropertyInputsCachePath)"
Inputs="@(ReferencePathWithRefAssemblies);@(IntermediateAssembly);$(_RunCsWinRTGeneratorPropertyInputsCachePath);$(_CsWinRTGeneratorMergedProjectionAssemblyPath)"
Outputs="$(_CsWinRTGeneratorInteropAssemblyPath)"
Condition="'$(CsWinRTGenerateInteropAssembly2)' == 'true'">

Expand All @@ -168,6 +168,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
ReferenceAssemblyPaths="@(_ReferenceAssemblyPaths)"
ImplementationAssemblyPaths="@(ReferencePath)"
OutputAssemblyPath="@(IntermediateAssembly)"
WinRTProjectionAssemblyPath="$(_CsWinRTGeneratorMergedProjectionAssemblyPath)"
InteropAssemblyDirectory="$(CsWinRTGeneratorInteropAssemblyDirectory)"
DebugReproDirectory="$(CsWinRTGeneratorDebugReproDirectory)"
CsWinRTToolsDirectory="$(CsWinRTInteropGenEffectiveToolsDirectory)"
Expand Down
20 changes: 20 additions & 0 deletions src/WinRT.Generator.Tasks/RunCsWinRTInteropGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ public sealed class RunCsWinRTInteropGenerator : ToolTask
[Required]
public ITaskItem[]? OutputAssemblyPath { get; set; }

/// <summary>
/// Gets or sets the path to the WinRT merged projection assembly.
/// </summary>
[Required]
public ITaskItem? WinRTProjectionAssemblyPath { get; set; }

/// <summary>
/// Gets or sets the path to the WinRT merged component assembly generated for authoring scenarios.
/// </summary>
public ITaskItem? WinRTComponentAssemblyPath { get; set; }

/// <summary>
/// Gets or sets the directory where the generated interop assembly will be placed.
/// </summary>
Expand Down Expand Up @@ -149,6 +160,13 @@ protected override bool ValidateParameters()
return false;
}

if (WinRTProjectionAssemblyPath is null)
{
Log.LogWarning("Invalid 'WinRTProjectionAssemblyPath' input.");

return false;
}

if (InteropAssemblyDirectory is null || !Directory.Exists(InteropAssemblyDirectory))
{
Log.LogWarning("Generated assembly directory '{0}' is invalid or does not exist.", InteropAssemblyDirectory);
Expand Down Expand Up @@ -236,6 +254,8 @@ protected override string GenerateResponseFileCommands()
AppendResponseFileCommand(args, "--reference-assembly-paths", referenceAssemblyPathsArg);
AppendResponseFileCommand(args, "--implementation-assembly-paths", implementationAssemblyPathsArg);
AppendResponseFileCommand(args, "--output-assembly-path", EffectiveOutputAssemblyItemSpec);
AppendResponseFileCommand(args, "--winrt-projection-assembly-path", WinRTProjectionAssemblyPath!.ItemSpec);
AppendResponseFileOptionalCommand(args, "--winrt-component-assembly-path", WinRTComponentAssemblyPath?.ItemSpec);
AppendResponseFileCommand(args, "--generated-assembly-directory", InteropAssemblyDirectory!);
AppendResponseFileOptionalCommand(args, "--debug-repro-directory", DebugReproDirectory);
AppendResponseFileCommand(args, "--use-windows-ui-xaml-projections", UseWindowsUIXamlProjections.ToString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ public static class ICommand
/// <summary>
/// Creates a new type definition for the interface implementation of the <see cref="System.Windows.Input.ICommand"/> interface.
/// </summary>
/// <param name="interopDefinitions">The <see cref="InteropDefinitions"/> instance to use.</param>
/// <param name="interopReferences">The <see cref="InteropReferences"/> instance to use.</param>
/// <param name="module">The module that will contain the type being created.</param>
/// <param name="useWindowsUIXamlProjections">Whether to use <c>Windows.UI.Xaml</c> projections.</param>
/// <param name="interfaceImplType">The resulting interface implementation type.</param>
public static void InterfaceImpl(
InteropDefinitions interopDefinitions,
InteropReferences interopReferences,
ModuleDefinition module,
bool useWindowsUIXamlProjections,
Expand All @@ -42,7 +44,7 @@ public static void InterfaceImpl(
CustomAttributes =
{
new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor),
InteropCustomAttributeFactory.Guid(interfaceType, interopReferences, useWindowsUIXamlProjections)
InteropCustomAttributeFactory.Guid(interfaceType, interopDefinitions, interopReferences, useWindowsUIXamlProjections)
},
Interfaces = { new InterfaceImplementation(interfaceType.ToTypeDefOrRef()) }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ public static class INotifyCollectionChanged
/// <summary>
/// Creates a new type definition for the interface implementation of the <see cref="System.Collections.Specialized.INotifyCollectionChanged"/> interface.
/// </summary>
/// <param name="interopDefinitions">The <see cref="InteropDefinitions"/> instance to use.</param>
/// <param name="interopReferences">The <see cref="InteropReferences"/> instance to use.</param>
/// <param name="module">The module that will contain the type being created.</param>
/// <param name="useWindowsUIXamlProjections">Whether to use <c>Windows.UI.Xaml</c> projections.</param>
/// <param name="interfaceImplType">The resulting interface implementation type.</param>
public static void InterfaceImpl(
InteropDefinitions interopDefinitions,
InteropReferences interopReferences,
ModuleDefinition module,
bool useWindowsUIXamlProjections,
Expand All @@ -42,7 +44,7 @@ public static void InterfaceImpl(
CustomAttributes =
{
new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor),
InteropCustomAttributeFactory.Guid(interfaceType, interopReferences, useWindowsUIXamlProjections)
InteropCustomAttributeFactory.Guid(interfaceType, interopDefinitions, interopReferences, useWindowsUIXamlProjections)
},
Interfaces = { new InterfaceImplementation(interfaceType.ToTypeDefOrRef()) }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ public static class INotifyPropertyChanged
/// <summary>
/// Creates a new type definition for the interface implementation of the <see cref="System.ComponentModel.INotifyPropertyChanged"/> interface.
/// </summary>
/// <param name="interopDefinitions">The <see cref="InteropDefinitions"/> instance to use.</param>
/// <param name="interopReferences">The <see cref="InteropReferences"/> instance to use.</param>
/// <param name="module">The module that will contain the type being created.</param>
/// <param name="useWindowsUIXamlProjections">Whether to use <c>Windows.UI.Xaml</c> projections.</param>
/// <param name="interfaceImplType">The resulting interface implementation type.</param>
public static void InterfaceImpl(
InteropDefinitions interopDefinitions,
InteropReferences interopReferences,
ModuleDefinition module,
bool useWindowsUIXamlProjections,
Expand All @@ -42,7 +44,7 @@ public static void InterfaceImpl(
CustomAttributes =
{
new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor),
InteropCustomAttributeFactory.Guid(interfaceType, interopReferences, useWindowsUIXamlProjections)
InteropCustomAttributeFactory.Guid(interfaceType, interopDefinitions, interopReferences, useWindowsUIXamlProjections)
},
Interfaces = { new InterfaceImplementation(interfaceType.ToTypeDefOrRef()) }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ internal static partial class DynamicCustomMappedTypeMapEntriesBuilder
/// Defines all assembly attributes for dynamic custom-mapped type map entries.
/// </summary>
/// <param name="args">The arguments for this invocation.</param>
/// <param name="interopDefinitions">The <see cref="InteropDefinitions"/> instance to use.</param>
/// <param name="interopReferences">The <see cref="InteropReferences"/> instance to use.</param>
/// <param name="module">The interop module being built.</param>
public static void AssemblyAttributes(
InteropGeneratorArgs args,
InteropDefinitions interopDefinitions,
InteropReferences interopReferences,
ModuleDefinition module)
{
Expand Down Expand Up @@ -60,16 +62,19 @@ public static void AssemblyAttributes(
useComWrappersMarshallerAttribute: true);

ICommandInterfaceType(
interopDefinitions: interopDefinitions,
interopReferences: interopReferences,
module: module,
useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections);

INotifyCollectionChangedInterfaceType(
interopDefinitions: interopDefinitions,
interopReferences: interopReferences,
module: module,
useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections);

INotifyPropertyChangedInterfaceType(
interopDefinitions: interopDefinitions,
interopReferences: interopReferences,
module: module,
useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections);
Expand Down Expand Up @@ -185,10 +190,12 @@ private static void InterfaceType(
/// <summary>
/// Creates a new custom attribute value for <see cref="TypeMapAttribute{TTypeMapGroup}"/> for the <see cref="System.Windows.Input.ICommand"/> interface type.
/// </summary>
/// <param name="interopDefinitions">The <see cref="InteropDefinitions"/> instance to use.</param>
/// <param name="interopReferences">The <see cref="InteropReferences"/> instance to use.</param>
/// <param name="module">The module that the attribute will be used from.</param>
/// <param name="useWindowsUIXamlProjections">Whether to use <c>Windows.UI.Xaml</c> projections.</param>
private static void ICommandInterfaceType(
InteropDefinitions interopDefinitions,
InteropReferences interopReferences,
ModuleDefinition module,
bool useWindowsUIXamlProjections)
Expand All @@ -215,6 +222,7 @@ private static void ICommandInterfaceType(

// Define the 'InterfaceImpl' type for the 'ICommand' interface type
ICommand.InterfaceImpl(
interopDefinitions: interopDefinitions,
interopReferences: interopReferences,
module: module,
useWindowsUIXamlProjections: useWindowsUIXamlProjections,
Expand All @@ -239,10 +247,12 @@ private static void ICommandInterfaceType(
/// <summary>
/// Creates a new custom attribute value for <see cref="TypeMapAttribute{TTypeMapGroup}"/> for the <see cref="System.Collections.Specialized.INotifyCollectionChanged"/> interface type.
/// </summary>
/// <param name="interopDefinitions">The <see cref="InteropDefinitions"/> instance to use.</param>
/// <param name="interopReferences">The <see cref="InteropReferences"/> instance to use.</param>
/// <param name="module">The module that the attribute will be used from.</param>
/// <param name="useWindowsUIXamlProjections">Whether to use <c>Windows.UI.Xaml</c> projections.</param>
private static void INotifyCollectionChangedInterfaceType(
InteropDefinitions interopDefinitions,
InteropReferences interopReferences,
ModuleDefinition module,
bool useWindowsUIXamlProjections)
Expand All @@ -269,6 +279,7 @@ private static void INotifyCollectionChangedInterfaceType(

// Define the 'InterfaceImpl' type for the 'INotifyCollectionChanged' interface type
INotifyCollectionChanged.InterfaceImpl(
interopDefinitions: interopDefinitions,
interopReferences: interopReferences,
module: module,
useWindowsUIXamlProjections: useWindowsUIXamlProjections,
Expand All @@ -293,10 +304,12 @@ private static void INotifyCollectionChangedInterfaceType(
/// <summary>
/// Creates a new custom attribute value for <see cref="TypeMapAttribute{TTypeMapGroup}"/> for the <see cref="System.ComponentModel.INotifyPropertyChanged"/> interface type.
/// </summary>
/// <param name="interopDefinitions">The <see cref="InteropDefinitions"/> instance to use.</param>
/// <param name="interopReferences">The <see cref="InteropReferences"/> instance to use.</param>
/// <param name="module">The module that the attribute will be used from.</param>
/// <param name="useWindowsUIXamlProjections">Whether to use <c>Windows.UI.Xaml</c> projections.</param>
private static void INotifyPropertyChangedInterfaceType(
InteropDefinitions interopDefinitions,
InteropReferences interopReferences,
ModuleDefinition module,
bool useWindowsUIXamlProjections)
Expand All @@ -323,6 +336,7 @@ private static void INotifyPropertyChangedInterfaceType(

// Define the 'InterfaceImpl' type for the 'INotifyPropertyChanged' interface type
INotifyPropertyChanged.InterfaceImpl(
interopDefinitions: interopDefinitions,
interopReferences: interopReferences,
module: module,
useWindowsUIXamlProjections: useWindowsUIXamlProjections,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void IIDs(
name: InteropUtf8NameFactory.TypeName(delegateType),
interopDefinitions: interopDefinitions,
interopReferences: interopReferences,
iid: GuidGenerator.CreateIID(delegateType, interopReferences, useWindowsUIXamlProjections),
iid: GuidGenerator.CreateIID(delegateType, interopDefinitions, interopReferences, useWindowsUIXamlProjections),
out get_IidMethod);

// 'IReference<T>' IID, which uses a boxed type signature to represent it.
Expand All @@ -58,7 +58,7 @@ public static void IIDs(
name: InteropUtf8NameFactory.TypeName(delegateType, "Reference"),
interopDefinitions: interopDefinitions,
interopReferences: interopReferences,
iid: GuidGenerator.CreateIID(delegateType.MakeBoxedType(), interopReferences, useWindowsUIXamlProjections),
iid: GuidGenerator.CreateIID(delegateType.MakeBoxedType(), interopDefinitions, interopReferences, useWindowsUIXamlProjections),
out get_ReferenceIidMethod);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,15 @@ public static void ComWrappersMarshallerAttribute(
/// </summary>
/// <param name="actionType">The <see cref="GenericInstanceTypeSignature"/> for the async action type.</param>
/// <param name="actionMethodsType">The <see cref="TypeDefinition"/> instance returned by <see cref="Methods"/>.</param>
/// <param name="interopDefinitions">The <see cref="InteropDefinitions"/> instance to use.</param>
/// <param name="interopReferences">The <see cref="InteropReferences"/> instance to use.</param>
/// <param name="module">The module that will contain the type being created.</param>
/// <param name="useWindowsUIXamlProjections">Whether to use <c>Windows.UI.Xaml</c> projections.</param>
/// <param name="interfaceImplType">The resulting interface implementation type.</param>
public static void InterfaceImpl(
GenericInstanceTypeSignature actionType,
TypeDefinition actionMethodsType,
InteropDefinitions interopDefinitions,
InteropReferences interopReferences,
ModuleDefinition module,
bool useWindowsUIXamlProjections,
Expand All @@ -255,7 +257,7 @@ public static void InterfaceImpl(
CustomAttributes =
{
new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor),
InteropCustomAttributeFactory.Guid(actionType, interopReferences, useWindowsUIXamlProjections)
InteropCustomAttributeFactory.Guid(actionType, interopDefinitions, interopReferences, useWindowsUIXamlProjections)
},
Interfaces =
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,15 @@ public static void ComWrappersMarshallerAttribute(
/// </summary>
/// <param name="operationType">The <see cref="GenericInstanceTypeSignature"/> for the async operation type.</param>
/// <param name="operationMethodsType">The <see cref="TypeDefinition"/> instance returned by <see cref="Methods"/>.</param>
/// <param name="interopDefinitions">The <see cref="InteropDefinitions"/> instance to use.</param>
/// <param name="interopReferences">The <see cref="InteropReferences"/> instance to use.</param>
/// <param name="module">The module that will contain the type being created.</param>
/// <param name="useWindowsUIXamlProjections">Whether to use <c>Windows.UI.Xaml</c> projections.</param>
/// <param name="interfaceImplType">The resulting interface implementation type.</param>
public static void InterfaceImpl(
GenericInstanceTypeSignature operationType,
TypeDefinition operationMethodsType,
InteropDefinitions interopDefinitions,
InteropReferences interopReferences,
ModuleDefinition module,
bool useWindowsUIXamlProjections,
Expand All @@ -209,7 +211,7 @@ public static void InterfaceImpl(
CustomAttributes =
{
new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor),
InteropCustomAttributeFactory.Guid(operationType, interopReferences, useWindowsUIXamlProjections)
InteropCustomAttributeFactory.Guid(operationType, interopDefinitions, interopReferences, useWindowsUIXamlProjections)
},
Interfaces =
{
Expand Down
Loading
Loading