Closed asklar closed 2 weeks ago
One option is to not add these helpers to wil which would remove the dependency on wil altogether, which is goodness. Instead, we could have a winappsdk/winiu3-specific header in windowsappsdk that you can bring in to your C++ app.
Yes. Totally that. This should be built-in and follow with the SDK they are there to support (which would have avoided this mess in the first place). It used to be built-in.
@oldnewthing is fixing this in wil in microsoft/wil#214
What do you mean "fixing this in wil"? Will this be included in the WAS/MUX headers/metadata? Or are we all stuck now ingesting the entirety of wil? (Microsoft.UI.Xaml.winmd
describes a [Microsoft.UI]Microsoft.UI.Dispatching.DispatcherQueue
)
@riverar Good point. I'll make it so that cppwinrt_helpers.h
has no dependencies on any other part of wil, so it's a freestanding header. You don't have to ingest any other part of wil.
Sounds good, although am curious what Microsoft.UI.Xaml.winmd
will point to (for the DispatcherQueue type) after everything is said/done.
The winmd has no dependency on anything C++ specific, it's just WinRT type metadata. C++ projects will have to reference the wil nuget, and consume the header that Raymond is adding the definitions to.
The winmd has no dependency on anything C++ specific
The WinAppSDK package includes a set of header files. that automatically gets referenced. It would IMHO have made more sense including this there - after all we didn't need WIL in the earlier sdk builds but suddenly that's yet another dependency we need to pull in.
Not sure what I'm missing to see the benefit of moving some of the WinUI specific stuff away from the WinUI specific SDK
I'll open a separate issue as it's not directly related to this.
The old WindowsAppSDK contained custom headers that injected a resume_foreground
into the winrt
namespace, which was a violation of the C++/WinRT naming convention. Meanwhile, wil
had a replacement resume_foreground
that addressed many of the defects in the winrt::resume_foreground
. In theory we could have duplicated them here (in a presumably new third namespace?), but then you run into the problem of keeping the two versions in sync.
Basically, resume_foreground
is not a feature of the DispatcherQueue itself, but rather a new feature built on top of the DispatcherQueue. That new feature is implemented by WIL. (C++/WinRT learned the hard way that building features on top of Windows Runtime objects is a slippery slope, and has realized that it's better to leave the higher-order features to other libraries. "Do one thing well, don't try to do everything.")
@oldnewthing Thanks for the detailed answer. Much appreciated. Although I don't like the developer experience this creates, it does make a lot of sense
I believe the only thing missing now is updating the release notes so they point to the new header / guidance. Tagging @zaryaf here too for that : )
If you want to co_await on the DispatcherQueue.TryEnqueue method, use the resume_foreground helper function in the Windows Implementation Library (WIL):
Add a reference to Microsoft.Windows.ImplementationLibrary NuGet package. Add the #include <wil/cppwinrt.h> statement to your code file. Use wil::resume_foreground(your_dispatcher); to co_await the result.
@zaryaf The header is now <wil/cppwinrt_helpers.h>
. You must include it after you include <winrt/Microsoft.UI.Dispatching.h>
.
Close this stale issue.
See microsoft/wil#213 - filing here to track
The code was removed when syncing with the OS copy of wil since it conflicted with some WRL names.
@dunhor @jevansaks FYI