Skip to content

Commit

Permalink
Fix mising global:: and add test case to avoid breaking in future. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaanstra committed Feb 6, 2024
1 parent ef21429 commit 174ccbf
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/Tests/TestComponentCSharp/TestComponentCSharp.idl
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,18 @@ And this is another one"
};
}

// Compile time test for sub WinRT namespace
namespace WinRT
{
runtimeclass Class
{
Class();
static void StaticMethod();
void Method();
void Method2(Windows.Foundation.IStringable stringable);
}
}

namespace AnotherAssembly
{
[default_interface]
Expand Down
2 changes: 2 additions & 0 deletions src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<ClInclude Include="WarningClass.h" />
<ClInclude Include="WarningStatic.h" />
<ClInclude Include="Windows.Class.h" />
<ClInclude Include="WinRT.Class.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
Expand All @@ -114,6 +115,7 @@
<ClCompile Include="WarningClass.cpp" />
<ClCompile Include="WarningStatic.cpp" />
<ClCompile Include="Windows.Class.cpp" />
<ClCompile Include="WinRT.Class.cpp" />
</ItemGroup>
<ItemGroup>
<Midl Include="TestComponentCSharp.idl" />
Expand Down
18 changes: 18 additions & 0 deletions src/Tests/TestComponentCSharp/WinRT.Class.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "pch.h"
#include "WinRT.Class.h"
#include "WinRT.Class.g.cpp"

namespace winrt::TestComponentCSharp::WinRT::implementation
{
void Class::StaticMethod()
{
}

void Class::Method()
{
}

void Class::Method2(winrt::Windows::Foundation::IStringable const& stringable)
{
}
}
20 changes: 20 additions & 0 deletions src/Tests/TestComponentCSharp/WinRT.Class.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include "WinRT.Class.g.h"

namespace winrt::TestComponentCSharp::WinRT::implementation
{
struct Class : ClassT<Class>
{
Class() = default;

static void StaticMethod();
void Method();
void Method2(winrt::Windows::Foundation::IStringable const& stringable);
};
}
namespace winrt::TestComponentCSharp::WinRT::factory_implementation
{
struct Class : ClassT<Class, implementation::Class>
{
};
}
2 changes: 1 addition & 1 deletion src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2074,7 +2074,7 @@ ComWrappersSupport.RegisterObjectForInterface(this, ThisPtr);
auto objrefname = w.write_temp("%", bind<write_objref_type_name>(class_type));

w.write(R"(
public %() : this(%(WinRT.IActivationFactoryMethods.ActivateInstance<IUnknownVftbl>(%)))
public %() : this(%(global::WinRT.IActivationFactoryMethods.ActivateInstance<IUnknownVftbl>(%)))
{
ComWrappersSupport.RegisterObjectForInterface(this, ThisPtr);
%
Expand Down

0 comments on commit 174ccbf

Please sign in to comment.