Repository: microsoft/PowerToys
File: src/modules/Workspaces/WorkspacesLib/AppUtils.cpp (C++)

Code before:
                            }
                            else
                            {
                                CComHeapPtr<wchar_t> propVariantString;
                                propVariantString.Allocate(512);
                                PropVariantToString(pv, propVariantString, 512);

                                if (prop == NonLocalizable::PackageFullNameProp)
                                {
                                    data.packageFullName = propVariantString.m_pData;
                                }
                                else if (prop == NonLocalizable::AppUserModelIdProp)
                                {
                                    data.appUserModelId = propVariantString.m_pData;
                                }
                                else if (prop == NonLocalizable::PackageInstallPathProp || prop == NonLocalizable::InstallPathProp)
                                {
                                    data.installPath = propVariantString.m_pData;

                                    if (!data.installPath.empty())
                                    {
                                        const bool isSteamProtocol = data.installPath.rfind(NonLocalizable::SteamUrlProtocol, 0) == 0;

                                        if (isSteamProtocol)
                                        {
                                            Logger::info(L"Found steam game: {}", data.installPath);
                                            data.protocolPath = data.installPath;

                                            try
                                            {
                                                auto gameId = Steam::GetGameIdFromUrlProtocolPath(data.installPath);
                                                auto gameFolder = Steam::GetSteamGameInfoFromAcfFile(gameId);

                                                if (gameFolder)
                                                {
                                                    Logger::info(L"Found steam game: {}", data.installPath);
                                                    data.installPath = gameFolder->gameInstallationPath;
                                                }
                                            }
                                            catch (std::exception ex)
                                            {
                                                Logger::error(L"Failed to get installPath for game {}", data.installPath);
                                                Logger::error("Error: {}", ex.what());
                                            }
                                        }
                                    }
                                }
                            }

                            PropVariantClear(&pv);
                        }

Review comment (bug):
Just minor comment: Probably this logging can be debug only? (Since exception will log it)
You can make decision to keep this one or the if gameFolder one later on as "log as info".


Code after:
                            }
                            else
                            {
                                CComHeapPtr<wchar_t> propVariantString;
                                propVariantString.Allocate(512);
                                PropVariantToString(pv, propVariantString, 512);

                                if (prop == NonLocalizable::PackageFullNameProp)
                                {
                                    data.packageFullName = propVariantString.m_pData;
                                }
                                else if (prop == NonLocalizable::AppUserModelIdProp)
                                {
                                    data.appUserModelId = propVariantString.m_pData;
                                }
                                else if (prop == NonLocalizable::PackageInstallPathProp || prop == NonLocalizable::InstallPathProp)
                                {
                                    data.installPath = propVariantString.m_pData;

                                    if (!data.installPath.empty())
                                    {
                                        const bool isSteamProtocol = data.installPath.rfind(NonLocalizable::SteamUrlProtocol, 0) == 0;

                                        if (isSteamProtocol)
                                        {
                                            Logger::info(L"Found steam game: protocol path: {}", data.installPath);
                                            data.protocolPath = data.installPath;

                                            try
                                            {
                                                auto gameId = Steam::GetGameIdFromUrlProtocolPath(data.installPath);
                                                auto gameFolder = Steam::GetSteamGameInfoFromAcfFile(gameId);

                                                if (gameFolder)
                                                {
                                                    data.installPath = gameFolder->gameInstallationPath;
                                                    Logger::info(L"Found steam game: physical path: {}", data.installPath);
                                                }
                                            }
                                            catch (std::exception ex)
                                            {
                                                Logger::error(L"Failed to get installPath for game {}", data.installPath);
                                                Logger::error("Error: {}", ex.what());
                                            }
                                        }
                                    }
                                }
                            }

                            PropVariantClear(&pv);
                        }