I think there's a real bug but I don't know how to constructively articulate that really this whole space just feels like it sucks. The docs suck and the api is esoteric.
docs comment here: https://github.com/MicrosoftDocs/winrt-api/issues/2445
The bug:
Severity Code Description Project File Line Suppression State
Error C3779 'winrt::impl::consume_Windows_Foundation_IAsyncOperation<winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Devices::Enumeration::DeviceInformationCollection>,TResult>::get': a function that returns 'auto' cannot be used before it is defined ConsoleApplication1 C:\Users\Ryan\source\repos\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp 17
Reproducible example
#include <iostream>
#include <winrt/base.h>
#include <winrt/Windows.Graphics.Display.h>
#include <winrt/Windows.Devices.Enumeration.h>
#include <winrt/Windows.Devices.Display.Core.h>
using namespace winrt;
using namespace winrt::Windows::Graphics;
using namespace winrt::Windows::Devices::Display;
using namespace winrt::Windows::Devices::Enumeration;
int main()
{
init_apartment();
const auto monitorSelector = DisplayMonitor::GetDeviceSelector();
const auto devices = DeviceInformation::FindAllAsync(monitorSelector).get();
}
I'm just exhausted with the WinRT ecosystem. There seems to be literally no meaningful c++ examples for any of it. I don't know where I'm just wrong or things don't work.
That error indicates that you are missing a necessary #include statement. You need #include <winrt/Windows.Foundation.h> because IAsyncOperation is in the Windows::Foundation namespace.
Version
2.0.240111.5
Summary
I think there's a real bug but I don't know how to constructively articulate that really this whole space just feels like it sucks. The docs suck and the api is esoteric. docs comment here: https://github.com/MicrosoftDocs/winrt-api/issues/2445
The bug:
Reproducible example
Expected behavior
But it doesn't return auto? https://learn.microsoft.com/en-us/uwp/api/windows.devices.enumeration.deviceinformation.findallasync?view=winrt-22621
Actual behavior
This should just work?
Additional comments
I'm just exhausted with the WinRT ecosystem. There seems to be literally no meaningful c++ examples for any of it. I don't know where I'm just wrong or things don't work.