Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -155,9 +155,9 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<UsingTask Condition="'$(CsWinRTGeneratorTasksOverriden)' != 'true'" TaskName="RunCsWinRTGenerator" AssemblyFile="$(CsWinRTGenTasksAssembly)" />
<Target
Name="_RunCsWinRTGenerator"
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="'$(CsWinRTGenerateInteropAssembly)' == 'true'">

Expand All @@ -177,6 +177,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
ReferenceAssemblyPaths="@(_ReferenceAssemblyPaths)"
ImplementationAssemblyPaths="@(ReferencePath)"
OutputAssemblyPath="@(IntermediateAssembly)"
WinRTProjectionAssemblyPath="$(_CsWinRTGeneratorMergedProjectionAssemblyPath)"
InteropAssemblyDirectory="$(CsWinRTGeneratorInteropAssemblyDirectory)"
DebugReproDirectory="$(CsWinRTGeneratorDebugReproDirectory)"
CsWinRTToolsDirectory="$(CsWinRTGenEffectiveToolsDirectory)"
Expand Down
20 changes: 20 additions & 0 deletions src/RunCsWinRTGeneratorTask/RunCsWinRTGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ public sealed class RunCsWinRTGenerator : 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