tsm: use the much cheaper & non-async 26100 AppExtension APIs when possible (#20356)

GetPublicPath doesn't require async _or_ Windows.Storage! FindAll is
just the Sync version of FindAllAsync!
This commit is contained in:
Dustin L. Howett
2026-06-23 18:00:46 -05:00
committed by GitHub
parent 8824b02a78
commit d0263b86ac

View File

@@ -395,7 +395,14 @@ void SettingsLoader::FindFragmentsAndMergeIntoUserSettings(bool generateExtensio
try try
{ {
const auto catalog = AppExtensionCatalog::Open(AppExtensionHostName); const auto catalog = AppExtensionCatalog::Open(AppExtensionHostName);
extensions = extractValueFromTaskWithoutMainThreadAwait(catalog.FindAllAsync()); if (auto catalog2{ catalog.try_as<IAppExtensionCatalog2>() })
{
extensions = catalog2.FindAll();
}
else
{
extensions = extractValueFromTaskWithoutMainThreadAwait(catalog.FindAllAsync());
}
} }
CATCH_LOG(); CATCH_LOG();
@@ -417,20 +424,37 @@ void SettingsLoader::FindFragmentsAndMergeIntoUserSettings(bool generateExtensio
continue; continue;
} }
// Likewise, getting the public folder from an extension is an async operation. winrt::hstring publicFolderPath;
auto foundFolder = extractValueFromTaskWithoutMainThreadAwait(ext.GetPublicFolderAsync()); if (auto ext3{ ext.try_as<IAppExtension3>() })
if (!foundFolder)
{ {
continue; // Windows 11 24H2 and above support a much faster, much less
// Windows.Storage-y API.
publicFolderPath = ext3.GetPublicPath();
if (publicFolderPath.empty())
{
// No point in falling through to GetPublicFolderAsync;
// it won't work.
continue;
}
}
else
{
// Likewise, getting the public folder from an extension is an async operation.
auto foundFolder = extractValueFromTaskWithoutMainThreadAwait(ext.GetPublicFolderAsync());
if (!foundFolder)
{
continue;
}
// the StorageFolder class has its own methods for obtaining the files within the folder
// however, all those methods are Async methods
// you may have noticed that we need to resort to clunky implementations for async operations
// (they are in extractValueFromTaskWithoutMainThreadAwait)
// so for now we will just take the folder path and access the files that way
publicFolderPath = foundFolder.Path();
} }
// the StorageFolder class has its own methods for obtaining the files within the folder const auto path = buildPath(publicFolderPath, FragmentsSubDirectory);
// however, all those methods are Async methods
// you may have noticed that we need to resort to clunky implementations for async operations
// (they are in extractValueFromTaskWithoutMainThreadAwait)
// so for now we will just take the folder path and access the files that way
const auto path = buildPath(foundFolder.Path(), FragmentsSubDirectory);
if (std::filesystem::is_directory(path)) if (std::filesystem::is_directory(path))
{ {
// MSIX does not support machine-wide scope // MSIX does not support machine-wide scope