Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing global:: and add test case to avoid breaking in future. #1500

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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