mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[PowerToysRun] Add version info to plugin error messages (#38491)
* changes * fix resx
This commit is contained in:
@@ -185,9 +185,10 @@ namespace PowerLauncher.Plugin
|
||||
|
||||
if (!failedPlugins.IsEmpty)
|
||||
{
|
||||
var failed = string.Join(", ", failedPlugins.Select(x => x.Metadata.Name));
|
||||
string title = Resources.FailedToInitializePluginsTitle.ToString().Replace("{0}", Constant.Version);
|
||||
var failed = string.Join(", ", failedPlugins.Select(x => $"{x.Metadata.Name} ({x.Metadata.ExecuteFileVersion})"));
|
||||
var description = $"{string.Format(CultureInfo.CurrentCulture, FailedToInitializePluginsDescription, failed)}\n\n{Resources.FailedToInitializePluginsDescriptionPartTwo}";
|
||||
Application.Current.Dispatcher.InvokeAsync(() => API.ShowMsg(Resources.FailedToInitializePluginsTitle, description, string.Empty, false));
|
||||
Application.Current.Dispatcher.InvokeAsync(() => API.ShowMsg(title, description, string.Empty, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace PowerLauncher.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to PowerToys Run - Plugin Initialization Error.
|
||||
/// Looks up a localized string similar to PowerToys Run {0} - Plugin Initialization Error.
|
||||
/// </summary>
|
||||
public static string FailedToInitializePluginsTitle {
|
||||
get {
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
<value>Fail to initialize plugins: {0}</value>
|
||||
</data>
|
||||
<data name="FailedToInitializePluginsTitle" xml:space="preserve">
|
||||
<value>PowerToys Run - Plugin Initialization Error</value>
|
||||
<value>PowerToys Run {0} - Plugin Initialization Error</value>
|
||||
<comment>Don't translate "PowerToys Run". This is a product name.</comment>
|
||||
</data>
|
||||
<data name="ContextMenuItemsAvailable" xml:space="preserve">
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
@@ -252,7 +251,7 @@ namespace PowerLauncher
|
||||
Id = x.Metadata.ID,
|
||||
Name = x.Plugin == null ? x.Metadata.Name : x.Plugin.Name,
|
||||
Description = x.Plugin?.Description,
|
||||
Version = FileVersionInfo.GetVersionInfo(x.Metadata.ExecuteFilePath).FileVersion,
|
||||
Version = x.Metadata.ExecuteFileVersion,
|
||||
Author = x.Metadata.Author,
|
||||
Website = x.Metadata.Website,
|
||||
Disabled = x.Metadata.Disabled,
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
@@ -42,6 +44,9 @@ namespace Wox.Plugin
|
||||
|
||||
public string ExecuteFileName { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string ExecuteFileVersion { get; private set; }
|
||||
|
||||
public string PluginDirectory
|
||||
{
|
||||
get
|
||||
@@ -53,6 +58,7 @@ namespace Wox.Plugin
|
||||
{
|
||||
_pluginDirectory = value;
|
||||
ExecuteFilePath = Path.Combine(value, ExecuteFileName);
|
||||
SetExecutableVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,5 +90,19 @@ namespace Wox.Plugin
|
||||
|
||||
[JsonIgnore]
|
||||
public int QueryCount { get; set; }
|
||||
|
||||
private void SetExecutableVersion()
|
||||
{
|
||||
// Using version from plugin metadata json as fallback
|
||||
try
|
||||
{
|
||||
var v = FileVersionInfo.GetVersionInfo(ExecuteFilePath).FileVersion;
|
||||
ExecuteFileVersion = (v is null or "0.0.0.0") ? Version : v;
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
ExecuteFileVersion = Version;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +82,9 @@ namespace Wox.Plugin
|
||||
|
||||
if (!IsPluginInitialized)
|
||||
{
|
||||
string description = $"{Resources.FailedToLoadPluginDescription} {Metadata.Name}\n\n{Resources.FailedToLoadPluginDescriptionPartTwo}";
|
||||
Application.Current.Dispatcher.InvokeAsync(() => api.ShowMsg(Resources.FailedToLoadPluginTitle, description, string.Empty, false));
|
||||
string title = Resources.FailedToLoadPluginTitle.ToString().Replace("{0}", Constant.Version);
|
||||
string description = $"{Resources.FailedToLoadPluginDescription} {Metadata.Name} ({Metadata.ExecuteFileVersion})\n\n{Resources.FailedToLoadPluginDescriptionPartTwo}";
|
||||
Application.Current.Dispatcher.InvokeAsync(() => api.ShowMsg(title, description, string.Empty, false));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Wox.Plugin.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to PowerToys Run - Plugin Loading Error.
|
||||
/// Looks up a localized string similar to PowerToys Run {0} - Plugin Loading Error.
|
||||
/// </summary>
|
||||
public static string FailedToLoadPluginTitle {
|
||||
get {
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
<comment>"https://aka.ms/powerToysReportBug" is a web uri.</comment>
|
||||
</data>
|
||||
<data name="FailedToLoadPluginTitle" xml:space="preserve">
|
||||
<value>PowerToys Run - Plugin Loading Error</value>
|
||||
<value>PowerToys Run {0} - Plugin Loading Error</value>
|
||||
<comment>Don't translate "PowerToys Run". This is a product name.</comment>
|
||||
</data>
|
||||
<data name="VirtualDesktopHelper_AllDesktops" xml:space="preserve">
|
||||
|
||||
Reference in New Issue
Block a user