Skip to content

Commit 97a7b4e

Browse files
authored
Make sure we pass StaticLibrary references as references to mdmerge. (#499)
1 parent b8b65c3 commit 97a7b4e

File tree

17 files changed

+34
-46
lines changed

17 files changed

+34
-46
lines changed

nuget/Microsoft.Windows.CppWinRT.targets

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,14 @@ Copyright (C) Microsoft Corporation. All rights reserved.
308308
<MdMergeOutputFile>$(CppWinRTProjectWinMD)</MdMergeOutputFile>
309309
</_MdMergeInputs>
310310
<!-- Static libraries don't mdmerge other static libraries.
311-
Instead they are passed independent inputs for the compoenent projection. -->
311+
Instead they are passed as independent inputs for the component projection. -->
312312
<_MdMergeInputs Include="@(CppWinRTStaticProjectWinMDReferences)" Condition="'$(ConfigurationType)' != 'StaticLibrary'">
313313
<MdMergeOutputFile>$(CppWinRTProjectWinMD)</MdMergeOutputFile>
314314
</_MdMergeInputs>
315315
<_MdMergeReferences Remove="@(_MdMergeReferences)" />
316+
<!-- Static libraries don't mdmerge other static libraries.
317+
They are however used as references so idl can reference classes from other libs. -->
318+
<_MdMergeReferences Include="@(CppWinRTStaticProjectWinMDReferences)" Condition="'$(ConfigurationType)' == 'StaticLibrary'" />
316319
<_MdMergeReferences Include="@(CppWinRTDirectWinMDReferences)" />
317320
<_MdMergeReferences Include="@(CppWinRTDynamicProjectWinMDReferences)" />
318321
<_MdMergeReferences Include="@(CppWinRTPlatformWinMDReferences)" />

test/nuget/Directory.Build.props

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
<Import Condition="Exists($([MSBuild]::GetPathOfFileAbove('Directory.Build.props','$(MSBuildThisFileDirectory)../')))" Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props','$(MSBuildThisFileDirectory)../'))" />
88

9-
<PropertyGroup>
9+
<PropertyGroup>
10+
<PlatformDirectoryName Condition="'$(Platform)' == 'Win32'">x86</PlatformDirectoryName>
11+
<PlatformDirectoryName Condition="'$(Platform)' != 'Win32'">$(Platform)</PlatformDirectoryName>
12+
1013
<!-- Consistent output directory for AppContainer and non-AppContainer projects -->
1114
<!-- Build overrides the roots. -->
1215
<GenerateProjectSpecificOutputFolder>false</GenerateProjectSpecificOutputFolder>

test/nuget/TestApp/MainPage.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using namespace winrt;
66
using namespace Windows::UI::Xaml;
77

8+
using namespace winrt::TestApp::Library1;
9+
using namespace winrt::TestApp::Library4;
810
using namespace winrt::TestRuntimeComponent1;
911
using namespace winrt::TestRuntimeComponent2;
1012
using namespace winrt::TestRuntimeComponentCX;
@@ -30,12 +32,12 @@ namespace winrt::TestApp::implementation
3032
TestRuntimeComponentNamespaceUnderscoreClass cUnderscore{};
3133
cUnderscore.Test();
3234

33-
TestStaticLibrary1Class cStatic1{};
34-
cStatic1.Test();
35-
3635
TestStaticLibrary4Class cStatic4{};
3736
cStatic4.Test();
3837

38+
TestStaticLibrary1Class cStatic1{};
39+
cStatic1.Test(cStatic4);
40+
3941
TestStaticLibrary5Class cStatic5{};
4042
cStatic5.Test();
4143

test/nuget/TestApp/pch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <winrt/Windows.UI.Xaml.Markup.h>
1515
#include <winrt/Windows.UI.Xaml.Navigation.h>
1616

17+
#include <winrt/TestApp.Library1.h>
18+
#include <winrt/TestApp.Library4.h>
1719
#include <winrt/TestRuntimeComponent1.h>
1820
#include <winrt/TestRuntimeComponent2.h>
1921
#include <winrt/TestRuntimeComponentCX.h>

test/nuget/TestRuntimeComponent2/module.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ int32_t __stdcall WINRT_CanUnloadNow() noexcept
4040

4141
int32_t __stdcall WINRT_GetActivationFactory(void* classId, void** factory) noexcept try
4242
{
43-
uint32_t length{};
44-
wchar_t const* const buffer = WINRT_WindowsGetStringRawBuffer(classId, &length);
45-
std::wstring_view const name{ buffer, length };
43+
std::wstring_view const name{ *reinterpret_cast<winrt::hstring*>(&classId) };
4644
*factory = winrt_get_activation_factory(name);
4745

4846
if (*factory)

test/nuget/TestRuntimeComponent3/module.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ int32_t __stdcall WINRT_CanUnloadNow() noexcept
4545

4646
int32_t __stdcall WINRT_GetActivationFactory(void* classId, void** factory) noexcept try
4747
{
48-
uint32_t length{};
49-
wchar_t const* const buffer = WINRT_WindowsGetStringRawBuffer(classId, &length);
50-
std::wstring_view const name{ buffer, length };
48+
std::wstring_view const name{ *reinterpret_cast<winrt::hstring*>(&classId) };
5149
*factory = winrt_get_activation_factory(name);
5250

5351
if (*factory)

test/nuget/TestRuntimeComponentCSharp/TestRuntimeComponentCSharp.csproj

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,6 @@
1818
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1919
<AllowCrossPlatformRetargeting>false</AllowCrossPlatformRetargeting>
2020
</PropertyGroup>
21-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
22-
<PlatformTarget>AnyCPU</PlatformTarget>
23-
<DebugSymbols>true</DebugSymbols>
24-
<DebugType>full</DebugType>
25-
<Optimize>false</Optimize>
26-
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
27-
<ErrorReport>prompt</ErrorReport>
28-
<WarningLevel>4</WarningLevel>
29-
</PropertyGroup>
30-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
31-
<PlatformTarget>AnyCPU</PlatformTarget>
32-
<DebugType>pdbonly</DebugType>
33-
<Optimize>true</Optimize>
34-
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
35-
<ErrorReport>prompt</ErrorReport>
36-
<WarningLevel>4</WarningLevel>
37-
</PropertyGroup>
3821
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
3922
<PlatformTarget>x86</PlatformTarget>
4023
<DebugSymbols>true</DebugSymbols>

test/nuget/TestRuntimeComponentEmpty/module.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ int32_t __stdcall WINRT_CanUnloadNow() noexcept
4545

4646
int32_t __stdcall WINRT_GetActivationFactory(void* classId, void** factory) noexcept try
4747
{
48-
uint32_t length{};
49-
wchar_t const* const buffer = WINRT_WindowsGetStringRawBuffer(classId, &length);
50-
std::wstring_view const name{ buffer, length };
48+
std::wstring_view const name{ *reinterpret_cast<winrt::hstring*>(&classId) };
5149
*factory = winrt_get_activation_factory(name);
5250

5351
if (*factory)

test/nuget/TestStaticLibrary1/TestStaticLibrary1.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<ProjectGuid>{2158F418-CA97-4599-8103-EFC133850BAA}</ProjectGuid>
99
<Keyword>StaticLibrary</Keyword>
1010
<ProjectName>TestStaticLibrary1</ProjectName>
11-
<RootNamespace>TestApp</RootNamespace>
11+
<RootNamespace>TestApp.Library1</RootNamespace>
1212
<DefaultLanguage>en-US</DefaultLanguage>
1313
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
1414
<AppContainerApplication>true</AppContainerApplication>

test/nuget/TestStaticLibrary1/TestStaticLibrary1Class.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
#include "TestStaticLibrary1Class.h"
33
#include "TestStaticLibrary1Class.g.cpp"
44

5-
namespace winrt::TestApp::implementation
5+
using namespace winrt::TestApp::Library4;
6+
7+
namespace winrt::TestApp::Library1::implementation
68
{
7-
void TestStaticLibrary1Class::Test()
9+
void TestStaticLibrary1Class::Test(TestStaticLibrary4Class const& c)
810
{
9-
TestStaticLibrary4Class c{};
1011
c.Test();
1112
}
1213
}

0 commit comments

Comments
 (0)