diff --git a/strings/base_marshaler.h b/strings/base_marshaler.h index 9be6959c9..526f4d4c3 100644 --- a/strings/base_marshaler.h +++ b/strings/base_marshaler.h @@ -1,5 +1,5 @@ -WINRT_EXPORT namespace winrt::impl +namespace winrt::impl { inline std::int32_t make_marshaler(unknown_abi* outer, void** result) noexcept { diff --git a/test/test_cpp20_module/marshal.cpp b/test/test_cpp20_module/marshal.cpp new file mode 100644 index 000000000..8024b2413 --- /dev/null +++ b/test/test_cpp20_module/marshal.cpp @@ -0,0 +1,24 @@ +#include "pch.h" +#include + +import std; +import winrt.Windows.Foundation.Collections; + +using namespace winrt; + +struct S : implements +{ + hstring ToString() + { + return L"S"; + } +}; + +// When winrt::impl::get_marshaler was being exported, an MSVC bug caused the marshaler +// object to have a null vtable, which caused a crash when calling any method on the marshaler. +// This test ensures that the marshaler vtable is properly initialized. +TEST_CASE("IMarshal") +{ + auto s = make(); + auto marshal = s.as(); +} diff --git a/test/test_cpp20_module/test_cpp20_module.vcxproj b/test/test_cpp20_module/test_cpp20_module.vcxproj index 1e76c487b..f5c20a35d 100644 --- a/test/test_cpp20_module/test_cpp20_module.vcxproj +++ b/test/test_cpp20_module/test_cpp20_module.vcxproj @@ -25,7 +25,8 @@ Release x64 - + + 16.0 {B8E3A5CE-4E91-4F27-9B02-E0CAF7E10D72} test_cpp20_module @@ -91,6 +92,7 @@ + Create