Skip to content

Commit

Permalink
Addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AmelBawa-msft committed Dec 12, 2024
1 parent bdf8c90 commit dee65a9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/AppInstallerCommonCore/Experiment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ namespace AppInstaller::Settings
{
ExperimentState GetExperimentStateInternal(Experiment::Key key, const UserSettings& userSettings)
{
if (key == Experiment::Key::None)
{
return { true, ExperimentToggleSource::Default };
}

auto experiment = Experiment::GetExperiment(key);
if (!GroupPolicies().IsEnabled(TogglePolicy::Policy::Experiments))
{
AICLI_LOG(Core, Info, << "Experiment " << experiment.Name() <<
AICLI_LOG(Core, Info, << "Experiment " << Experiment::GetExperiment(key).Name() <<
" is disabled due to group policy: " << TogglePolicy::GetPolicy(TogglePolicy::Policy::Experiments).RegValueName());
return { false, ExperimentToggleSource::Policy };
}

if (key == Experiment::Key::None)
{
return { false, ExperimentToggleSource::Default };
}

auto experiment = Experiment::GetExperiment(key);
auto userSettingsExperiments = userSettings.Get<Setting::Experiments>();
auto jsonName = std::string(experiment.JsonName());
if (userSettingsExperiments.find(jsonName) != userSettingsExperiments.end())
Expand Down Expand Up @@ -80,7 +80,7 @@ namespace AppInstaller::Settings
switch (key)
{
case Key::CDN:
return Experiment{ "CDN experiment", "CDN", "https://aka.ms/winget-settings", "CDN"};
return Experiment{ "winget source CDN experiment", "CDN", "https://aka.ms/winget-settings", "CDN"};
#ifndef AICLI_DISABLE_TEST_HOOKS
case Key::TestExperiment:
return Experiment{ "Test experiment", "TestExperiment", "https://aka.ms/winget-settings", "TestExperiment" };
Expand Down
12 changes: 6 additions & 6 deletions src/AppInstallerCommonCore/Public/winget/Experiment.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ namespace AppInstaller::Settings

using Key_t = std::underlying_type_t<Key>;

Experiment(std::string_view name, std::string_view jsonName, std::string_view link, std::string key) :
m_name(name), m_jsonName(jsonName), m_link(link), m_key(key) {}
Experiment(std::string name, std::string jsonName, std::string link, std::string key) :
m_name(std::move(name)), m_jsonName(jsonName), m_link(std::move(link)), m_key(std::move((key))) {}

static ExperimentState GetState(Key feature);
static ExperimentState GetStateInternal(Key feature);
static Experiment GetExperiment(Key key);
static std::vector<Experiment> GetAllExperiments();

std::string_view Name() const { return m_name; }
std::string Name() const { return m_name; }
Utility::LocIndView JsonName() const { return m_jsonName; }
std::string_view Link() const { return m_link; }
std::string Link() const { return m_link; }
std::string GetKey() const { return m_key; }

private:
std::string_view m_name;
std::string m_name;
Utility::LocIndView m_jsonName;
std::string_view m_link;
std::string m_link;
std::string m_key;
};
}
5 changes: 3 additions & 2 deletions src/AppInstallerSharedLib/JsonUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ namespace AppInstaller::JSON
{
for (const auto& entry : node.getMemberNames())
{
if (node[entry].isBool())
auto& value = node[entry];
if (value.isBool())
{
result[entry] = node[entry].asBool();
result[entry] = value.asBool();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerSharedLib/Public/winget/JsonUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace AppInstaller::JSON
std::optional<std::vector<std::string>> GetValue<std::vector<std::string>>(const Json::Value& node);

template<>
std::optional<std::map<std::string, bool>> GetValue(const Json::Value& node);
std::optional<std::map<std::string, bool>> GetValue<std::map<std::string, bool>>(const Json::Value& node);

#ifndef WINGET_DISABLE_FOR_FUZZING
// For cpprestsdk JSON
Expand Down

0 comments on commit dee65a9

Please sign in to comment.