Skip to content

Bug: Ambiguous reference for winrt::Microsoft::Windows::ApplicationModel.Background::UniversalBGTask::Task::Run #1485

@dlech

Description

@dlech

Version

2.0.240111.5

Summary

I have a feeling that this is perhaps an API bug, but CppWinRT could be made to work around it. A new class added in Windows App SDK 1.7 has an explicit interface implementation (in C# terms) that isn't seen in other APIs and doesn't seem to follow the WinRT type system guidelines.

This causes CppWinRT to generate multiple Run methods. One for the public interface and another for the explicit interface implementation that should actually be private and therefore not projected.

https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.windows.applicationmodel.background.universalbgtask.task?view=windows-app-sdk-1.7

Reproducible example

It will take some time to make a minimal test case.

Expected behavior

CppWinRT should not generate ambiguous methods.

Actual behavior

Code fails to compile with error.

Additional comments

Here is the actual compiler error.

C:\Users\extra\work\pywinrt\projection\winui3\winui3-Microsoft.Windows.ApplicationModel.Background.Univer
salBGTask\py.Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.cpp(71,31): error C2668: 'winr 
t::impl::consume_Windows_ApplicationModel_Background_IBackgroundTask<D>::Run': ambiguous call to overload
ed function [C:\Users\extra\work\pywinrt\_build\release\_winui3_microsoft_windows_applicationmodel_backgr 
ound_universalbgtask.vcxproj]
C:\Users\extra\work\pywinrt\projection\winui3\winui3-Microsoft.Windows.ApplicationModel.Background.Univer
salBGTask\py.Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.cpp(71,31): error C2668:       
   with [C:\Users\extra\work\pywinrt\_build\release\_winui3_microsoft_windows_applicationmodel_background
_universalbgtask.vcxproj]
C:\Users\extra\work\pywinrt\projection\winui3\winui3-Microsoft.Windows.ApplicationModel.Background.Univer 
salBGTask\py.Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.cpp(71,31): error C2668:       
   [ [C:\Users\extra\work\pywinrt\_build\release\_winui3_microsoft_windows_applicationmodel_background_un
iversalbgtask.vcxproj]
C:\Users\extra\work\pywinrt\projection\winui3\winui3-Microsoft.Windows.ApplicationModel.Background.Univer 
salBGTask\py.Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.cpp(71,31): error C2668:      
       D=winrt::Microsoft::Windows::ApplicationModel::Background::UniversalBGTask::Task [C:\Users\extra\w 
ork\pywinrt\_build\release\_winui3_microsoft_windows_applicationmodel_background_universalbgtask.vcxproj]
C:\Users\extra\work\pywinrt\projection\winui3\winui3-Microsoft.Windows.ApplicationModel.Background.Univer 
salBGTask\py.Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.cpp(71,31): error C2668:       
   ] [C:\Users\extra\work\pywinrt\_build\release\_winui3_microsoft_windows_applicationmodel_background_un 
iversalbgtask.vcxproj]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions