Skip to content

Commit f33c251

Browse files
committed
TestComponent: Add OverloadClass
Copied from microsoft/cppwinrt#1458
1 parent 7edb474 commit f33c251

File tree

6 files changed

+100
-5
lines changed

6 files changed

+100
-5
lines changed

TestComponent/OverloadClass.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "pch.h"
2+
#include "OverloadClass.h"
3+
#include "OverloadClass.g.cpp"
4+
5+
namespace winrt::TestComponent::implementation
6+
{
7+
void OverloadClass::Overload()
8+
{
9+
throw hresult_not_implemented();
10+
}
11+
void OverloadClass::Overload(int a)
12+
{
13+
throw hresult_not_implemented();
14+
}
15+
void OverloadClass::Overload(int a, int b)
16+
{
17+
throw hresult_not_implemented();
18+
}
19+
void OverloadClass::Overload(int a, int b, int c)
20+
{
21+
throw hresult_not_implemented();
22+
}
23+
}

TestComponent/OverloadClass.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma once
2+
#include "OverloadClass.g.h"
3+
4+
namespace winrt::TestComponent::implementation
5+
{
6+
struct OverloadClass : OverloadClassT<OverloadClass>
7+
{
8+
OverloadClass() = default;
9+
10+
void Overload();
11+
void Overload(int a);
12+
void Overload(int a, int b);
13+
void Overload(int a, int b, int c);
14+
};
15+
}
16+
namespace winrt::TestComponent::factory_implementation
17+
{
18+
struct OverloadClass : OverloadClassT<OverloadClass, implementation::OverloadClass>
19+
{
20+
};
21+
}

TestComponent/TestComponent.idl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,51 @@ namespace TestComponent
292292
{
293293
Derived();
294294
}
295+
296+
[exclusiveto(TestComponent.OverloadClass)]
297+
[version(1), uuid(EF902013-00F3-4549-9032-49E86D536C07)]
298+
interface IOverloadClass : IInspectable
299+
{
300+
HRESULT Overload();
301+
}
302+
303+
[exclusiveto(TestComponent.OverloadClass)]
304+
[version(1), uuid(DFDFFB61-EA72-4977-B1A7-3F0D2C32BB58)]
305+
interface IOverloadClassFactory : IInspectable
306+
{
307+
HRESULT CreateInstance([in] IInspectable* baseInterface, [out] IInspectable** innerInterface, [out][retval] TestComponent.OverloadClass** value);
308+
}
309+
310+
[exclusiveto(TestComponent.OverloadClass)]
311+
[version(1), uuid(32510F72-9229-4C69-95BD-DE7B8189C85C)]
312+
interface IOverloadClassOverrides : IInspectable
313+
{
314+
[overload("Overload")] HRESULT OverloadWithOne(int a);
315+
}
316+
317+
[exclusiveto(TestComponent.OverloadClass)]
318+
[version(1), uuid(50205BCE-FAD3-4C66-801F-17AAD007B26C)]
319+
interface IOverloadClassOverrides2 : IInspectable
320+
{
321+
[overload("Overload")] HRESULT OverloadWithTwo(int a, int b);
322+
}
323+
324+
[exclusiveto(TestComponent.OverloadClass)]
325+
[version(1), uuid(6EDD1A3F-2616-45B7-9731-F84DA9CCECA1)]
326+
interface IOverloadClassProtected : IInspectable
327+
{
328+
[overload("Overload")] HRESULT OverloadWithThree(int a, int b, int c);
329+
}
330+
331+
[composable(TestComponent.IOverloadClassFactory, public, 1)]
332+
[marshaling_behavior(agile)]
333+
[threading(both)]
334+
[version(1)]
335+
runtimeclass OverloadClass
336+
{
337+
[default] interface TestComponent.IOverloadClass;
338+
[protected] interface TestComponent.IOverloadClassProtected;
339+
[overridable] interface TestComponent.IOverloadClassOverrides;
340+
[overridable] interface TestComponent.IOverloadClassOverrides2;
341+
}
295342
}

TestComponent/TestComponent.vcxproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.220331.4\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220331.4\build\native\Microsoft.Windows.CppWinRT.props')" />
3+
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
44
<PropertyGroup Label="Globals">
55
<CppWinRTOptimized>true</CppWinRTOptimized>
66
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
@@ -150,13 +150,15 @@
150150
<ClInclude Include="Class.h" />
151151
<ClInclude Include="Composable.h" />
152152
<ClInclude Include="Derived.h" />
153+
<ClInclude Include="OverloadClass.h" />
153154
<ClInclude Include="pch.h" />
154155
<ClInclude Include="TestRunner.h" />
155156
</ItemGroup>
156157
<ItemGroup>
157158
<ClCompile Include="Class.cpp" />
158159
<ClCompile Include="Composable.cpp" />
159160
<ClCompile Include="Derived.cpp" />
161+
<ClCompile Include="OverloadClass.cpp" />
160162
<ClCompile Include="pch.cpp">
161163
<PrecompiledHeader>Create</PrecompiledHeader>
162164
</ClCompile>
@@ -172,13 +174,13 @@
172174
</ItemGroup>
173175
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
174176
<ImportGroup Label="ExtensionTargets">
175-
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.220331.4\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220331.4\build\native\Microsoft.Windows.CppWinRT.targets')" />
177+
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets')" />
176178
</ImportGroup>
177179
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
178180
<PropertyGroup>
179181
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
180182
</PropertyGroup>
181-
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220331.4\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.220331.4\build\native\Microsoft.Windows.CppWinRT.props'))" />
182-
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220331.4\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.220331.4\build\native\Microsoft.Windows.CppWinRT.targets'))" />
183+
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props'))" />
184+
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets'))" />
183185
</Target>
184186
</Project>

TestComponent/TestComponent.vcxproj.filters

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
<ClCompile Include="Composable.cpp" />
1717
<ClCompile Include="Derived.cpp" />
1818
<ClCompile Include="Class.cpp" />
19+
<ClCompile Include="OverloadClass.cpp" />
1920
</ItemGroup>
2021
<ItemGroup>
2122
<ClInclude Include="pch.h" />
2223
<ClInclude Include="TestRunner.h" />
2324
<ClInclude Include="Composable.h" />
2425
<ClInclude Include="Derived.h" />
2526
<ClInclude Include="Class.h" />
27+
<ClInclude Include="OverloadClass.h" />
2628
</ItemGroup>
2729
<ItemGroup>
2830
<Midl Include="TestComponent.idl" />

TestComponent/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Windows.CppWinRT" version="2.0.220331.4" targetFramework="native" />
3+
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
44
</packages>

0 commit comments

Comments
 (0)