Skip to content

Commit 58f6e32

Browse files
committed
Swap to v3 user settings, don't use statics (or strings) when cheaper things will do
1 parent 0ff8521 commit 58f6e32

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

src/AppInstallerCLICore/Workflows/ConfigurationFlow.cpp

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,32 @@ namespace AppInstaller::CLI::Workflow
6666
struct PredefinedResource
6767
{
6868
// RequiredModule could be empty, meaning no required modules needed.
69-
std::wstring RequiredModule;
69+
std::wstring_view RequiredModule;
7070

71-
std::vector<std::wstring> UnitTypes;
71+
std::vector<std::wstring_view> UnitTypes;
7272
};
7373

74-
static const PredefinedResource s_PredefinedResourcesForExport[] = {
75-
{ std::wstring{ s_Module_WinGetClient }, { L"Microsoft.WinGet.DSC/WinGetUserSettings" } },
76-
{ L"Microsoft.Windows.Developer", { L"Microsoft.Windows.Developer/DeveloperMode", L"Microsoft.Windows.Developer/EnableDarkMode", L"Microsoft.Windows.Developer/ShowSecondsInClock", L"Microsoft.Windows.Developer/Taskbar", L"Microsoft.Windows.Developer/WindowsExplorer" }},
77-
};
74+
std::vector<PredefinedResource> PredefinedResourcesForExport()
75+
{
76+
return {
77+
{ {}, { L"Microsoft.WinGet/UserSettingsFile" } },
78+
{ L"Microsoft.Windows.Developer", { L"Microsoft.Windows.Developer/DeveloperMode", L"Microsoft.Windows.Developer/EnableDarkMode", L"Microsoft.Windows.Developer/ShowSecondsInClock", L"Microsoft.Windows.Developer/Taskbar", L"Microsoft.Windows.Developer/WindowsExplorer" } },
79+
};
80+
}
7881

79-
static const std::wstring s_PackageSettingsExclusionList[] = {
80-
L"Microsoft.WinGet/", L"Microsoft.DSC.Debug/", L"Microsoft.DSC/", L"Microsoft.DSC.Transitional/", L"Microsoft.Windows/RebootPending",
81-
L"Microsoft.Windows/Registry", L"Microsoft.Windows/WMI", L"Microsoft.Windows/WindowsPowerShell", L"Microsoft/OSInfo"
82+
std::vector<std::wstring_view> PackageSettingsExclusionList()
83+
{
84+
return {
85+
L"Microsoft.WinGet/",
86+
L"Microsoft.DSC.Debug/",
87+
L"Microsoft.DSC/",
88+
L"Microsoft.DSC.Transitional/",
89+
L"Microsoft.Windows/RebootPending",
90+
L"Microsoft.Windows/Registry",
91+
L"Microsoft.Windows/WMI",
92+
L"Microsoft.Windows/WindowsPowerShell",
93+
L"Microsoft/OSInfo"
94+
};
8295
};
8396

8497
Logging::Level ConvertLevel(DiagnosticLevel level)
@@ -1475,7 +1488,7 @@ namespace AppInstaller::CLI::Workflow
14751488
{
14761489
ConfigurationContext& configContext = context.Get<Data::ConfigurationContext>();
14771490

1478-
for (const auto& resources : s_PredefinedResourcesForExport)
1491+
for (const auto& resources : PredefinedResourcesForExport())
14791492
{
14801493
std::optional<ConfigurationUnit> requiredModuleUnit;
14811494

@@ -1538,11 +1551,13 @@ namespace AppInstaller::CLI::Workflow
15381551
context.Reporter.Warn() << Resource::String::ConfigurationExportFailedToGetUnitProcessors << std::endl;
15391552
}
15401553

1554+
auto exclusionList = PackageSettingsExclusionList();
1555+
15411556
// Filter out processors in exclusion list.
15421557
for (auto itr = unitProcessors.begin(); itr != unitProcessors.end(); /* itr incremented in the logic */)
15431558
{
15441559
bool processorRemoved = false;
1545-
for (const auto& exclusionItem : anon::s_PackageSettingsExclusionList)
1560+
for (const auto& exclusionItem : exclusionList)
15461561
{
15471562
if (Utility::CaseInsensitiveStartsWith(itr->UnitType(), exclusionItem))
15481563
{

0 commit comments

Comments
 (0)