Skip to content

Commit

Permalink
preview: Test non-WinRT dependency of dependency #7
Browse files Browse the repository at this point in the history
  • Loading branch information
roxk committed Apr 1, 2024
1 parent a080c1a commit 37a55ec
Show file tree
Hide file tree
Showing 29 changed files with 505 additions and 40 deletions.
12 changes: 12 additions & 0 deletions WinUI3XamlPreview/TestDep/BlankPage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "pch.h"
#include "BlankPage.h"
#if __has_include("BlankPage.g.cpp")
#include "BlankPage.g.cpp"
#endif

using namespace winrt;
using namespace Windows::UI::Xaml;

namespace winrt::TestDep::implementation
{
}
22 changes: 22 additions & 0 deletions WinUI3XamlPreview/TestDep/BlankPage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "BlankPage.g.h"

namespace winrt::TestDep::implementation
{
struct BlankPage : BlankPageT<BlankPage>
{
BlankPage()
{
// Xaml objects should not call InitializeComponent during construction.
// See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
}
};
}

namespace winrt::TestDep::factory_implementation
{
struct BlankPage : BlankPageT<BlankPage, implementation::BlankPage>
{
};
}
8 changes: 8 additions & 0 deletions WinUI3XamlPreview/TestDep/BlankPage.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace TestDep
{
[default_interface]
runtimeclass BlankPage : Microsoft.UI.Xaml.Controls.Page
{
BlankPage();
}
}
13 changes: 13 additions & 0 deletions WinUI3XamlPreview/TestDep/BlankPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Page
x:Class="TestDep.BlankPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:TestDep"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<StackPanel>
<local:DepUserControl />
<local:DepCustomControl />
</StackPanel>
</Page>
17 changes: 17 additions & 0 deletions WinUI3XamlPreview/TestDep/TestDep.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="BlankPage.h">
<DependentUpon>BlankPage.xaml</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="DepCustomControl.h">
<DependentUpon>DepCustomControl.cpp</DependentUpon>
<SubType>Code</SubType>
Expand All @@ -115,6 +119,10 @@
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="BlankPage.cpp">
<DependentUpon>BlankPage.xaml</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="DepCustomControl.cpp">
<SubType>Code</SubType>
</ClCompile>
Expand All @@ -137,12 +145,19 @@
</Text>
</ItemGroup>
<ItemGroup>
<Page Include="BlankPage.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="DepUserControl.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Generic.xaml" />
</ItemGroup>
<ItemGroup>
<Midl Include="BlankPage.idl">
<DependentUpon>BlankPage.xaml</DependentUpon>
<SubType>Code</SubType>
</Midl>
<Midl Include="DepCustomControl.idl">
<DependentUpon>DepCustomControl.cpp</DependentUpon>
<SubType>Code</SubType>
Expand All @@ -158,6 +173,7 @@
<Import Project="..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.755\build\Microsoft.Windows.SDK.BuildTools.targets" Condition="Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.755\build\Microsoft.Windows.SDK.BuildTools.targets')" />
<Import Project="..\packages\Microsoft.WindowsAppSDK.1.4.230913002\build\native\Microsoft.WindowsAppSDK.targets" Condition="Exists('..\packages\Microsoft.WindowsAppSDK.1.4.230913002\build\native\Microsoft.WindowsAppSDK.targets')" />
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\packages\WinUI3XamlPreview.WinUI3XamlPreview.0.0.0\build\native\WinUI3XamlPreview.WinUI3XamlPreview.targets" Condition="Exists('..\packages\WinUI3XamlPreview.WinUI3XamlPreview.0.0.0\build\native\WinUI3XamlPreview.WinUI3XamlPreview.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
Expand All @@ -170,5 +186,6 @@
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.4.230913002\build\native\Microsoft.WindowsAppSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.4.230913002\build\native\Microsoft.WindowsAppSDK.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.4.230913002\build\native\Microsoft.WindowsAppSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.4.230913002\build\native\Microsoft.WindowsAppSDK.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\packages\WinUI3XamlPreview.WinUI3XamlPreview.0.0.0\build\native\WinUI3XamlPreview.WinUI3XamlPreview.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WinUI3XamlPreview.WinUI3XamlPreview.0.0.0\build\native\WinUI3XamlPreview.WinUI3XamlPreview.targets'))" />
</Target>
</Project>
1 change: 1 addition & 0 deletions WinUI3XamlPreview/TestDep/TestDep.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
<ItemGroup>
<Page Include="DepUserControl.xaml" />
<Page Include="Themes\Generic.xaml" />
<Page Include="BlankPage.xaml" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions WinUI3XamlPreview/TestDep/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
<package id="Microsoft.Windows.SDK.BuildTools" version="10.0.22621.755" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK" version="1.4.230913002" targetFramework="native" />
<package id="WinUI3XamlPreview.WinUI3XamlPreview" version="0.0.0" targetFramework="native" />
</packages>
1 change: 1 addition & 0 deletions WinUI3XamlPreview/TestDep/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
#include <winrt/Microsoft.UI.Dispatching.h>
#include <wil/cppwinrt_helpers.h>
#include "DepCustomControl.h"
#include <winrt/WinUI3XamlPreview.h>
23 changes: 23 additions & 0 deletions WinUI3XamlPreview/TestDepOfDep/DepCustomControl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "pch.h"
#include "DepCustomControl.h"
#if __has_include("DepCustomControl.g.cpp")
#include "DepCustomControl.g.cpp"
#endif
#include "../TestNonWinRTDep/SomeLibrary.h"
#include <iostream>

using namespace winrt;
using namespace Microsoft::UI::Xaml;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace winrt::TestDepOfDep::implementation
{
DepCustomControl::DepCustomControl()
{
DefaultStyleKey(winrt::box_value(L"TestDepOfDep.DepCustomControl"));
int result = SomeFunction(42);
std::cout << result << std::endl;
}
}
18 changes: 18 additions & 0 deletions WinUI3XamlPreview/TestDepOfDep/DepCustomControl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include "DepCustomControl.g.h"

namespace winrt::TestDepOfDep::implementation
{
struct DepCustomControl : DepCustomControlT<DepCustomControl>
{
DepCustomControl();
};
}

namespace winrt::TestDepOfDep::factory_implementation
{
struct DepCustomControl : DepCustomControlT<DepCustomControl, implementation::DepCustomControl>
{
};
}
8 changes: 8 additions & 0 deletions WinUI3XamlPreview/TestDepOfDep/DepCustomControl.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace TestDepOfDep
{
[default_interface]
runtimeclass DepCustomControl : Microsoft.UI.Xaml.Controls.Control
{
DepCustomControl();
}
}
6 changes: 5 additions & 1 deletion WinUI3XamlPreview/TestDepOfDep/DepOfDepPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<dep:DepCustomControl />
<StackPanel>
<dep:DepCustomControl />
<dep:DepUserControl />
<local:DepCustomControl />
</StackPanel>
</Page>
3 changes: 3 additions & 0 deletions WinUI3XamlPreview/TestDepOfDep/DepOfDepPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ using namespace Microsoft::UI::Xaml;

namespace winrt::TestDepOfDep::implementation
{
DepOfDepPage::DepOfDepPage()
{
}
}
6 changes: 1 addition & 5 deletions WinUI3XamlPreview/TestDepOfDep/DepOfDepPage.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ namespace winrt::TestDepOfDep::implementation
{
struct DepOfDepPage : DepOfDepPageT<DepOfDepPage>
{
DepOfDepPage()
{
// Xaml objects should not call InitializeComponent during construction.
// See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
}
DepOfDepPage();
};
}

Expand Down
21 changes: 21 additions & 0 deletions WinUI3XamlPreview/TestDepOfDep/TestDepOfDep.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
<ClCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">TestNonWinRTDep.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)..;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
Expand All @@ -104,13 +108,20 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="DepCustomControl.h">
<DependentUpon>DepCustomControl.cpp</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="DepOfDepPage.xaml.h">
<DependentUpon>DepOfDepPage.xaml</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="DepCustomControl.cpp">
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="DepOfDepPage.xaml.cpp">
<DependentUpon>DepOfDepPage.xaml</DependentUpon>
<SubType>Code</SubType>
Expand All @@ -133,8 +144,13 @@
<Page Include="DepOfDepPage.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Generic.xaml" />
</ItemGroup>
<ItemGroup>
<Midl Include="DepCustomControl.idl">
<DependentUpon>DepCustomControl.cpp</DependentUpon>
<SubType>Code</SubType>
</Midl>
<Midl Include="DepOfDepPage.idl">
<DependentUpon>DepOfDepPage.xaml</DependentUpon>
<SubType>Code</SubType>
Expand All @@ -144,13 +160,17 @@
<ProjectReference Include="..\TestDep\TestDep.vcxproj">
<Project>{a4c036f2-eab5-4447-ba06-64d6c3e1aff1}</Project>
</ProjectReference>
<ProjectReference Include="..\TestNonWinRTDep\TestNonWinRTDep.vcxproj">
<Project>{139f0229-1c0e-432e-9928-d8589e7fa87c}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.755\build\Microsoft.Windows.SDK.BuildTools.targets" Condition="Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.755\build\Microsoft.Windows.SDK.BuildTools.targets')" />
<Import Project="..\packages\Microsoft.WindowsAppSDK.1.4.230913002\build\native\Microsoft.WindowsAppSDK.targets" Condition="Exists('..\packages\Microsoft.WindowsAppSDK.1.4.230913002\build\native\Microsoft.WindowsAppSDK.targets')" />
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\packages\WinUI3XamlPreview.WinUI3XamlPreview.0.0.0\build\native\WinUI3XamlPreview.WinUI3XamlPreview.targets" Condition="Exists('..\packages\WinUI3XamlPreview.WinUI3XamlPreview.0.0.0\build\native\WinUI3XamlPreview.WinUI3XamlPreview.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
Expand All @@ -163,5 +183,6 @@
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.4.230913002\build\native\Microsoft.WindowsAppSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.4.230913002\build\native\Microsoft.WindowsAppSDK.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.4.230913002\build\native\Microsoft.WindowsAppSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.4.230913002\build\native\Microsoft.WindowsAppSDK.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\packages\WinUI3XamlPreview.WinUI3XamlPreview.0.0.0\build\native\WinUI3XamlPreview.WinUI3XamlPreview.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WinUI3XamlPreview.WinUI3XamlPreview.0.0.0\build\native\WinUI3XamlPreview.WinUI3XamlPreview.targets'))" />
</Target>
</Project>
8 changes: 5 additions & 3 deletions WinUI3XamlPreview/TestDepOfDep/TestDepOfDep.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
<ItemGroup>
<ClCompile Include="pch.cpp" />
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
<ClCompile Include="DepCustomControl.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<Midl Include="Class.idl" />
</ItemGroup>
<ItemGroup>
<None Include="TestDepOfDep.def" />
<None Include="packages.config" />
Expand All @@ -28,5 +26,9 @@
</ItemGroup>
<ItemGroup>
<Page Include="DepOfDepPage.xaml" />
<Page Include="Themes\Generic.xaml" />
</ItemGroup>
<ItemGroup>
<Natvis Include="$(MSBuildThisFileDirectory)..\..\natvis\wil.natvis" />
</ItemGroup>
</Project>
15 changes: 15 additions & 0 deletions WinUI3XamlPreview/TestDepOfDep/Themes/Generic.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestDepOfDep">

<Style TargetType="local:DepCustomControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:DepCustomControl">
<TextBlock Text="Hello from dep of dep custom control" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
1 change: 1 addition & 0 deletions WinUI3XamlPreview/TestDepOfDep/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
<package id="Microsoft.Windows.SDK.BuildTools" version="10.0.22621.755" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK" version="1.4.230913002" targetFramework="native" />
<package id="WinUI3XamlPreview.WinUI3XamlPreview" version="0.0.0" targetFramework="native" />
</packages>
2 changes: 2 additions & 0 deletions WinUI3XamlPreview/TestDepOfDep/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@
#include <winrt/Microsoft.UI.Dispatching.h>
#include <wil/cppwinrt_helpers.h>
#include <winrt/TestDep.h>
#include "DepCustomControl.h"
#include <winrt/WinUI3XamlPreview.h>
7 changes: 7 additions & 0 deletions WinUI3XamlPreview/TestNonWinRTDep/SomeFunction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "pch.h"
#include "SomeLibrary.h"

int SomeFunction(int x)
{
return x * x;
}
9 changes: 9 additions & 0 deletions WinUI3XamlPreview/TestNonWinRTDep/SomeLibrary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#ifdef TESTNONWINRTDEP_EXPORTS
#define SOME_LIB_API __declspec(dllexport)
#else
#define SOME_LIB_API __declspec(dllimport)
#endif

SOME_LIB_API int __stdcall SomeFunction(int x);
Loading

0 comments on commit 37a55ec

Please sign in to comment.