mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
[PowerToysRun] Add version info to plugin error messages (#38491)
* changes * fix resx
This commit is contained in:
@@ -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