Repository: microsoft/terminal
File: src/types/TermControlUiaProvider.cpp (C++)

Code before:
using namespace Microsoft::WRL;

#pragma warning(suppress : 26434) // WRL RuntimeClassInitialize base is a no-op and we need this for MakeAndInitialize
HRESULT TermControlUiaProvider::RuntimeClassInitialize(_In_ ::Microsoft::Console::Types::IUiaData* const uiaData,
                                                       _In_ ::Microsoft::Console::Types::IControlAccessibilityInfo* controlInfo) noexcept
{
    RETURN_HR_IF_NULL(E_INVALIDARG, uiaData);
    RETURN_IF_FAILED(ScreenInfoUiaProviderBase::RuntimeClassInitialize(uiaData));

    _controlInfo = controlInfo;
    return S_OK;
}

// Implementation of IRawElementProviderSimple::get_PropertyValue.
// Gets custom properties.
IFACEMETHODIMP TermControlUiaProvider::GetPropertyValue(_In_ PROPERTYID propertyId,
                                                        _Out_ VARIANT* pVariant) noexcept
{
    pVariant->vt = VT_EMPTY;

    // Returning the default will leave the property as the default
    // so we only really need to touch it for the properties we want to implement
    if (propertyId == UIA_ClassNamePropertyId)
    {
        pVariant->bstrVal = SysAllocString(L"TermControl");
        if (pVariant->bstrVal != nullptr)
        {
            pVariant->vt = VT_BSTR;
        }
    }
    else if (propertyId == UIA_ControlTypePropertyId)
    {
        pVariant->vt = VT_I4;
        pVariant->lVal = UIA_TextControlTypeId;
    }
    else if (propertyId == UIA_LocalizedControlTypePropertyId)
    {
        // TODO: we should use RS_(L"TerminalControl_ControlType"),
        // but that's exposed/defined in the TermControl project
        pVariant->bstrVal = SysAllocString(L"terminal");
        if (pVariant->bstrVal != nullptr)
        {
            pVariant->vt = VT_BSTR;
        }
    }
    else if (propertyId == UIA_OrientationPropertyId)
    {
        pVariant->vt = VT_I4;
        pVariant->lVal = OrientationType_Vertical;
    }
    else if (propertyId == UIA_LiveSettingPropertyId)

Review comment (suggestion):
Assuming this only applies in the WPF control:

```suggestion
        pVariant->bstrVal = SysAllocString(L"WPFTermControl");

```

Code after:
using namespace Microsoft::WRL;

#pragma warning(suppress : 26434) // WRL RuntimeClassInitialize base is a no-op and we need this for MakeAndInitialize
HRESULT TermControlUiaProvider::RuntimeClassInitialize(_In_ ::Microsoft::Console::Types::IUiaData* const uiaData,
                                                       _In_ ::Microsoft::Console::Types::IControlAccessibilityInfo* controlInfo) noexcept
{
    RETURN_HR_IF_NULL(E_INVALIDARG, uiaData);
    RETURN_IF_FAILED(ScreenInfoUiaProviderBase::RuntimeClassInitialize(uiaData));

    _controlInfo = controlInfo;
    return S_OK;
}

// Implementation of IRawElementProviderSimple::get_PropertyValue.
// Gets custom properties.
IFACEMETHODIMP TermControlUiaProvider::GetPropertyValue(_In_ PROPERTYID propertyId,
                                                        _Out_ VARIANT* pVariant) noexcept
{
    pVariant->vt = VT_EMPTY;

    // Returning the default will leave the property as the default
    // so we only really need to touch it for the properties we want to implement
    switch (propertyId)
    {
    case UIA_ClassNamePropertyId:
        pVariant->bstrVal = SysAllocString(L"TermControl");
        if (pVariant->bstrVal != nullptr)
        {
            pVariant->vt = VT_BSTR;
        }
        break;
    case UIA_ControlTypePropertyId:
        pVariant->vt = VT_I4;
        pVariant->lVal = UIA_TextControlTypeId;
        break;
    case UIA_LocalizedControlTypePropertyId:
        // TODO: we should use RS_(L"TerminalControl_ControlType"),
        // but that's exposed/defined in the TermControl project
        pVariant->bstrVal = SysAllocString(L"terminal");
        if (pVariant->bstrVal != nullptr)
        {
            pVariant->vt = VT_BSTR;
        }
        break;
    case UIA_OrientationPropertyId:
        pVariant->vt = VT_I4;
        pVariant->lVal = OrientationType_Vertical;
        break;
    case UIA_LiveSettingPropertyId:
        pVariant->vt = VT_I4;
        pVariant->lVal = LiveSetting::Polite;