Skip to content

Commit

Permalink
Runtime class name for bare IInspectable should not be "Object" (#930)
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnewthing authored Apr 27, 2021
1 parent 342edc5 commit 18670d2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions strings/base_implements.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,15 @@ namespace winrt::impl
}
};

template <>
struct runtime_class_name<Windows::Foundation::IInspectable>
{
static hstring get()
{
return {};
}
};

template <typename D, typename I, typename Enable>
struct producer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ TEST_CASE("Test_GetRuntimeClassName_NoOverride")
{
Windows::Foundation::IInspectable i = make<Test_GetRuntimeClassName_NoOverride>();

REQUIRE(get_class_name(i) == L"Object");
REQUIRE(get_class_name(i) == L"");
}

TEST_CASE("Test_GetRuntimeClassName_Override")
Expand Down
1 change: 1 addition & 0 deletions test/old_tests/UnitTests/constexpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ TEST_CASE("constexpr")
REQUIRE(winrt::guid_of<winrt::IInspectable>() == winrt::guid(__uuidof(::IInspectable)));
REQUIRE(winrt::guid_of<winrt_container>() == winrt::guid(__uuidof(midl_container)));
REQUIRE(winrt::name_of<winrt::IInspectable>() == L"Object"sv);
REQUIRE(winrt::name_of<winrt::IAsyncOperation<winrt::IInspectable>>() == L"Windows.Foundation.IAsyncOperation`1<Object>"sv);

REQUIRE(winrt::name_of<winrt_container>() == midl_container::z_get_rc_name_impl());

Expand Down
2 changes: 1 addition & 1 deletion test/old_tests/UnitTests/produce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ struct produce_IInspectable_RuntimeClassName : implements<produce_IInspectable_R
TEST_CASE("produce_IInspectable_RuntimeClassName")
{
Windows::Foundation::IInspectable without = make<produce_IInspectable_No_RuntimeClassName>();
REQUIRE(get_class_name(without) == L"Object");
REQUIRE(get_class_name(without) == L"");

Windows::Foundation::IInspectable with = make<produce_IInspectable_RuntimeClassName>();
REQUIRE(get_class_name(with) == L"produce_IInspectable_RuntimeClassName");
Expand Down

0 comments on commit 18670d2

Please sign in to comment.