microsoft / cppwinrt

C++/WinRT
MIT License
1.64k stars 236 forks source link

winrt::impl::reference::Get(T) functions should cast safely #1362

Closed JaiganeshKumaran closed 10 months ago

JaiganeshKumaran commented 11 months ago

Currently winrt::impl::reference::Get(T) functions simply use a static_cast, which can narrow. This behaviour is inconsistent from the built-in PropertyValue objects returned by various PropertyValue::Create(T) methods, where they throw an exception in case a conversion could not be done.

JaiganeshKumaran commented 11 months ago

Another thing, winrt::impl::reference (mainly used for enums), throws hresult_not_implemented for GetSingle and GetDouble, while the built-in ones for integers do not.

kennykerr commented 11 months ago

I've tagged a few project maintainers. If one of them is available to offer guidance and mentorship for this issue, they will reach out according to the contributing guide to discuss and agree on an approach.

@microsoft/cppwinrt-maintainers

Related to #1347. Mainly this functionality exists to make Xaml happy, and this implementation has been sufficient for Xaml for some time so I'd be reluctant to mess with it now.

github-actions[bot] commented 10 months ago

This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days.