diff --git a/src/Projections/Test/Test.csproj b/src/Projections/Test/Test.csproj index 2878ba757..449be0db9 100644 --- a/src/Projections/Test/Test.csproj +++ b/src/Projections/Test/Test.csproj @@ -20,6 +20,7 @@ TestComponent;TestComponentCSharp;test_component_base;test_component_derived; + TestComponentCSharp.AnotherAssembly; $([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.winui', '$(MicrosoftWinUIVersion)')) diff --git a/src/Projections/TestSubset/TestSubset.csproj b/src/Projections/TestSubset/TestSubset.csproj new file mode 100644 index 000000000..6e4a1a11b --- /dev/null +++ b/src/Projections/TestSubset/TestSubset.csproj @@ -0,0 +1,32 @@ + + + + netstandard2.0;net5.0;net6.0 + x64;x86 + + + + + + + + + + + + + + + + + + TestComponentCSharp.AnotherAssembly; + + $([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.winui', '$(MicrosoftWinUIVersion)')) + + + + + + + \ No newline at end of file diff --git a/src/Tests/TestComponentCSharp/AnotherAssembly.SetPropertyClass.cpp b/src/Tests/TestComponentCSharp/AnotherAssembly.SetPropertyClass.cpp new file mode 100644 index 000000000..705707444 --- /dev/null +++ b/src/Tests/TestComponentCSharp/AnotherAssembly.SetPropertyClass.cpp @@ -0,0 +1,16 @@ +#include "pch.h" +#include "AnotherAssembly.SetPropertyClass.h" +#include "AnotherAssembly.SetPropertyClass.g.cpp" + +namespace winrt::TestComponentCSharp::AnotherAssembly::implementation +{ + void SetPropertyClass::ReadWriteProperty(int32_t value) + { + readWriteValue = value; + } + + int32_t SetPropertyClass::ReadWriteProperty() + { + return readWriteValue; + } +} diff --git a/src/Tests/TestComponentCSharp/AnotherAssembly.SetPropertyClass.h b/src/Tests/TestComponentCSharp/AnotherAssembly.SetPropertyClass.h new file mode 100644 index 000000000..ce73bd7ce --- /dev/null +++ b/src/Tests/TestComponentCSharp/AnotherAssembly.SetPropertyClass.h @@ -0,0 +1,21 @@ +#pragma once +#include "AnotherAssembly.SetPropertyClass.g.h" + +namespace winrt::TestComponentCSharp::AnotherAssembly::implementation +{ + struct SetPropertyClass : SetPropertyClassT + { + SetPropertyClass() = default; + + void ReadWriteProperty(int32_t value); + int32_t ReadWriteProperty(); + + int32_t readWriteValue; + }; +} +namespace winrt::TestComponentCSharp::AnotherAssembly::factory_implementation +{ + struct SetPropertyClass : SetPropertyClassT + { + }; +} \ No newline at end of file diff --git a/src/Tests/TestComponentCSharp/TestComponentCSharp.idl b/src/Tests/TestComponentCSharp/TestComponentCSharp.idl index f47f61a38..1c15a8954 100644 --- a/src/Tests/TestComponentCSharp/TestComponentCSharp.idl +++ b/src/Tests/TestComponentCSharp/TestComponentCSharp.idl @@ -562,4 +562,14 @@ And this is another one" { }; } + + namespace AnotherAssembly + { + [default_interface] + runtimeclass SetPropertyClass : TestComponentCSharp.IProperties1 + { + SetPropertyClass(); + Int32 ReadWriteProperty{ set; }; + } + } } \ No newline at end of file diff --git a/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj b/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj index 9b9ed5e54..b24cd199e 100644 --- a/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj +++ b/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj @@ -76,6 +76,7 @@ + @@ -91,6 +92,7 @@ + Create diff --git a/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj.filters b/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj.filters index b9036a929..f7706e887 100644 --- a/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj.filters +++ b/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj.filters @@ -18,6 +18,7 @@ + @@ -29,6 +30,7 @@ + diff --git a/src/Tests/UnitTest/TestComponentCSharp_Tests.cs b/src/Tests/UnitTest/TestComponentCSharp_Tests.cs index 1911cf1e2..65dd6010b 100644 --- a/src/Tests/UnitTest/TestComponentCSharp_Tests.cs +++ b/src/Tests/UnitTest/TestComponentCSharp_Tests.cs @@ -2432,6 +2432,17 @@ public void TestInterfaceObjectMarshalling() TestObject.CopyProperties(nativeProperties); Assert.Equal(TestObject.ReadWriteProperty, nativeProperties.ReadWriteProperty); + } + + [Fact] + public void TestSetPropertyAcrossProjections() + { + var setPropertyClass = new TestComponentCSharp.AnotherAssembly.SetPropertyClass(); + setPropertyClass.ReadWriteProperty = 4; + Assert.Equal(4, setPropertyClass.ReadWriteProperty); + + IProperties1 property = setPropertyClass; + Assert.Equal(4, property.ReadWriteProperty); } // Test scenario where type reported by runtimeclass name is not a valid type (i.e. internal type). diff --git a/src/Tests/UnitTest/UnitTest.csproj b/src/Tests/UnitTest/UnitTest.csproj index 097ae67cb..56a9ebb90 100644 --- a/src/Tests/UnitTest/UnitTest.csproj +++ b/src/Tests/UnitTest/UnitTest.csproj @@ -16,6 +16,7 @@ + diff --git a/src/cswinrt.sln b/src/cswinrt.sln index 671ce57ee..7ec82b2ed 100644 --- a/src/cswinrt.sln +++ b/src/cswinrt.sln @@ -117,6 +117,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IIDOptimizer", "Perf\IIDOpt EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Reunion", "Projections\Reunion\Reunion.csproj", "{B6312AD1-A59E-4F3B-AA39-20B780FE9E15}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestSubset", "Projections\TestSubset\TestSubset.csproj", "{80F0EC48-5536-49D6-8ED1-B1F4CED88073}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -482,6 +484,18 @@ Global {B6312AD1-A59E-4F3B-AA39-20B780FE9E15}.Release|x64.Build.0 = Release|x64 {B6312AD1-A59E-4F3B-AA39-20B780FE9E15}.Release|x86.ActiveCfg = Release|x86 {B6312AD1-A59E-4F3B-AA39-20B780FE9E15}.Release|x86.Build.0 = Release|x86 + {80F0EC48-5536-49D6-8ED1-B1F4CED88073}.Debug|ARM.ActiveCfg = Debug|x86 + {80F0EC48-5536-49D6-8ED1-B1F4CED88073}.Debug|ARM64.ActiveCfg = Debug|x86 + {80F0EC48-5536-49D6-8ED1-B1F4CED88073}.Debug|x64.ActiveCfg = Debug|x64 + {80F0EC48-5536-49D6-8ED1-B1F4CED88073}.Debug|x64.Build.0 = Debug|x64 + {80F0EC48-5536-49D6-8ED1-B1F4CED88073}.Debug|x86.ActiveCfg = Debug|x86 + {80F0EC48-5536-49D6-8ED1-B1F4CED88073}.Debug|x86.Build.0 = Debug|x86 + {80F0EC48-5536-49D6-8ED1-B1F4CED88073}.Release|ARM.ActiveCfg = Release|x86 + {80F0EC48-5536-49D6-8ED1-B1F4CED88073}.Release|ARM64.ActiveCfg = Release|x86 + {80F0EC48-5536-49D6-8ED1-B1F4CED88073}.Release|x64.ActiveCfg = Release|x64 + {80F0EC48-5536-49D6-8ED1-B1F4CED88073}.Release|x64.Build.0 = Release|x64 + {80F0EC48-5536-49D6-8ED1-B1F4CED88073}.Release|x86.ActiveCfg = Release|x86 + {80F0EC48-5536-49D6-8ED1-B1F4CED88073}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -509,6 +523,7 @@ Global {493C7729-2F21-4198-AB09-BDF56BF501D3} = {CFB651EC-DAA4-4A11-ABCD-C77F90602EB5} {AE3B0611-2FBB-42AB-A245-B4E79868A5F9} = {539DBDEF-3B49-4503-9BD3-7EB83C2179CB} {B6312AD1-A59E-4F3B-AA39-20B780FE9E15} = {6D41796B-9904-40B8-BBCB-40B2D1BAE44B} + {80F0EC48-5536-49D6-8ED1-B1F4CED88073} = {6D41796B-9904-40B8-BBCB-40B2D1BAE44B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {5AE8C9D7-2613-4E1A-A4F2-579BAC28D0A2} diff --git a/src/cswinrt/code_writers.h b/src/cswinrt/code_writers.h index 2b7037e0d..b06947431 100644 --- a/src/cswinrt/code_writers.h +++ b/src/cswinrt/code_writers.h @@ -3457,7 +3457,9 @@ global::System.Collections.Concurrent.ConcurrentDictionary()"s : "((%)(IWinRTObject)this)"s; w.write("get{ return " + getter_cast + ".%; }\n", getter_interface, prop.Name()); }