Skip to content

Commit

Permalink
TestComponent: Add OverloadClass
Browse files Browse the repository at this point in the history
  • Loading branch information
dlech committed Nov 24, 2024
1 parent 7edb474 commit f33c251
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 5 deletions.
23 changes: 23 additions & 0 deletions TestComponent/OverloadClass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "pch.h"
#include "OverloadClass.h"
#include "OverloadClass.g.cpp"

namespace winrt::TestComponent::implementation
{
void OverloadClass::Overload()
{
throw hresult_not_implemented();
}
void OverloadClass::Overload(int a)
{
throw hresult_not_implemented();
}
void OverloadClass::Overload(int a, int b)
{
throw hresult_not_implemented();
}
void OverloadClass::Overload(int a, int b, int c)
{
throw hresult_not_implemented();
}
}
21 changes: 21 additions & 0 deletions TestComponent/OverloadClass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once
#include "OverloadClass.g.h"

namespace winrt::TestComponent::implementation
{
struct OverloadClass : OverloadClassT<OverloadClass>
{
OverloadClass() = default;

void Overload();
void Overload(int a);
void Overload(int a, int b);
void Overload(int a, int b, int c);
};
}
namespace winrt::TestComponent::factory_implementation
{
struct OverloadClass : OverloadClassT<OverloadClass, implementation::OverloadClass>
{
};
}
47 changes: 47 additions & 0 deletions TestComponent/TestComponent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,51 @@ namespace TestComponent
{
Derived();
}

[exclusiveto(TestComponent.OverloadClass)]
[version(1), uuid(EF902013-00F3-4549-9032-49E86D536C07)]
interface IOverloadClass : IInspectable
{
HRESULT Overload();
}

[exclusiveto(TestComponent.OverloadClass)]
[version(1), uuid(DFDFFB61-EA72-4977-B1A7-3F0D2C32BB58)]
interface IOverloadClassFactory : IInspectable
{
HRESULT CreateInstance([in] IInspectable* baseInterface, [out] IInspectable** innerInterface, [out][retval] TestComponent.OverloadClass** value);
}

[exclusiveto(TestComponent.OverloadClass)]
[version(1), uuid(32510F72-9229-4C69-95BD-DE7B8189C85C)]
interface IOverloadClassOverrides : IInspectable
{
[overload("Overload")] HRESULT OverloadWithOne(int a);
}

[exclusiveto(TestComponent.OverloadClass)]
[version(1), uuid(50205BCE-FAD3-4C66-801F-17AAD007B26C)]
interface IOverloadClassOverrides2 : IInspectable
{
[overload("Overload")] HRESULT OverloadWithTwo(int a, int b);
}

[exclusiveto(TestComponent.OverloadClass)]
[version(1), uuid(6EDD1A3F-2616-45B7-9731-F84DA9CCECA1)]
interface IOverloadClassProtected : IInspectable
{
[overload("Overload")] HRESULT OverloadWithThree(int a, int b, int c);
}

[composable(TestComponent.IOverloadClassFactory, public, 1)]
[marshaling_behavior(agile)]
[threading(both)]
[version(1)]
runtimeclass OverloadClass
{
[default] interface TestComponent.IOverloadClass;
[protected] interface TestComponent.IOverloadClassProtected;
[overridable] interface TestComponent.IOverloadClassOverrides;
[overridable] interface TestComponent.IOverloadClassOverrides2;
}
}
10 changes: 6 additions & 4 deletions TestComponent/TestComponent.vcxproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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')" />
<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')" />
<PropertyGroup Label="Globals">
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
Expand Down Expand Up @@ -150,13 +150,15 @@
<ClInclude Include="Class.h" />
<ClInclude Include="Composable.h" />
<ClInclude Include="Derived.h" />
<ClInclude Include="OverloadClass.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="TestRunner.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Class.cpp" />
<ClCompile Include="Composable.cpp" />
<ClCompile Include="Derived.cpp" />
<ClCompile Include="OverloadClass.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
Expand All @@ -172,13 +174,13 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<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')" />
<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')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<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>
</PropertyGroup>
<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'))" />
<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'))" />
<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'))" />
<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'))" />
</Target>
</Project>
2 changes: 2 additions & 0 deletions TestComponent/TestComponent.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
<ClCompile Include="Composable.cpp" />
<ClCompile Include="Derived.cpp" />
<ClCompile Include="Class.cpp" />
<ClCompile Include="OverloadClass.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
<ClInclude Include="TestRunner.h" />
<ClInclude Include="Composable.h" />
<ClInclude Include="Derived.h" />
<ClInclude Include="Class.h" />
<ClInclude Include="OverloadClass.h" />
</ItemGroup>
<ItemGroup>
<Midl Include="TestComponent.idl" />
Expand Down
2 changes: 1 addition & 1 deletion TestComponent/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.220331.4" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
</packages>

0 comments on commit f33c251

Please sign in to comment.