Repository: microsoft/terminal
File: src/cascadia/TerminalApp/AboutDialog.cpp (C++)

Code before:
        if (!IsPackaged())
        {
            co_return;
        }

        co_await wil::resume_foreground(strongThis->Dispatcher());
        _SetPendingUpdateVersion({});
        CheckingForUpdates(true);

        try
        {
#ifdef WT_BRANDING_DEV
            // **DEV BRANDING**: Always sleep for three seconds and then report that
            // there is an update available. This lets us test the system.
            co_await winrt::resume_after(std::chrono::seconds{ 3 });
            co_await wil::resume_foreground(strongThis->Dispatcher());
            _SetPendingUpdateVersion(L"X.Y.Z");
#else // release build, likely has a store context
            if (auto storeContext{ winrt::Windows::Services::Store::StoreContext::GetDefault() })
            {
                auto updates = co_await storeContext.GetAppAndOptionalStorePackageUpdatesAsync();
                co_await wil::resume_foreground(strongThis->Dispatcher());
                if (updates.Size() > 0)
                {
                    auto version = updates.GetAt(0).Package().Id().Version();
                    _SetPendingUpdateVersion(fmt::format(L"{0}.{1}.{2}", version.Major, version.Minor, version.Revision));
                }
            }
#endif
        }
        catch (...)
        {
            // do nothing on failure
        }

        co_await wil::resume_foreground(strongThis->Dispatcher());
        CheckingForUpdates(false);
    }
}


Review comment (suggestion):
FYI this doesn't compile, because `std::wstring` and `winrt::hstring` aren't implicitly convertible.

Code after:
        if (!IsPackaged())
        {
            co_return;
        }

        co_await wil::resume_foreground(strongThis->Dispatcher());
        _SetPendingUpdateVersion({});
        CheckingForUpdates(true);

        try
        {
#ifdef WT_BRANDING_DEV
            // **DEV BRANDING**: Always sleep for three seconds and then report that
            // there is an update available. This lets us test the system.
            co_await winrt::resume_after(std::chrono::seconds{ 3 });
            co_await wil::resume_foreground(strongThis->Dispatcher());
            _SetPendingUpdateVersion(L"X.Y.Z");
#else // release build, likely has a store context
            if (auto storeContext{ winrt::Windows::Services::Store::StoreContext::GetDefault() })
            {
                const auto updates = co_await storeContext.GetAppAndOptionalStorePackageUpdatesAsync();
                co_await wil::resume_foreground(strongThis->Dispatcher());
                const auto numUpdates = updates.Size();
                if (numUpdates > 0)
                {
                    const auto update = updates.GetAt(0);
                    const auto version = update.Package().Id().Version();
                    const auto str = fmt::format(FMT_COMPILE(L"{}.{}.{}"), version.Major, version.Minor, version.Build);
                    _SetPendingUpdateVersion(winrt::hstring{ str });
                }
            }
#endif
        }
        catch (...)
        {
            // do nothing on failure
        }

        co_await wil::resume_foreground(strongThis->Dispatcher());
        CheckingForUpdates(false);
    }
}