Version
2.0.250303.1
Summary
I'm struggling to understand the intended behavior of winrt::guid_of<T>(). The function appear to return the same value as __uuidof(T) for most types. However, it behaves very differently for classes inheriting winrt::implements<T...>, where it instead seem to return the interface ID GUID for the first interface in the winrt::implements template list.
I'm not sure if this is a bug or intended behavior, but it does at least seem to have caused a bug in wil::register_com_server (see microsoft/wil#533). I would therefore appreciate if the documentation could either be extended to clarify the behavior, or the behavior changed to avoid counter-intuitive surprises.
Reproducible example
structDECLSPEC_UUID("5fb96f8d-409c-42a9-99a7-8a95c1459dbd") ICapture : ::IUnknown {
...
};
structDECLSPEC_UUID("BABF401C-D3D2-4B68-8E1A-1F4177F3F49A") Capture : implements<Capture, ICapture, IStringable> {
...
};Expected behavior
__uuidof(Capture); // returns {BABF401C-D3D2-4B68-8E1A-1F4177F3F49A}
winrt::guid_of<Capture>(); // returns {BABF401C-D3D2-4B68-8E1A-1F4177F3F49A}Actual behavior
winrt::guid_of<ICapture>(); // returns {5fb96f8d-409c-42a9-99a7-8a95c1459dbd} as expected__uuidof(Capture); // returns {BABF401C-D3D2-4B68-8E1A-1F4177F3F49A} as expected
winrt::guid_of<Capture>(); // returns {5fb96f8d-409c-42a9-99a7-8a95c1459dbd} which was surprising to meAdditional comments
No response
Version
2.0.250303.1
Summary
I'm struggling to understand the intended behavior of
winrt::guid_of<T>(). The function appear to return the same value as__uuidof(T)for most types. However, it behaves very differently for classes inheritingwinrt::implements<T...>, where it instead seem to return the interface ID GUID for the first interface in the winrt::implements template list.I'm not sure if this is a bug or intended behavior, but it does at least seem to have caused a bug in
wil::register_com_server(see microsoft/wil#533). I would therefore appreciate if the documentation could either be extended to clarify the behavior, or the behavior changed to avoid counter-intuitive surprises.Reproducible example
Expected behavior
Actual behavior
Additional comments
No response