Inheriting from a XAML page within the same project fails to compile in C++/WinRT with /std:c++20
See original GitHub issueDescribe the bug
After upgrading to VS 17.0 Preview 2, inheriting from another XAML page within the same project results in a compile error when combined with /std:c++20
or /std:c++latest
Steps to reproduce the bug
Steps to reproduce the behavior:
- Create a new UWP project using C++/WinRT
- Set the langage version to C++ 20 or latest in project settings
- Make
MainPage
unsealed in the IDL - Create a new XAML page in the project (named
BlankPage
in the rest of these steps) - Remove or rename the
MyProperty
property fromBlankPage.cpp
,BlankPage.h
andBlankPage.idl
to avoid conflicts with the base class - Make that page inherit from
MainPage
from IDL:runtimeclass BlankPage : MainPage
(don’t forgetimport "MainPage.idl";
) - Add
#include "MainPage.h"
toBlankPage.h
- Update
BlankPage.xaml
to declare a root object of typelocal:MainPage
instead of Page - Compile the project
- Observe the
'to_abi': no matching overloaded function found
error
Expected behavior The code should compile correctly and run.
Screenshots
Version Info
NuGet package version: This issue happens whether WinUI 2 is used or not.
Windows app type:
UWP | Win32 |
---|---|
Yes | Yes (system XAML islands) |
Windows version | Saw the problem? |
---|---|
Insider Build (xxxxx) | |
October 2020 Update (19042) | Yes |
May 2020 Update (19041) | |
November 2019 Update (18363) | |
May 2019 Update (18362) | |
October 2018 Update (17763) | |
April 2018 Update (17134) | |
Fall Creators Update (16299) | |
Creators Update (15063) |
Device form factor | Saw the problem? |
---|---|
Desktop | Yes |
Xbox | |
Surface Hub | |
IoT |
Additional context This happens with the Windows SDK version 22000.100, I think it needs to use the v143 toolset as well.
Developer Community issue: https://developercommunity.visualstudio.com/t/Inheriting-from-a-XAML-page-within-the-s/1491603?entry=myfeedback
Sample repro project: BlankApp1.zip (edit 2020-08-02: updated the zip, I somehow managed to upload a zip attempting to use a cppwinrt version that didn’t exist on NuGet)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:12 (12 by maintainers)
Top GitHub Comments
for MS folks this is http://task.ms/35009721
I had to do a clean build to force the XAML codegen to trigger again, merely upgrading the SDK still used the old codegen - my bad! The issue is resolved now, thanks 😃