Skip to content

Commit

Permalink
Make DevDiagnostics experimental again (#3845)
Browse files Browse the repository at this point in the history
  • Loading branch information
timkur committed Sep 12, 2024
1 parent e3a7e1e commit 1d5d5aa
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
8 changes: 8 additions & 0 deletions settings/DevHome.Settings/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,14 @@
<value>Quiet background processes allows you to free up resources while developing</value>
<comment>Inline description of the Quiet background processes experimental feature on the 'Settings -&gt; Experiments' page where you enable it.</comment>
</data>
<data name="DevDiagnosticsExperiment_Name" xml:space="preserve">
<value>Dev Diagnostics</value>
<comment>Name of experimental feature 'Dev Diagnostics' on the 'Settings -&gt; Experiments' page where you enable it.</comment>
</data>
<data name="DevDiagnosticsExperiment_Description" xml:space="preserve">
<value>Dev Diagnostics is a utility to provide deeper insights into your applications</value>
<comment>Inline description of the Dev Diagnostics experimental feature on the 'Settings -&gt; Experiments' page where you enable it.</comment>
</data>
<data name="QuickstartPlayground_Name" xml:space="preserve">
<value>Quickstart Playground</value>
<comment>Locked="{Quickstart Playground}" Title text for the Quickstart Playground feature.</comment>
Expand Down
24 changes: 24 additions & 0 deletions src/NavConfig.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,30 @@
"parameter": "StartQuickstartPlayground"
}
},
{
"identity": "DevDiagnosticsExperiment",
"enabledByDefault": false,
"buildTypeOverrides": [
{
"buildType": "dev",
"enabledByDefault": true,
"visible": true
},
{
"buildType": "canary",
"enabledByDefault": true,
"visible": true
},
{
"buildType": "stable",
"enabledByDefault": false,
"visible": true
}
],
"openPage": {
"key": "DevHome.Utilities.ViewModels.UtilitiesMainPageViewModel"
}
},
{
"identity": "RepositoryManagementExperiment",
"enabledByDefault": false,
Expand Down
20 changes: 20 additions & 0 deletions tools/DevDiagnostics/DevHome.DevDiagnostics/DDApp.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,26 @@ private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledEx
Environment.FailFast(e.Message, e.Exception);
}

internal static bool IsFeatureEnabled()
{
var isEnabled = false;

ApplicationData.Current.LocalSettings.Values.TryGetValue($"ExperimentalFeature_DevDiagnosticsExperiment", out var isEnabledObj);
if (isEnabledObj is not null && isEnabledObj is string isEnabledValue)
{
isEnabled = isEnabledValue == "true";
}
else
{
#if DEBUG
// Override on debug builds to be enabled by default
isEnabled = true;
#endif
}

return isEnabled;
}

internal static ITelemetry Logger => TelemetryFactory.Get<ITelemetry>();

internal static void LogTimeTaken(string eventName, uint timeTakenMilliseconds, Guid? relatedActivityId = null) => Logger.LogTimeTaken(eventName, timeTakenMilliseconds, relatedActivityId);
Expand Down
7 changes: 7 additions & 0 deletions tools/DevDiagnostics/DevHome.DevDiagnostics/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ private static void OnActivated(object? sender, Microsoft.Windows.AppLifecycle.A
else if (e.Kind == Microsoft.Windows.AppLifecycle.ExtendedActivationKind.StartupTask)
{
// Start the app in the background to handle the startup task and register the hotkey
if (wasFirstActivation && !App.IsFeatureEnabled())
{
// Exit the process if PI Expermental feature is not enabled and its the first activation in the process
Log.Information("Experimental feature is not enabled. Exiting the process.");
Process.GetCurrentProcess().Kill(false);
}

// Don't show the bar window for startup task activations.
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public UtilitiesMainPageViewModel(IExperimentationService experimentationService
SupportsLaunchAsAdmin = Microsoft.UI.Xaml.Visibility.Visible,
UtilityAutomationId = "DevHome.EnvironmentVariables",
},
new(Path.Combine(appExAliasAbsFolderPath, "DevHome.DevDiagnostics.exe"))
new(Path.Combine(appExAliasAbsFolderPath, "DevHome.DevDiagnostics.exe"), experimentationService, "DevDiagnosticsExperiment")
{
Title = stringResource.GetLocalized("DevDiagnosticsTitle"),
Description = stringResource.GetLocalized("DevDiagnosticsDesc"),
Expand Down

0 comments on commit 1d5d5aa

Please sign in to comment.