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

Make a lot of experimental things release #969

Merged
merged 2 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Commands/ExportCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace AppInstaller::CLI
// Command to get the set of installed packages on the system.
struct ExportCommand final : public Command
{
ExportCommand(std::string_view parent) : Command("export", parent, Settings::ExperimentalFeature::Feature::ExperimentalExport) {}
ExportCommand(std::string_view parent) : Command("export", parent) {}

std::vector<Argument> GetArguments() const override;

Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Commands/ListCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace AppInstaller::CLI
// Command to get the set of installed packages on the system.
struct ListCommand final : public Command
{
ListCommand(std::string_view parent) : Command("list", parent, Settings::ExperimentalFeature::Feature::ExperimentalList) {}
ListCommand(std::string_view parent) : Command("list", parent) {}

std::vector<Argument> GetArguments() const override;

Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Commands/UninstallCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace AppInstaller::CLI
{
struct UninstallCommand final : public Command
{
UninstallCommand(std::string_view parent) : Command("uninstall", parent, Settings::ExperimentalFeature::Feature::ExperimentalUninstall) {}
UninstallCommand(std::string_view parent) : Command("uninstall", parent) {}

std::vector<Argument> GetArguments() const override;

Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Commands/UpgradeCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace AppInstaller::CLI
{
struct UpgradeCommand final : public Command
{
UpgradeCommand(std::string_view parent) : Command("upgrade", parent, Settings::ExperimentalFeature::Feature::ExperimentalUpgrade) {}
UpgradeCommand(std::string_view parent) : Command("upgrade", parent) {}

std::vector<Argument> GetArguments() const override;

Expand Down
4 changes: 0 additions & 4 deletions src/AppInstallerCLIE2ETests/ImportCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ public class ImportCommand : BaseCommand
[SetUp]
public void Setup()
{
InitializeAllFeatures(false);
ConfigureFeature("export", true);
CleanupTestExe();
}

[TearDown]
public void TearDown()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public void TearDown()

Should we just delete the tear down?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applies to the other 2 tests' setup and teardown if you decide to do so

{
InitializeAllFeatures(false);
}

[Test]
Expand Down Expand Up @@ -119,7 +116,6 @@ private bool VerifyTestExeInstalled(string installDir = null)

private void UninstallTestExe()
{
ConfigureFeature("uninstall", true);
TestCommon.RunAICLICommand("uninstall", Constants.ExeInstallerPackageId);
}

Expand Down
3 changes: 0 additions & 3 deletions src/AppInstallerCLIE2ETests/ListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ public class ListCommand : BaseCommand
[SetUp]
public void Setup()
{
InitializeAllFeatures(false);
ConfigureFeature("list", true);
}

[TearDown]
public void TearDown()
{
InitializeAllFeatures(false);
}

[Test]
Expand Down
3 changes: 0 additions & 3 deletions src/AppInstallerCLIE2ETests/UninstallCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ public class UninstallCommand : BaseCommand
[OneTimeSetUp]
public void OneTimeSetUp()
{
InitializeAllFeatures(false);
ConfigureFeature("uninstall", true);
}

[OneTimeTearDown]
public void OneTimeTearDown()
{
InitializeAllFeatures(false);
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLITests/Downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ TEST_CASE("DownloadInvalidUrl", "[Downloader]")

ProgressCallback callback;

REQUIRE_THROWS_HR(Download("blargle-flargle-fluff", tempFile.GetPath(), DownloadType::Installer, callback, true), WININET_E_UNRECOGNIZED_SCHEME);
REQUIRE_THROWS(Download("blargle-flargle-fluff", tempFile.GetPath(), DownloadType::Installer, callback, true));
}
23 changes: 13 additions & 10 deletions src/AppInstallerCommonCore/Downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,21 @@ namespace AppInstaller::Utility
// Determine whether to try DO first or not, as this is the only choice currently supported.
InstallerDownloader setting = User().Get<Setting::NetworkDownloader>();

// Currently, the default remains WinINet until the DO path is proven.
if (setting == InstallerDownloader::Default)
if (setting == InstallerDownloader::Default ||
setting == InstallerDownloader::DeliveryOptimization)
{
setting = InstallerDownloader::WinInet;
}

if (setting == InstallerDownloader::DeliveryOptimization)
{
return DODownload(url, dest, progress, computeHash, info);
auto result = DODownload(url, dest, progress, computeHash, info);
// Since we cannot pre-apply to the file with DO, post-apply the MotW to the file.
// Only do so if the file exists, because cancellation will not throw here.
if (std::filesystem::exists(dest))
{
ApplyMotwIfApplicable(dest, URLZONE_INTERNET);
}
return result;

// While DO still requires an explicit opt-in, we will let failures through.
// When DO becomes the default, we may choose to catch exceptions and fall back to WinINet below.
// If DO becomes an issue, we may choose to catch exceptions and fall back to WinINet below.
// We would need to be careful not to bypass metered networks or other reasons that might
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other reasons

Curious what the other reasons could be?
Is metered networks the reason we do not fall back to wininet for now?

// intentionally cause the download to be blocked.
}
}

Expand Down
34 changes: 8 additions & 26 deletions src/AppInstallerCommonCore/ExperimentalFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ namespace AppInstaller::Settings
return true;
}

// Even if all experimental features are disabled, if the store policy is enabled then override it.
if (feature == ExperimentalFeature::Feature::ExperimentalMSStore &&
GroupPolicies().GetState(TogglePolicy::Policy::MSStoreSource) == PolicyState::Enabled)
{
// Force enable the feature
return true;
}

if (!GroupPolicies().IsEnabled(TogglePolicy::Policy::ExperimentalFeatures))
{
AICLI_LOG(Core, Info, <<
Expand All @@ -35,23 +43,7 @@ namespace AppInstaller::Settings
case ExperimentalFeature::Feature::ExperimentalArg:
return userSettings.Get<Setting::EFExperimentalArg>();
case ExperimentalFeature::Feature::ExperimentalMSStore:
if (GroupPolicies().GetState(TogglePolicy::Policy::MSStoreSource) == PolicyState::Enabled)
{
// Force enable the feature
return true;
}

return userSettings.Get<Setting::EFExperimentalMSStore>();
case ExperimentalFeature::Feature::ExperimentalList:
return userSettings.Get<Setting::EFList>();
case ExperimentalFeature::Feature::ExperimentalUpgrade:
return userSettings.Get<Setting::EFExperimentalUpgrade>();
case ExperimentalFeature::Feature::ExperimentalUninstall:
return userSettings.Get<Setting::EFUninstall>();
case ExperimentalFeature::Feature::ExperimentalExport:
return userSettings.Get<Setting::EFExport>();
case ExperimentalFeature::Feature::ExperimentalRestSource:
return userSettings.Get<Setting::EFRestSource>();
default:
THROW_HR(E_UNEXPECTED);
}
Expand Down Expand Up @@ -80,16 +72,6 @@ namespace AppInstaller::Settings
return ExperimentalFeature{ "Argument Sample", "experimentalArg", "https://aka.ms/winget-settings", Feature::ExperimentalArg };
case Feature::ExperimentalMSStore:
return ExperimentalFeature{ "Microsoft Store Support", "experimentalMSStore", "https://aka.ms/winget-settings", Feature::ExperimentalMSStore };
case Feature::ExperimentalList:
return ExperimentalFeature{ "List Command", "list", "https://aka.ms/winget-settings", Feature::ExperimentalList };
case Feature::ExperimentalUpgrade:
return ExperimentalFeature{ "Upgrade Command", "upgrade", "https://aka.ms/winget-settings", Feature::ExperimentalUpgrade };
case Feature::ExperimentalUninstall:
return ExperimentalFeature{ "Uninstall Command", "uninstall", "https://aka.ms/winget-settings", Feature::ExperimentalUninstall };
case Feature::ExperimentalExport:
return ExperimentalFeature{ "Export Command", "export", "https://aka.ms/winget-settings", Feature::ExperimentalExport };
case Feature::ExperimentalRestSource:
return ExperimentalFeature{ "Rest Source Support", "restSource", "https://aka.ms/winget-settings", Feature::ExperimentalRestSource };
default:
THROW_HR(E_UNEXPECTED);
}
Expand Down
13 changes: 4 additions & 9 deletions src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,13 @@ namespace AppInstaller::Settings
enum class Feature : unsigned
{
None = 0x0,
ExperimentalCmd = 0x1,
ExperimentalArg = 0x2,
ExperimentalMSStore = 0x4,
ExperimentalList = 0x8,
ExperimentalUpgrade = 0x10,
ExperimentalUninstall = 0x20,
ExperimentalRestSource = 0x40,
ExperimentalMSStore = 0x1,
Max, // This MUST always be after all experimental features

// Features listed after Max will not be shown with the features command
// This can be used to hide highly experimental features
ExperimentalExport = 0x100
// This can be used to hide highly experimental features (or these example ones)
ExperimentalCmd = 0x10000,
ExperimentalArg = 0x20000,
};

using Feature_t = std::underlying_type_t<ExperimentalFeature::Feature>;
Expand Down
10 changes: 0 additions & 10 deletions src/AppInstallerCommonCore/Public/winget/UserSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@ namespace AppInstaller::Settings
EFExperimentalCmd,
EFExperimentalArg,
EFExperimentalMSStore,
EFList,
EFExperimentalUpgrade,
EFUninstall,
EFExport,
TelemetryDisable,
EFRestSource,
InstallScopePreference,
InstallScopeRequirement,
NetworkDownloader,
Expand Down Expand Up @@ -118,12 +113,7 @@ namespace AppInstaller::Settings
SETTINGMAPPING_SPECIALIZATION(Setting::EFExperimentalCmd, bool, bool, false, ".experimentalFeatures.experimentalCmd"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::EFExperimentalArg, bool, bool, false, ".experimentalFeatures.experimentalArg"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::EFExperimentalMSStore, bool, bool, false, ".experimentalFeatures.experimentalMSStore"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::EFList, bool, bool, false, ".experimentalFeatures.list"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::EFExperimentalUpgrade, bool, bool, false, ".experimentalFeatures.upgrade"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::EFUninstall, bool, bool, false, ".experimentalFeatures.uninstall"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::EFExport, bool, bool, false, ".experimentalFeatures.export"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::TelemetryDisable, bool, bool, false, ".telemetry.disable"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::EFRestSource, bool, bool, false, ".experimentalFeatures.restSource"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::InstallScopePreference, std::string, ScopePreference, ScopePreference::User, ".installBehavior.preferences.scope"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::InstallScopeRequirement, std::string, ScopePreference, ScopePreference::None, ".installBehavior.requirements.scope"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::NetworkDownloader, std::string, InstallerDownloader, InstallerDownloader::Default, ".network.downloader"sv);
Expand Down
5 changes: 0 additions & 5 deletions src/AppInstallerCommonCore/UserSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,7 @@ namespace AppInstaller::Settings
WINGET_VALIDATE_PASS_THROUGH(EFExperimentalCmd)
WINGET_VALIDATE_PASS_THROUGH(EFExperimentalArg)
WINGET_VALIDATE_PASS_THROUGH(EFExperimentalMSStore)
WINGET_VALIDATE_PASS_THROUGH(EFList)
WINGET_VALIDATE_PASS_THROUGH(EFExperimentalUpgrade)
WINGET_VALIDATE_PASS_THROUGH(EFUninstall)
WINGET_VALIDATE_PASS_THROUGH(EFExport)
WINGET_VALIDATE_PASS_THROUGH(TelemetryDisable)
WINGET_VALIDATE_PASS_THROUGH(EFRestSource)

WINGET_VALIDATE_SIGNATURE(InstallScopePreference)
{
Expand Down
18 changes: 1 addition & 17 deletions src/AppInstallerRepositoryCore/RepositorySource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,6 @@ namespace AppInstaller::Repository

for (auto& source : userSources)
{
if (Utility::CaseInsensitiveEquals(Rest::RestSourceFactory::Type(), source.Type)
&& !Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::ExperimentalRestSource))
{
continue;
}

// Check source against list of allowed sources and drop tombstones for required sources
if (!IsUserSourceAllowedByPolicy(source.Name, source.Type, source.Arg, source.IsTombstone))
{
Expand Down Expand Up @@ -582,8 +576,7 @@ namespace AppInstaller::Repository
{
return Microsoft::PredefinedInstalledSourceFactory::Create();
}
else if (Utility::CaseInsensitiveEquals(Rest::RestSourceFactory::Type(), type)
&& Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::ExperimentalRestSource))
else if (Utility::CaseInsensitiveEquals(Rest::RestSourceFactory::Type(), type))
{
return Rest::RestSourceFactory::Create();
}
Expand Down Expand Up @@ -880,15 +873,6 @@ namespace AppInstaller::Repository
details.LastUpdateTime = Utility::ConvertUnixEpochToSystemClock(0);
details.Origin = SourceOrigin::User;

// Check feature flag enablement for rest source.
if (Utility::CaseInsensitiveEquals(Rest::RestSourceFactory::Type(), type)
&& !Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::ExperimentalRestSource))
{
AICLI_LOG(Repo, Error, << Settings::ExperimentalFeature::GetFeature(Settings::ExperimentalFeature::Feature::ExperimentalRestSource).Name()
<< " feature is disabled. Execution cancelled.");
THROW_HR(APPINSTALLER_CLI_ERROR_EXPERIMENTAL_FEATURE_DISABLED);
}

AddSourceFromDetails(details, progress);

AICLI_LOG(Repo, Info, << "Source created with extra data: " << details.Data);
Expand Down