Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create machinery for disabling experimental features #1490

Merged
merged 1 commit into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@
<PreprocessorDefinitions>AICLI_DISABLE_TEST_HOOKS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(WingetDisableExperimentalFeatures)'=='true'">
<ClCompile>
<PreprocessorDefinitions>WINGET_DISABLE_EXPERIMENTAL_FEATURES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Argument.h" />
<ClInclude Include="ChannelStreams.h" />
Expand Down
4 changes: 4 additions & 0 deletions src/AppInstallerCLICore/Commands/FeaturesCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ namespace AppInstaller::CLI

void FeaturesCommand::ExecuteInternal(Execution::Context& context) const
{
#ifdef WINGET_DISABLE_EXPERIMENTAL_FEATURES
context.Reporter.Info() << Resource::String::FeaturesMessageDisabledByBuild << std::endl;
#else
if (GroupPolicies().IsEnabled(TogglePolicy::Policy::ExperimentalFeatures) &&
GroupPolicies().IsEnabled(TogglePolicy::Policy::Settings))
{
Expand Down Expand Up @@ -61,5 +64,6 @@ namespace AppInstaller::CLI
// Better work hard to get some out there!
context.Reporter.Info() << Resource::String::NoExperimentalFeaturesMessage << std::endl;
}
#endif
}
}
6 changes: 3 additions & 3 deletions src/AppInstallerCLICore/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace AppInstaller::CLI

// Enable all logging for this phase; we will update once we have the arguments
Logging::Log().EnableChannel(Logging::Channel::All);
Logging::Log().SetLevel(Logging::Level::Verbose);
Logging::Log().SetLevel(Logging::Level::Info);
Logging::AddFileLogger();
Logging::EnableWilFailureTelemetry();

Expand Down Expand Up @@ -100,9 +100,9 @@ namespace AppInstaller::CLI
command->ParseArguments(invocation, context.Args);

// Change logging level to Info if Verbose not requested
if (!context.Args.Contains(Execution::Args::Type::VerboseLogs))
if (context.Args.Contains(Execution::Args::Type::VerboseLogs))
{
Logging::Log().SetLevel(Logging::Level::Info);
Logging::Log().SetLevel(Logging::Level::Verbose);
}

context.UpdateForArgs();
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(FeaturesFeature);
WINGET_DEFINE_RESOURCE_STRINGID(FeaturesLink);
WINGET_DEFINE_RESOURCE_STRINGID(FeaturesMessage);
WINGET_DEFINE_RESOURCE_STRINGID(FeaturesMessageDisabledByBuild);
WINGET_DEFINE_RESOURCE_STRINGID(FeaturesMessageDisabledByPolicy);
WINGET_DEFINE_RESOURCE_STRINGID(FeaturesProperty);
WINGET_DEFINE_RESOURCE_STRINGID(FeaturesStatus);
Expand Down
4 changes: 4 additions & 0 deletions src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1165,4 +1165,8 @@ Please specify one of them using the `--source` option to proceed.</value>
<data name="SearchFailureErrorNoMatches" xml:space="preserve">
<value>No packages were found among the working sources.</value>
</data>
<data name="FeaturesMessageDisabledByBuild" xml:space="preserve">
<value>This is a stable release of the Windows Package Manager. If you would like to try experimental features, please install a pre-release build. Instructions are available on GitHub at https://github.com/microsoft/winget-cli.</value>
<comment>{Locked="Windows Package Manager","GitHub","https://github.com/microsoft/winget-cli"}</comment>
</data>
</root>
5 changes: 5 additions & 0 deletions src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@
<PreprocessorDefinitions>AICLI_DISABLE_TEST_HOOKS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(WingetDisableExperimentalFeatures)'=='true'">
<ClCompile>
<PreprocessorDefinitions>WINGET_DISABLE_EXPERIMENTAL_FEATURES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="DODownloader.h" />
<ClInclude Include="Public\winget\AdminSettings.h" />
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCommonCore/ExperimentalFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ namespace AppInstaller::Settings
return true;
}

#ifdef WINGET_DISABLE_EXPERIMENTAL_FEATURES
UNREFERENCED_PARAMETER(userSettings);
return false;
#else

if (!GroupPolicies().IsEnabled(TogglePolicy::Policy::ExperimentalFeatures))
{
AICLI_LOG(Core, Info, <<
Expand All @@ -40,6 +45,7 @@ namespace AppInstaller::Settings
default:
THROW_HR(E_UNEXPECTED);
}
#endif
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCommonCore/GroupPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace AppInstaller::Settings
return std::nullopt;
}

AICLI_LOG(Core, Info, << "Found policy '" << valueName << "', Value: " << *intValue);
AICLI_LOG(Core, Verbose, << "Found policy '" << valueName << "', Value: " << *intValue);
return (bool)*intValue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCommonCore/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace AppInstaller::Settings

void LogSettingAction(std::string_view action, const StreamDefinition& def)
{
AICLI_LOG(Core, Info, << "Setting action: " << action << ", Type: " << ToString(def.Type) << ", Name: " << def.Path);
AICLI_LOG(Core, Verbose, << "Setting action: " << action << ", Type: " << ToString(def.Type) << ", Name: " << def.Path);
}

// A settings container.
Expand Down
8 changes: 4 additions & 4 deletions src/AppInstallerCommonCore/UserSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ namespace AppInstaller::Settings
// Add it to the map
settings[S].emplace<details::SettingIndex(S)>(
std::forward<typename details::SettingMapping<S>::value_t>(validatedValue.value()));
AICLI_LOG(Core, Info, << "Valid setting from Group Policy. Field: " << path << " Value: " << GetValueString(policyValue.value()));
AICLI_LOG(Core, Verbose, << "Valid setting from Group Policy. Field: " << path << " Value: " << GetValueString(policyValue.value()));
}
else
{
auto valueAsString = GetValueString(policyValue.value());
AICLI_LOG(Core, Info, << "Invalid setting from Group Policy. Field: " << path << " Value: " << valueAsString);
AICLI_LOG(Core, Error, << "Invalid setting from Group Policy. Field: " << path << " Value: " << valueAsString);
warnings.emplace_back(StringResource::String::SettingsWarningInvalidValueFromPolicy, path, valueAsString);
}

Expand All @@ -148,7 +148,7 @@ namespace AppInstaller::Settings
// Finally add it to the map
settings[S].emplace<details::SettingIndex(S)>(
std::forward<typename details::SettingMapping<S>::value_t>(validatedValue.value()));
AICLI_LOG(Core, Info, << "Valid setting. Field: " << path << " Value: " << GetValueString(jsonValue.value()));
AICLI_LOG(Core, Verbose, << "Valid setting. Field: " << path << " Value: " << GetValueString(jsonValue.value()));
}
else
{
Expand All @@ -165,7 +165,7 @@ namespace AppInstaller::Settings
}
else
{
AICLI_LOG(Core, Info, << "Setting " << path << " not found. Using default");
AICLI_LOG(Core, Verbose, << "Setting " << path << " not found. Using default");
}
}

Expand Down