diff --git a/nuget/Microsoft.Windows.CsWinRT.CsWinRTGen.targets b/nuget/Microsoft.Windows.CsWinRT.CsWinRTGen.targets
index 1c3ad8a56..a5b69a70e 100644
--- a/nuget/Microsoft.Windows.CsWinRT.CsWinRTGen.targets
+++ b/nuget/Microsoft.Windows.CsWinRT.CsWinRTGen.targets
@@ -8,7 +8,9 @@ Copyright (C) Microsoft Corporation. All rights reserved.
$(SolutionDir)RunCsWinRTGeneratorTask\bin\$(Configuration)\netstandard2.0\RunCsWinRTGeneratorTask.dll
- $(SolutionDir)WinRT.Interop.Generator\bin\$(Configuration)\net10.0\
+ $(SolutionDir)WinRT.Interop.Generator\bin\$(Configuration)\net10.0\
+ $(SolutionDir)WinRT.Impl.Generator\bin\$(Configuration)\net10.0\
+ $(SolutionDir)WinRT.Projection.Generator\bin\$(Configuration)\net10.0\
AnyCPU
<_TargetPlatformVersionUsesCsWinRT3>true
@@ -17,7 +19,8 @@ Copyright (C) Microsoft Corporation. All rights reserved.
So the switch for it is currently opt-in. It can be changed to opt-out in the future.
We only enable this automatically if the project is explicitly targeting CsWinRT 3.0.
-->
- true
+ true
+ true
false
<_RunCsWinRTGeneratorPropertyInputsCachePath Condition="'$(_RunCsWinRTGeneratorPropertyInputsCachePath)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).cswinrtgen.cache
<_RunCsWinRTGeneratorPropertyInputsCachePath>$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '$(_RunCsWinRTGeneratorPropertyInputsCachePath)'))
+
+
+ $(IntermediateOutputPath)\forwarder\
+ <_CsWinRTGeneratorForwarderAssemblyPath>$(CsWinRTGeneratorForwarderAssemblyDirectory)$(AssemblyName).dll
+
+
+ <_CsWinRTGeneratorMergedProjectionAssemblyPath>$(IntermediateOutputPath)WinRT.Projection.dll
+ <_CsWinRTGeneratorMergedProjectionOutputAssemblyPath>WinRT.Projection.dll
+
+ $(DefineConstants);CSWINRT_REFERENCE_PROJECTION
-
+
+
<_RunCsWinRTGeneratorInputsCacheToHash Include="$(CsWinRTEffectiveToolsDirectory)" />
@@ -125,17 +156,17 @@ Copyright (C) Microsoft Corporation. All rights reserved.
Name="_RunCsWinRTGenerator"
DependsOnTargets="CoreCompile;$(GetTargetPathDependsOn);$(GetTargetPathWithTargetPlatformMonikerDependsOn);_ComputeRunCsWinRTGeneratorCache"
BeforeTargets="GetTargetPath;GetTargetPathWithTargetPlatformMoniker;GenerateBuildDependencyFile;GeneratePublishDependencyFile;GetCopyToOutputDirectoryItems;GetCopyToPublishDirectoryItems"
- Inputs="@(ReferencePath);@(IntermediateAssembly);$(_RunCsWinRTGeneratorPropertyInputsCachePath)"
+ Inputs="@(ReferencePathWithRefAssemblies);@(IntermediateAssembly);$(_RunCsWinRTGeneratorPropertyInputsCachePath)"
Outputs="$(_CsWinRTGeneratorInteropAssemblyPath)"
Condition="'$(CsWinRTGenerateInteropAssembly)' == 'true'">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @(CsWinRTInputs)
+
+
+
+
+
+
+
+
+
+ <_ReferencePathsWithWinMDs Include="@(ReferencePathWithRefAssemblies)" Condition="'%(ReferencePathWithRefAssemblies.CsWinRTInputs)' != ''" />
+ <_WinMDPathsList Include="@(CsWinRTInputs)" />
+ <_WinMDPathsList Include="$([MSBuild]::ValueOrDefault('%(_ReferencePathsWithWinMDs.CsWinRTInputs)', '').Split(';'))"
+ Condition="'%(_ReferencePathsWithWinMDs.CsWinRTInputs)' != ''" />
+ <_WinMDPathsList Include="$(CsWinRTInteropMetadata)" />
+
+
+
+
+
+
+
+
+ WinRT.Projection
+ .NETCoreApp
+ false
+ true
+ true
+ _RunCsWinRTMergedProjectionGenerator
+ AnyCPU
+
+
+
+
+
+
+
+
+
+
+
+ <_SourceItemsToCopyToOutputDirectory
+ Include="@(CsWinRTGeneratorMergedProjectionPath)"
+ TargetPath="$(_CsWinRTGeneratorMergedProjectionOutputAssemblyPath)" />
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nuget/Microsoft.Windows.CsWinRT.targets b/nuget/Microsoft.Windows.CsWinRT.targets
index ae18e9af7..9b817dff0 100644
--- a/nuget/Microsoft.Windows.CsWinRT.targets
+++ b/nuget/Microsoft.Windows.CsWinRT.targets
@@ -13,6 +13,11 @@ Copyright (C) Microsoft Corporation. All rights reserved.
false
false
true
+ false
+ false
+ true
+ true
+ $([MSBuild]::NormalizePath($(TargetDir), 'ref', $(TargetFileName)))
true
+ true
+
+
+ WindowsRuntime.ProjectionGenerator
+
+
+ cswinrtprojectiongen
+
+
+ true
+ true
+ latest
+ latest-all
+ true
+ strict
+ true
+
+
+
+
+
+
+
+
diff --git a/src/cswinrt.slnx b/src/cswinrt.slnx
index 7db15b0a3..5257edd28 100644
--- a/src/cswinrt.slnx
+++ b/src/cswinrt.slnx
@@ -175,8 +175,7 @@
-
-
+
@@ -356,6 +355,7 @@
+
diff --git a/src/cswinrt/code_writers.h b/src/cswinrt/code_writers.h
index 13ff88e44..b8148fb8c 100644
--- a/src/cswinrt/code_writers.h
+++ b/src/cswinrt/code_writers.h
@@ -1588,6 +1588,12 @@ namespace cswinrt
void write_abi_static_method_call(writer& w, type_semantics const& iface, MethodDef const& method, std::string const& targetObjRef)
{
+ if (settings.reference_projection)
+ {
+ w.write("throw null");
+ return;
+ }
+
method_signature signature{ method };
w.write("%.%(%%%)", bind(iface, typedef_name_type::StaticAbiClass, true),
method.Name(),
@@ -1598,6 +1604,12 @@ namespace cswinrt
void write_unsafe_accessor_static_method_call(writer& w, std::string const& unsafeAccessorMethod, MethodDef const& method, std::string const& targetObjRef)
{
+ if (settings.reference_projection)
+ {
+ w.write("throw null");
+ return;
+ }
+
method_signature signature{ method };
w.write("%(null, %%%)",
unsafeAccessorMethod,
@@ -1608,6 +1620,12 @@ namespace cswinrt
void write_abi_get_property_static_method_call(writer& w, type_semantics const& iface, Property const& prop, std::string const& targetObjRef)
{
+ if (settings.reference_projection)
+ {
+ w.write("throw null");
+ return;
+ }
+
w.write("%.%(%)",
bind(iface, typedef_name_type::StaticAbiClass, true),
prop.Name(),
@@ -1616,6 +1634,12 @@ namespace cswinrt
void write_abi_set_property_static_method_call(writer& w, type_semantics const& iface, Property const& prop, std::string const& targetObjRef)
{
+ if (settings.reference_projection)
+ {
+ w.write("throw null");
+ return;
+ }
+
w.write("%.%(%, value)",
bind(iface, typedef_name_type::StaticAbiClass, true),
prop.Name(),
@@ -1624,6 +1648,12 @@ namespace cswinrt
void write_unsafe_accessor_property_static_method_call(writer& w, std::string const& unsafeAccessorMethod, std::string const& targetObjRef, bool get)
{
+ if (settings.reference_projection)
+ {
+ w.write("throw null");
+ return;
+ }
+
w.write("%(null, %%)",
unsafeAccessorMethod,
targetObjRef,
@@ -1632,6 +1662,12 @@ namespace cswinrt
void write_abi_event_source_static_method_call(writer& w, type_semantics const& iface, Event const& evt, bool isSubscribeCall, std::string const& targetObjRef, bool is_static_event = false)
{
+ if (settings.reference_projection)
+ {
+ w.write("throw null");
+ return;
+ }
+
bool is_unsafe_accessor_call = false;
w.write("%(%, %).%(value)",
bind([&](writer& w) {
@@ -2611,6 +2647,22 @@ private static % _% = new %("%.%", %.IID);
void write_activation_factory_objref_definition(writer& w, TypeDef const& classType)
{
auto objrefname = w.write_temp("%", bind(classType));
+ if (settings.reference_projection)
+ {
+ w.write(R"(
+private static WindowsRuntimeObjectReference %
+{
+ get
+ {
+ throw null;
+ }
+}
+)",
+ objrefname);
+ return;
+ }
+
+
w.write(R"(
private static WindowsRuntimeObjectReference %
{
@@ -2636,6 +2688,22 @@ private static WindowsRuntimeObjectReference %
void write_static_objref_definition(writer& w, TypeDef const& staticsType, TypeDef const& classType)
{
auto objrefname = w.write_temp("%", bind(staticsType));
+ if (settings.reference_projection)
+ {
+ w.write(R"(
+private static WindowsRuntimeObjectReference %
+{
+ get
+ {
+ throw null;
+ }
+}
+)",
+ objrefname);
+ return;
+ }
+
+
w.write(R"(
private static WindowsRuntimeObjectReference %
{
@@ -4703,8 +4771,24 @@ R"(#pragma warning disable IL2026
type.TypeNamespace(), type.TypeName());
}
+ void write_class_winrt_classname_attribute(writer& w, TypeDef const& type)
+ {
+ if (settings.reference_projection)
+ {
+ return;
+ }
+
+ w.write("[WindowsRuntimeClassName(%.RuntimeClassName)]\n",
+ bind(type, typedef_name_type::ABI, false));
+ }
+
void write_comwrapper_marshaller_attribute(writer& w, TypeDef const& type)
{
+ if (settings.reference_projection)
+ {
+ return;
+ }
+
w.write("[ABI.%.%ComWrappersMarshaller]\n",
type.TypeNamespace(), type.TypeName());
}
@@ -6219,19 +6303,31 @@ public override unsafe void Invoke(
ReadOnlySpan