From 395add97f29e36839878ae93ce54c1a550325ddd Mon Sep 17 00:00:00 2001 From: Raymond Chen Date: Fri, 23 Apr 2021 16:15:36 -0700 Subject: [PATCH 1/3] Runtime class name for bare IInspectable should not be "Object" This tickles an edge case in the metadata-based marshaller. Use an empty string instead. --- strings/base_implements.h | 9 +++++++++ .../UnitTests/IInspectable_GetRuntimeClassName.cpp | 2 +- test/old_tests/UnitTests/produce.cpp | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/strings/base_implements.h b/strings/base_implements.h index bc44b27f6..a763da424 100644 --- a/strings/base_implements.h +++ b/strings/base_implements.h @@ -430,6 +430,15 @@ namespace winrt::impl } }; + template <> + struct runtime_class_name + { + static hstring get() + { + return {}; + } + }; + template struct producer { diff --git a/test/old_tests/UnitTests/IInspectable_GetRuntimeClassName.cpp b/test/old_tests/UnitTests/IInspectable_GetRuntimeClassName.cpp index 6b0d7550b..7db7ed869 100644 --- a/test/old_tests/UnitTests/IInspectable_GetRuntimeClassName.cpp +++ b/test/old_tests/UnitTests/IInspectable_GetRuntimeClassName.cpp @@ -28,7 +28,7 @@ TEST_CASE("Test_GetRuntimeClassName_NoOverride") { Windows::Foundation::IInspectable i = make(); - REQUIRE(get_class_name(i) == L"Object"); + REQUIRE(get_class_name(i) == L""); } TEST_CASE("Test_GetRuntimeClassName_Override") diff --git a/test/old_tests/UnitTests/produce.cpp b/test/old_tests/UnitTests/produce.cpp index 5ceab4d0c..403f0df2b 100644 --- a/test/old_tests/UnitTests/produce.cpp +++ b/test/old_tests/UnitTests/produce.cpp @@ -133,7 +133,7 @@ struct produce_IInspectable_RuntimeClassName : implements(); - REQUIRE(get_class_name(without) == L"Object"); + REQUIRE(get_class_name(without) == L""); Windows::Foundation::IInspectable with = make(); REQUIRE(get_class_name(with) == L"produce_IInspectable_RuntimeClassName"); From bc2ca361b6a3d60c8d550306fd9d4f3970304e7e Mon Sep 17 00:00:00 2001 From: Raymond Chen Date: Fri, 23 Apr 2021 16:53:19 -0700 Subject: [PATCH 2/3] Verify that we didn't disturb IID generation or name generation --- test/old_tests/UnitTests/constexpr.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/old_tests/UnitTests/constexpr.cpp b/test/old_tests/UnitTests/constexpr.cpp index 22478af2f..ea1d078e5 100644 --- a/test/old_tests/UnitTests/constexpr.cpp +++ b/test/old_tests/UnitTests/constexpr.cpp @@ -35,6 +35,7 @@ TEST_CASE("constexpr") REQUIRE(winrt::guid_of() == winrt::guid(__uuidof(::IInspectable))); REQUIRE(winrt::guid_of() == winrt::guid(__uuidof(midl_container))); REQUIRE(winrt::name_of() == L"Object"sv); + REQUIRE(winrt::name_of>() == L"Windows.Foundation.IAsyncOperation`1"); REQUIRE(winrt::name_of() == midl_container::z_get_rc_name_impl()); From 5b89a53e93556a01d36536b3264acd1636d1ce3b Mon Sep 17 00:00:00 2001 From: Raymond Chen Date: Fri, 23 Apr 2021 20:30:40 -0700 Subject: [PATCH 3/3] Ensure comparison is as wstring_view objects --- test/old_tests/UnitTests/constexpr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/old_tests/UnitTests/constexpr.cpp b/test/old_tests/UnitTests/constexpr.cpp index ea1d078e5..a881a2659 100644 --- a/test/old_tests/UnitTests/constexpr.cpp +++ b/test/old_tests/UnitTests/constexpr.cpp @@ -35,7 +35,7 @@ TEST_CASE("constexpr") REQUIRE(winrt::guid_of() == winrt::guid(__uuidof(::IInspectable))); REQUIRE(winrt::guid_of() == winrt::guid(__uuidof(midl_container))); REQUIRE(winrt::name_of() == L"Object"sv); - REQUIRE(winrt::name_of>() == L"Windows.Foundation.IAsyncOperation`1"); + REQUIRE(winrt::name_of>() == L"Windows.Foundation.IAsyncOperation`1"sv); REQUIRE(winrt::name_of() == midl_container::z_get_rc_name_impl());