Примеры ошибок, обнаруженных с помощью диагностики V1114
V1114. Suspicious use of type conversion operator when working with COM interfaces. Consider using the 'QueryInterface' member function.
Windows Terminal
V1114 Suspicious use of 'static_cast' when working with COM interfaces. Consider using the 'QueryInterface' member function. uiaTextRange.cpp 84
namespace Microsoft::Console::Types
{
class ScreenInfoUiaProviderBase :
public WRL::RuntimeClass<
WRL::RuntimeClassFlags<WRL::ClassicCom | WRL::InhibitFtmBase>,
IRawElementProviderSimple,
IRawElementProviderFragment,
ITextProvider
>,
public IUiaTraceable
....
}
namespace Microsoft::Console::Interactivity::Win32
{
class ScreenInfoUiaProvider final :
public Microsoft::Console::Types::ScreenInfoUiaProviderBase
{
....
}
....
}
HWND UiaTextRange::_getWindowHandle() const
{
const auto provider = static_cast<ScreenInfoUiaProvider*>(_pProvider); // <=
return provider->GetWindowHandle();
}