From 1af200d5a51dd50cc46aaa59929ca8f7ea180f8b Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 19 May 2020 22:06:52 +0800 Subject: [PATCH 01/19] catch error early --- Wox/App.xaml.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index df0d61d43..3503c4c12 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -75,14 +75,12 @@ private void OnStartup(object sender, StartupEventArgs e) { Logger.StopWatchNormal("Startup cost", () => { - Logger.WoxInfo("Begin Wox startup----------------------------------------------------"); - Logger.WoxInfo($"Runtime info:{ExceptionFormatter.RuntimeInfo()}"); - Settings.Instance.ToString(); - RegisterAppDomainExceptions(); RegisterDispatcherUnhandledException(); - //throw new Exception("sentry wox exception"); + Logger.WoxInfo("Begin Wox startup----------------------------------------------------"); + Logger.WoxInfo($"Runtime info:{ExceptionFormatter.RuntimeInfo()}"); + Settings.Instance.ToString(); _portable.PreStartCleanUpAfterPortabilityUpdate(); From 95ab28cf868c70e1ffea866709bb173601cfe86d Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 19 May 2020 22:12:36 +0800 Subject: [PATCH 02/19] add more info to dump --- Wox.Infrastructure/Exception/ExceptionFormatter.cs | 3 ++- Wox.Infrastructure/UserSettings/Settings.cs | 12 +++++++++--- Wox/App.xaml.cs | 5 ++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Wox.Infrastructure/Exception/ExceptionFormatter.cs b/Wox.Infrastructure/Exception/ExceptionFormatter.cs index 189f053d1..a969a05d6 100644 --- a/Wox.Infrastructure/Exception/ExceptionFormatter.cs +++ b/Wox.Infrastructure/Exception/ExceptionFormatter.cs @@ -135,7 +135,8 @@ public static string RuntimeInfo() sb.AppendLine($"* Timestamp: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}"); sb.AppendLine($"* Wox version: {Constant.Version}"); sb.AppendLine($"* OS Version: {Environment.OSVersion.VersionString}"); - sb.AppendLine($"* x64: {Environment.Is64BitOperatingSystem}"); + sb.AppendLine($"* x64 OS: {Environment.Is64BitOperatingSystem}"); + sb.AppendLine($"* x64 Process: {Environment.Is64BitProcess}"); sb.AppendLine($"* CLR Version: {Environment.Version}"); sb.AppendLine($"* Installed .NET Framework: "); foreach (var result in GetFrameworkVersionFromRegistry()) diff --git a/Wox.Infrastructure/UserSettings/Settings.cs b/Wox.Infrastructure/UserSettings/Settings.cs index 68b27a412..eff637459 100644 --- a/Wox.Infrastructure/UserSettings/Settings.cs +++ b/Wox.Infrastructure/UserSettings/Settings.cs @@ -20,10 +20,16 @@ public static void Save() } private static WoxJsonStorage _storage = new WoxJsonStorage(); - private static Settings _instance = _storage.Load(); - public static Settings Instance => _instance; + private static Settings _instance; + public static Settings Instance = _instance; - #endregion + public static void Initialize() + { + _instance = _storage.Load(); + Logger.WoxInfo($"Wox Language: {_instance.Language}"); + } + + #endregion public string Hotkey { get; set; } = "Alt + Space"; public string Language { get; set; } = "en"; diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index 3503c4c12..fde1c44e8 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -79,12 +79,11 @@ private void OnStartup(object sender, StartupEventArgs e) RegisterDispatcherUnhandledException(); Logger.WoxInfo("Begin Wox startup----------------------------------------------------"); - Logger.WoxInfo($"Runtime info:{ExceptionFormatter.RuntimeInfo()}"); - Settings.Instance.ToString(); + Settings.Initialize(); + Logger.WoxInfo(ExceptionFormatter.RuntimeInfo()); _portable.PreStartCleanUpAfterPortabilityUpdate(); - ImageLoader.Initialize(); _settingsVM = new SettingWindowViewModel(_portable); From d5293469c301caf2fc73b0c5db4f1b613b136cbb Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 19 May 2020 22:18:11 +0800 Subject: [PATCH 03/19] add more runtime info --- Wox.Infrastructure/Exception/ExceptionFormatter.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Wox.Infrastructure/Exception/ExceptionFormatter.cs b/Wox.Infrastructure/Exception/ExceptionFormatter.cs index a969a05d6..c3fa42d45 100644 --- a/Wox.Infrastructure/Exception/ExceptionFormatter.cs +++ b/Wox.Infrastructure/Exception/ExceptionFormatter.cs @@ -137,6 +137,7 @@ public static string RuntimeInfo() sb.AppendLine($"* OS Version: {Environment.OSVersion.VersionString}"); sb.AppendLine($"* x64 OS: {Environment.Is64BitOperatingSystem}"); sb.AppendLine($"* x64 Process: {Environment.Is64BitProcess}"); + sb.AppendLine($"* CurrentUICulture: {CultureInfo.CurrentUICulture.Name}"); sb.AppendLine($"* CLR Version: {Environment.Version}"); sb.AppendLine($"* Installed .NET Framework: "); foreach (var result in GetFrameworkVersionFromRegistry()) From 19e96e05a56f8ebd30f775f36860f274a4ef1d75 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 19 May 2020 22:23:55 +0800 Subject: [PATCH 04/19] fix single instance --- Wox.Infrastructure/UserSettings/Settings.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Wox.Infrastructure/UserSettings/Settings.cs b/Wox.Infrastructure/UserSettings/Settings.cs index eff637459..fe15874b6 100644 --- a/Wox.Infrastructure/UserSettings/Settings.cs +++ b/Wox.Infrastructure/UserSettings/Settings.cs @@ -20,13 +20,12 @@ public static void Save() } private static WoxJsonStorage _storage = new WoxJsonStorage(); - private static Settings _instance; - public static Settings Instance = _instance; + public static Settings Instance; public static void Initialize() { - _instance = _storage.Load(); - Logger.WoxInfo($"Wox Language: {_instance.Language}"); + Instance = _storage.Load(); + Logger.WoxInfo($"Wox Language: {Instance.Language}"); } #endregion From e924ff639c2ede08b9fb5fff5cc8b97d32fcb403 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 19 May 2020 22:39:00 +0800 Subject: [PATCH 05/19] add language to runtime info --- Wox.Infrastructure/Exception/ExceptionFormatter.cs | 12 +++++++++++- Wox.Infrastructure/UserSettings/Settings.cs | 1 - Wox/App.xaml.cs | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Wox.Infrastructure/Exception/ExceptionFormatter.cs b/Wox.Infrastructure/Exception/ExceptionFormatter.cs index c3fa42d45..f262018b9 100644 --- a/Wox.Infrastructure/Exception/ExceptionFormatter.cs +++ b/Wox.Infrastructure/Exception/ExceptionFormatter.cs @@ -3,6 +3,8 @@ using System.Globalization; using System.Linq; using System.Text; +using System.Threading; +using System.Windows; using System.Xml; using Microsoft.Win32; @@ -10,6 +12,13 @@ namespace Wox.Infrastructure.Exception { public class ExceptionFormatter { + private static string _systemLanguage; + private static string _woxLanguage; + public static void Initialize(string systemLanguage, string woxLanguage) + { + _systemLanguage = systemLanguage; + _woxLanguage = woxLanguage; + } public static string FormattedException(System.Exception ex) { return FormattedAllExceptions(ex).ToString(); @@ -137,7 +146,8 @@ public static string RuntimeInfo() sb.AppendLine($"* OS Version: {Environment.OSVersion.VersionString}"); sb.AppendLine($"* x64 OS: {Environment.Is64BitOperatingSystem}"); sb.AppendLine($"* x64 Process: {Environment.Is64BitProcess}"); - sb.AppendLine($"* CurrentUICulture: {CultureInfo.CurrentUICulture.Name}"); + sb.AppendLine($"* System Language: {_systemLanguage}"); + sb.AppendLine($"* Wox Language: {_woxLanguage}"); sb.AppendLine($"* CLR Version: {Environment.Version}"); sb.AppendLine($"* Installed .NET Framework: "); foreach (var result in GetFrameworkVersionFromRegistry()) diff --git a/Wox.Infrastructure/UserSettings/Settings.cs b/Wox.Infrastructure/UserSettings/Settings.cs index fe15874b6..6423e65aa 100644 --- a/Wox.Infrastructure/UserSettings/Settings.cs +++ b/Wox.Infrastructure/UserSettings/Settings.cs @@ -25,7 +25,6 @@ public static void Save() public static void Initialize() { Instance = _storage.Load(); - Logger.WoxInfo($"Wox Language: {Instance.Language}"); } #endregion diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index fde1c44e8..95ba1a601 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -34,6 +34,7 @@ public partial class App : IDisposable, ISingleInstanceApp private SettingWindowViewModel _settingsVM; private readonly Portable _portable = new Portable(); private StringMatcher _stringMatcher; + private static string _systemLanguage; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -59,6 +60,7 @@ private void ParseCommandLineArgs(IList args) [STAThread] public static void Main() { + _systemLanguage = CultureInfo.CurrentUICulture.Name; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; if (SingleInstance.InitializeAsFirstInstance(Unique)) @@ -80,6 +82,7 @@ private void OnStartup(object sender, StartupEventArgs e) Logger.WoxInfo("Begin Wox startup----------------------------------------------------"); Settings.Initialize(); + ExceptionFormatter.Initialize(_systemLanguage, Settings.Instance.Language); Logger.WoxInfo(ExceptionFormatter.RuntimeInfo()); _portable.PreStartCleanUpAfterPortabilityUpdate(); From a1d8fb87badf0a854b7d0d6dece5004210cde319 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 00:13:21 +0800 Subject: [PATCH 06/19] switch --- .../Exception/ExceptionFormatter.cs | 4 +- Wox.Infrastructure/Logger/Log.cs | 22 +++++++-- Wox.Infrastructure/Wox.Infrastructure.csproj | 3 ++ Wox/App.config | 12 ++++- Wox/App.xaml.cs | 32 ++++++++++--- Wox/Helper/ErrorReporting.cs | 45 +++++++++++++------ Wox/ReportWindow.xaml.cs | 10 ++--- Wox/Wox.csproj | 6 +-- 8 files changed, 100 insertions(+), 34 deletions(-) diff --git a/Wox.Infrastructure/Exception/ExceptionFormatter.cs b/Wox.Infrastructure/Exception/ExceptionFormatter.cs index f262018b9..904be0770 100644 --- a/Wox.Infrastructure/Exception/ExceptionFormatter.cs +++ b/Wox.Infrastructure/Exception/ExceptionFormatter.cs @@ -168,9 +168,11 @@ public static string SDKInfo() return sb.ToString(); } - public static string ExceptionWithRuntimeInfo(System.Exception ex) + public static string ExceptionWithRuntimeInfo(System.Exception ex, string id) { StringBuilder sb = new StringBuilder(); + sb.Append("Error id: "); + sb.AppendLine(id); var formatted = FormattedAllExceptions(ex); sb.Append(formatted); var info = RuntimeInfoFull(); diff --git a/Wox.Infrastructure/Logger/Log.cs b/Wox.Infrastructure/Logger/Log.cs index 90f6406f4..7c3fcf0c3 100644 --- a/Wox.Infrastructure/Logger/Log.cs +++ b/Wox.Infrastructure/Logger/Log.cs @@ -2,10 +2,10 @@ using System.Diagnostics; using System.IO; using System.Runtime.CompilerServices; -using Mindscape.Raygun4Net; using NLog; using NLog.Config; using NLog.Targets; +using Sentry; using Wox.Infrastructure.Exception; using Wox.Infrastructure.UserSettings; @@ -14,9 +14,10 @@ namespace Wox.Infrastructure.Logger public static class Log { public const string DirectoryName = "Logs"; - private static RaygunClient _raygunClient = new RaygunClient("LG5MX0YYMCpCN2AtD0fdZw"); public static string CurrentLogDirectory { get; } + private static string _woxLanguage = "not set"; + static Log() { CurrentLogDirectory = Path.Combine(DataLocation.DataDirectory(), DirectoryName, Constant.Version); @@ -74,10 +75,25 @@ public static void WoxError(this NLog.Logger logger, string message, System.Exce { Debug.WriteLine($"ERROR|{logger.Name}|{methodName}|{message}"); logger.Error($"{methodName}|{message}|{ExceptionFormatter.FormattedException(exception)}"); - _raygunClient.Send(exception); + SendException(exception); #if DEBUG throw exception; #endif } + + public static void updateSettingsInfo(string woxLanguage) + { + _woxLanguage = woxLanguage; + + SentrySdk.ConfigureScope(scope => + { + scope.SetTag("woxLanguage", _woxLanguage); + }); + } + + public static void SendException(System.Exception exception) + { + SentrySdk.CaptureException(exception); + } } } \ No newline at end of file diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index 705cbac78..f26fbf195 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -103,6 +103,9 @@ 4.7.0 + + 2.1.1 + 4.0.0 diff --git a/Wox/App.config b/Wox/App.config index 5f570a630..540eaaabe 100644 --- a/Wox/App.config +++ b/Wox/App.config @@ -8,6 +8,13 @@ + + + + + + + @@ -16,4 +23,7 @@ - + + + + diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index 95ba1a601..e53508696 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -22,6 +22,7 @@ using Wox.ViewModel; using Stopwatch = Wox.Infrastructure.Stopwatch; using Wox.Infrastructure.Exception; +using Sentry; namespace Wox { @@ -63,12 +64,16 @@ public static void Main() _systemLanguage = CultureInfo.CurrentUICulture.Name; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; - if (SingleInstance.InitializeAsFirstInstance(Unique)) + + using (ErrorReporting.InitializedSentry(_systemLanguage)) { - using (var application = new App()) + if (SingleInstance.InitializeAsFirstInstance(Unique)) { - application.InitializeComponent(); - application.Run(); + using (var application = new App()) + { + application.InitializeComponent(); + application.Run(); + } } } } @@ -83,6 +88,8 @@ private void OnStartup(object sender, StartupEventArgs e) Logger.WoxInfo("Begin Wox startup----------------------------------------------------"); Settings.Initialize(); ExceptionFormatter.Initialize(_systemLanguage, Settings.Instance.Language); + InsertWoxLanguageIntoLog(); + Logger.WoxInfo(ExceptionFormatter.RuntimeInfo()); _portable.PreStartCleanUpAfterPortabilityUpdate(); @@ -125,6 +132,17 @@ private void OnStartup(object sender, StartupEventArgs e) }); } + private static void InsertWoxLanguageIntoLog() + { + Log.updateSettingsInfo(Settings.Instance.Language); + Settings.Instance.PropertyChanged += (s, ev) => + { + if (ev.PropertyName == nameof(Settings.Instance.Language)) + { + Log.updateSettingsInfo(Settings.Instance.Language); + } + }; + } private void AutoStartup() { @@ -147,7 +165,7 @@ private void RegisterExitEvents() /// /// let exception throw as normal is better for Debug /// - [Conditional("RELEASE")] + //[Conditional("RELEASE")] private void RegisterDispatcherUnhandledException() { DispatcherUnhandledException += ErrorReporting.DispatcherUnhandledException; @@ -157,7 +175,7 @@ private void RegisterDispatcherUnhandledException() /// /// let exception throw as normal is better for Debug /// - [Conditional("RELEASE")] + //[Conditional("RELEASE")] private static void RegisterAppDomainExceptions() { AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandleMain; @@ -169,7 +187,7 @@ public void Dispose() // but if sessionending is not called, exit won't be called when log off / shutdown if (!_disposed) { - API.SaveAppAllSettings(); + API?.SaveAppAllSettings(); _disposed = true; } } diff --git a/Wox/Helper/ErrorReporting.cs b/Wox/Helper/ErrorReporting.cs index b3c41ddaa..efd7e2791 100644 --- a/Wox/Helper/ErrorReporting.cs +++ b/Wox/Helper/ErrorReporting.cs @@ -1,55 +1,72 @@ using System; +using System.Net; +using System.Net.Sockets; using System.Runtime.CompilerServices; using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; -using Mindscape.Raygun4Net; using NLog; +using Sentry; +using Sentry.Protocol; +using Wox.Infrastructure; using Wox.Infrastructure.Exception; namespace Wox.Helper { public static class ErrorReporting { - private static RaygunClient _raygunClient = new RaygunClient("LG5MX0YYMCpCN2AtD0fdZw"); - - private static void Report(Exception e, [CallerMemberName] string method = "") + private static void Report(Exception e, string id, [CallerMemberName] string method = "") { var logger = LogManager.GetLogger(method); - logger.Fatal(ExceptionFormatter.ExceptionWithRuntimeInfo(e)); + logger.Fatal(ExceptionFormatter.ExceptionWithRuntimeInfo(e, id)); - var reportWindow = new ReportWindow(e); + var reportWindow = new ReportWindow(e, id); reportWindow.Show(); - } public static void UnhandledExceptionHandleTask(Task t) { - _raygunClient.Send(t.Exception); + SentryId id = SentrySdk.CaptureException(t.Exception); Application.Current.Dispatcher.Invoke(() => { - Report(t.Exception); + Report(t.Exception, id.ToString()); }); - } public static void UnhandledExceptionHandleMain(object sender, UnhandledExceptionEventArgs e) { - _raygunClient.Send(e.ExceptionObject as Exception); + SentryId id = SentrySdk.CaptureException(e.ExceptionObject as Exception); //handle non-ui main thread exceptions Application.Current.Dispatcher.Invoke(() => { - Report((Exception)e.ExceptionObject); + Report((Exception)e.ExceptionObject, id.ToString()); }); } public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { - _raygunClient.Send(e.Exception); - Report(e.Exception); + SentryId id = SentrySdk.CaptureException(e.Exception); + Report(e.Exception, id.ToString()); //prevent application exist, so the user can copy prompted error info e.Handled = true; } + public static IDisposable InitializedSentry(string systemLanguage) + { + var s = SentrySdk.Init(o => + { + o.Dsn = new Dsn("https://b87bf28a6fab49bf9cb1b53e9648152f@o385966.ingest.sentry.io/5219588"); + o.Debug = true; // todo + o.Release = Constant.Version; + o.SendDefaultPii = true; + o.DisableAppDomainUnhandledExceptionCapture(); + }); + SentrySdk.ConfigureScope(scope => + { + scope.SetTag("systemLanguage", systemLanguage); + scope.SetTag("timezone", TimeZoneInfo.Local.DisplayName); + }); + return s; + } } } diff --git a/Wox/ReportWindow.xaml.cs b/Wox/ReportWindow.xaml.cs index bcb24daf6..5bdcc488a 100644 --- a/Wox/ReportWindow.xaml.cs +++ b/Wox/ReportWindow.xaml.cs @@ -15,25 +15,25 @@ namespace Wox { internal partial class ReportWindow { - public ReportWindow(Exception exception) + public ReportWindow(Exception exception, string id) { InitializeComponent(); ErrorTextbox.Document.Blocks.FirstBlock.Margin = new Thickness(0); - SetException(exception); + SetException(exception, id); } - private void SetException(Exception exception) + private void SetException(Exception exception, string id) { string path = Log.CurrentLogDirectory; var directory = new DirectoryInfo(path); var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First(); - var paragraph = Hyperlink("Please open new issue in: ", Constant.Issue); + var paragraph = Hyperlink("You can help us to fix this issue by opening issue in: ", Constant.Issue); paragraph.Inlines.Add($"1. upload log file: {log.FullName}\n"); paragraph.Inlines.Add($"2. copy below exception message"); ErrorTextbox.Document.Blocks.Add(paragraph); - var content = ExceptionFormatter.ExceptionWithRuntimeInfo(exception); + var content = ExceptionFormatter.ExceptionWithRuntimeInfo(exception, id); paragraph = new Paragraph(); paragraph.Inlines.Add(content); ErrorTextbox.Document.Blocks.Add(paragraph); diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 4c1ff6c59..93997ddd0 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -495,9 +495,6 @@ 10.3.0 - - 5.10.2 - 9.0.1 @@ -520,6 +517,9 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all + + 2.1.1 + 1.9.1 From 99fbd8d43e37afb15def5d664f9e1a7c69f907f3 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 01:42:34 +0800 Subject: [PATCH 07/19] fix test --- Wox.Test/FuzzyMatcherTest.cs | 13 ++++++++++--- Wox.Test/PluginManagerTest.cs | 12 ++++++++++++ Wox.Test/PluginProgramTest.cs | 34 ---------------------------------- Wox.Test/Wox.Test.csproj | 1 - 4 files changed, 22 insertions(+), 38 deletions(-) delete mode 100644 Wox.Test/PluginProgramTest.cs diff --git a/Wox.Test/FuzzyMatcherTest.cs b/Wox.Test/FuzzyMatcherTest.cs index 6a033db79..2780a58dd 100644 --- a/Wox.Test/FuzzyMatcherTest.cs +++ b/Wox.Test/FuzzyMatcherTest.cs @@ -20,9 +20,16 @@ public class FuzzyMatcherTest private const string OneOneOneOne = "1111"; private const string MicrosoftSqlServerManagementStudio = "Microsoft SQL Server Management Studio"; + [OneTimeSetUp] + public void setUp() + { + Settings.Initialize(); + } + + public List GetSearchStrings() - => new List - { + => new List + { Chrome, "Choose which programs you want Windows to use for activities like web browsing, editing photos, sending e-mail, and playing music.", HelpCureHopeRaiseOnMindEntityChrome, @@ -31,7 +38,7 @@ public List GetSearchStrings() "Add, change, and manage fonts on your computer", LastIsChrome, OneOneOneOne - }; + }; public List GetPrecisionScores() { diff --git a/Wox.Test/PluginManagerTest.cs b/Wox.Test/PluginManagerTest.cs index 4907f6a37..cfe3d2e61 100644 --- a/Wox.Test/PluginManagerTest.cs +++ b/Wox.Test/PluginManagerTest.cs @@ -21,6 +21,7 @@ public void setUp() { // todo remove i18n from application / ui, so it can be tested in a modular way new App(); + Settings.Initialize(); ImageLoader.Initialize(); Portable portable = new Portable(); @@ -52,5 +53,16 @@ public void BuiltinQueryTest(string QueryText, string ResultTitle) Assert.IsTrue(result.Title.StartsWith(ResultTitle)); } + + [TestCase("powershell", "PowerShell")] + [TestCase("note", "Notepad")] + [TestCase("this pc", "This PC")] + public void Win32Test(string QueryText, string ResultTitle) + { + PluginPair pair = PluginManager.AllPlugins.Where(p => p.Plugin.GetType() == typeof(Plugin.Program.Main)).First(); + Query query = QueryBuilder.Build(QueryText.Trim(), new Dictionary()); + Result result = pair.Plugin.Query(query).OrderByDescending(r => r.Score).First(); + Assert.IsTrue(result.Title.StartsWith(ResultTitle)); + } } } diff --git a/Wox.Test/PluginProgramTest.cs b/Wox.Test/PluginProgramTest.cs deleted file mode 100644 index b5d064fbe..000000000 --- a/Wox.Test/PluginProgramTest.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -using NUnit.Framework; -using Wox.Core.Plugin; -using Wox.Plugin; - -namespace Wox.Test -{ - [TestFixture] - class PluginProgramTest - { - - private Plugin.Program.Main plugin; - - [OneTimeSetUp] - public void Setup() - { - plugin = new Plugin.Program.Main(); - plugin.loadSettings(); - Plugin.Program.Main.IndexPrograms(); - } - - [TestCase("powershell", "PowerShell")] - [TestCase("note", "Notepad")] - [TestCase("this pc", "This PC")] - public void Win32Test(string QueryText, string ResultTitle) - { - Query query = QueryBuilder.Build(QueryText.Trim(), new Dictionary()); - Result result = plugin.Query(query).OrderByDescending(r => r.Score).First(); - Assert.IsTrue(result.Title.StartsWith(ResultTitle)); - } - } -} diff --git a/Wox.Test/Wox.Test.csproj b/Wox.Test/Wox.Test.csproj index 1f35773c3..42bbe199d 100644 --- a/Wox.Test/Wox.Test.csproj +++ b/Wox.Test/Wox.Test.csproj @@ -48,7 +48,6 @@ Properties\SolutionAssemblyInfo.cs - From a477d6b3e9e7496204c36785a4eb377b78279b4c Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 01:49:49 +0800 Subject: [PATCH 08/19] Revert "fix test" This reverts commit 99fbd8d43e37afb15def5d664f9e1a7c69f907f3. --- Wox.Test/FuzzyMatcherTest.cs | 13 +++---------- Wox.Test/PluginManagerTest.cs | 12 ------------ Wox.Test/PluginProgramTest.cs | 34 ++++++++++++++++++++++++++++++++++ Wox.Test/Wox.Test.csproj | 1 + 4 files changed, 38 insertions(+), 22 deletions(-) create mode 100644 Wox.Test/PluginProgramTest.cs diff --git a/Wox.Test/FuzzyMatcherTest.cs b/Wox.Test/FuzzyMatcherTest.cs index 2780a58dd..6a033db79 100644 --- a/Wox.Test/FuzzyMatcherTest.cs +++ b/Wox.Test/FuzzyMatcherTest.cs @@ -20,16 +20,9 @@ public class FuzzyMatcherTest private const string OneOneOneOne = "1111"; private const string MicrosoftSqlServerManagementStudio = "Microsoft SQL Server Management Studio"; - [OneTimeSetUp] - public void setUp() - { - Settings.Initialize(); - } - - public List GetSearchStrings() - => new List - { + => new List + { Chrome, "Choose which programs you want Windows to use for activities like web browsing, editing photos, sending e-mail, and playing music.", HelpCureHopeRaiseOnMindEntityChrome, @@ -38,7 +31,7 @@ public List GetSearchStrings() "Add, change, and manage fonts on your computer", LastIsChrome, OneOneOneOne - }; + }; public List GetPrecisionScores() { diff --git a/Wox.Test/PluginManagerTest.cs b/Wox.Test/PluginManagerTest.cs index cfe3d2e61..4907f6a37 100644 --- a/Wox.Test/PluginManagerTest.cs +++ b/Wox.Test/PluginManagerTest.cs @@ -21,7 +21,6 @@ public void setUp() { // todo remove i18n from application / ui, so it can be tested in a modular way new App(); - Settings.Initialize(); ImageLoader.Initialize(); Portable portable = new Portable(); @@ -53,16 +52,5 @@ public void BuiltinQueryTest(string QueryText, string ResultTitle) Assert.IsTrue(result.Title.StartsWith(ResultTitle)); } - - [TestCase("powershell", "PowerShell")] - [TestCase("note", "Notepad")] - [TestCase("this pc", "This PC")] - public void Win32Test(string QueryText, string ResultTitle) - { - PluginPair pair = PluginManager.AllPlugins.Where(p => p.Plugin.GetType() == typeof(Plugin.Program.Main)).First(); - Query query = QueryBuilder.Build(QueryText.Trim(), new Dictionary()); - Result result = pair.Plugin.Query(query).OrderByDescending(r => r.Score).First(); - Assert.IsTrue(result.Title.StartsWith(ResultTitle)); - } } } diff --git a/Wox.Test/PluginProgramTest.cs b/Wox.Test/PluginProgramTest.cs new file mode 100644 index 000000000..b5d064fbe --- /dev/null +++ b/Wox.Test/PluginProgramTest.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using System.Linq; + +using NUnit.Framework; +using Wox.Core.Plugin; +using Wox.Plugin; + +namespace Wox.Test +{ + [TestFixture] + class PluginProgramTest + { + + private Plugin.Program.Main plugin; + + [OneTimeSetUp] + public void Setup() + { + plugin = new Plugin.Program.Main(); + plugin.loadSettings(); + Plugin.Program.Main.IndexPrograms(); + } + + [TestCase("powershell", "PowerShell")] + [TestCase("note", "Notepad")] + [TestCase("this pc", "This PC")] + public void Win32Test(string QueryText, string ResultTitle) + { + Query query = QueryBuilder.Build(QueryText.Trim(), new Dictionary()); + Result result = plugin.Query(query).OrderByDescending(r => r.Score).First(); + Assert.IsTrue(result.Title.StartsWith(ResultTitle)); + } + } +} diff --git a/Wox.Test/Wox.Test.csproj b/Wox.Test/Wox.Test.csproj index 42bbe199d..1f35773c3 100644 --- a/Wox.Test/Wox.Test.csproj +++ b/Wox.Test/Wox.Test.csproj @@ -48,6 +48,7 @@ Properties\SolutionAssemblyInfo.cs + From fc766ab78a7380be1f6d0f1cb117b393ddcf5bef Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 02:01:08 +0800 Subject: [PATCH 09/19] fix test --- Plugins/Wox.Plugin.Program/Main.cs | 10 +++++++++- Wox.Test/FuzzyMatcherTest.cs | 6 ++++++ Wox.Test/PluginManagerTest.cs | 1 + Wox.Test/PluginProgramTest.cs | 23 +++++++++++++++++++++-- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/Plugins/Wox.Plugin.Program/Main.cs b/Plugins/Wox.Plugin.Program/Main.cs index 0134b3aa6..b3063689e 100644 --- a/Plugins/Wox.Plugin.Program/Main.cs +++ b/Plugins/Wox.Plugin.Program/Main.cs @@ -99,7 +99,8 @@ public List Query(Query query) if (token.IsCancellationRequested) { return new List(); } OrderedParallelQuery sorted = resultRaw.AsParallel().OrderByDescending(r => r.Score); List results = new List(); - foreach (Result r in sorted) { + foreach (Result r in sorted) + { if (token.IsCancellationRequested) { return new List(); } var ignored = _settings.IgnoredSequence.Any(entry => { @@ -137,6 +138,13 @@ public void Init(PluginInitContext context) }); } + public void InitSync(PluginInitContext context) + { + _context = context; + loadSettings(); + IndexPrograms(); + } + public void loadSettings() { _settingsStorage = new PluginJsonStorage(); diff --git a/Wox.Test/FuzzyMatcherTest.cs b/Wox.Test/FuzzyMatcherTest.cs index 6a033db79..cd6f08cce 100644 --- a/Wox.Test/FuzzyMatcherTest.cs +++ b/Wox.Test/FuzzyMatcherTest.cs @@ -20,6 +20,12 @@ public class FuzzyMatcherTest private const string OneOneOneOne = "1111"; private const string MicrosoftSqlServerManagementStudio = "Microsoft SQL Server Management Studio"; + [OneTimeSetUp] + public void setUp() + { + Settings.Initialize(); + } + public List GetSearchStrings() => new List { diff --git a/Wox.Test/PluginManagerTest.cs b/Wox.Test/PluginManagerTest.cs index 4907f6a37..2b548b27a 100644 --- a/Wox.Test/PluginManagerTest.cs +++ b/Wox.Test/PluginManagerTest.cs @@ -21,6 +21,7 @@ public void setUp() { // todo remove i18n from application / ui, so it can be tested in a modular way new App(); + Settings.Initialize(); ImageLoader.Initialize(); Portable portable = new Portable(); diff --git a/Wox.Test/PluginProgramTest.cs b/Wox.Test/PluginProgramTest.cs index b5d064fbe..02d03fb29 100644 --- a/Wox.Test/PluginProgramTest.cs +++ b/Wox.Test/PluginProgramTest.cs @@ -2,8 +2,13 @@ using System.Linq; using NUnit.Framework; +using Wox.Core.Configuration; using Wox.Core.Plugin; +using Wox.Image; +using Wox.Infrastructure; +using Wox.Infrastructure.UserSettings; using Wox.Plugin; +using Wox.ViewModel; namespace Wox.Test { @@ -16,9 +21,23 @@ class PluginProgramTest [OneTimeSetUp] public void Setup() { + new App(); + Settings.Initialize(); + Portable portable = new Portable(); + SettingWindowViewModel settingsVm = new SettingWindowViewModel(portable); + StringMatcher stringMatcher = new StringMatcher(); + StringMatcher.Instance = stringMatcher; + stringMatcher.UserSettingSearchPrecision = Settings.Instance.QuerySearchPrecision; + PluginManager.LoadPlugins(Settings.Instance.PluginSettings); + MainViewModel mainVm = new MainViewModel(false); + PublicAPIInstance api = new PublicAPIInstance(settingsVm, mainVm); + PluginManager.InitializePlugins(api); + plugin = new Plugin.Program.Main(); - plugin.loadSettings(); - Plugin.Program.Main.IndexPrograms(); + plugin.InitSync(new PluginInitContext() + { + API = api, + }); } [TestCase("powershell", "PowerShell")] From 5c33c4252356bf52705a116dd74d50c9dc5beb07 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 02:13:18 +0800 Subject: [PATCH 10/19] pass test try again --- Wox.Test/PluginProgramTest.cs | 2 -- Wox/ViewModel/MainViewModel.cs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Wox.Test/PluginProgramTest.cs b/Wox.Test/PluginProgramTest.cs index 02d03fb29..6c12619c6 100644 --- a/Wox.Test/PluginProgramTest.cs +++ b/Wox.Test/PluginProgramTest.cs @@ -21,7 +21,6 @@ class PluginProgramTest [OneTimeSetUp] public void Setup() { - new App(); Settings.Initialize(); Portable portable = new Portable(); SettingWindowViewModel settingsVm = new SettingWindowViewModel(portable); @@ -31,7 +30,6 @@ public void Setup() PluginManager.LoadPlugins(Settings.Instance.PluginSettings); MainViewModel mainVm = new MainViewModel(false); PublicAPIInstance api = new PublicAPIInstance(settingsVm, mainVm); - PluginManager.InitializePlugins(api); plugin = new Plugin.Program.Main(); plugin.InitSync(new PluginInitContext() diff --git a/Wox/ViewModel/MainViewModel.cs b/Wox/ViewModel/MainViewModel.cs index fc2a9dc9f..221cd6325 100644 --- a/Wox/ViewModel/MainViewModel.cs +++ b/Wox/ViewModel/MainViewModel.cs @@ -74,9 +74,9 @@ public MainViewModel(bool useUI = true) History = new ResultsViewModel(_settings); _selectedResults = Results; - _translator = InternationalizationManager.Instance; if (useUI) { + _translator = InternationalizationManager.Instance; InitializeKeyCommands(); RegisterResultsUpdatedEvent(); From 46b296a0ed672d3e27f5b450d5c07b101dfb85b8 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 02:24:43 +0800 Subject: [PATCH 11/19] collect plugin exception info --- Wox.Core/Plugin/PluginConfig.cs | 2 ++ Wox.Core/Plugin/PluginManager.cs | 11 ++++++++++- Wox.Core/Plugin/PluginsLoader.cs | 9 +++++++++ Wox/ReportWindow.xaml.cs | 13 ++++++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Wox.Core/Plugin/PluginConfig.cs b/Wox.Core/Plugin/PluginConfig.cs index eb75b8e7a..0fab990ed 100644 --- a/Wox.Core/Plugin/PluginConfig.cs +++ b/Wox.Core/Plugin/PluginConfig.cs @@ -79,6 +79,8 @@ private static PluginMetadata GetPluginMetadata(string pluginDirectory) } catch (Exception e) { + e.Data.Add(nameof(configPath), configPath); + e.Data.Add(nameof(pluginDirectory), pluginDirectory); Logger.WoxError($"invalid json for config <{configPath}>", e); return null; } diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index d790d1109..b9c629c13 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -167,7 +167,16 @@ public static List QueryForPlugin(PluginPair pair, Query query) List results = new List(); var milliseconds = Logger.StopWatchDebug($"Query <{query.RawQuery}> Cost for {metadata.Name}", () => { - results = pair.Plugin.Query(query) ?? new List(); + try + { + results = pair.Plugin.Query(query) ?? new List(); + } + catch (Exception e) + { + e.Data.Add(nameof(pair.Metadata.ID), pair.Metadata.ID); + e.Data.Add(nameof(pair.Metadata.Name), pair.Metadata.Name); + e.Data.Add(nameof(pair.Metadata.Website), pair.Metadata.Website); + } UpdatePluginMetadata(results, metadata, query); }); metadata.QueryCount += 1; diff --git a/Wox.Core/Plugin/PluginsLoader.cs b/Wox.Core/Plugin/PluginsLoader.cs index 694a8c42c..5f1233a95 100644 --- a/Wox.Core/Plugin/PluginsLoader.cs +++ b/Wox.Core/Plugin/PluginsLoader.cs @@ -52,6 +52,9 @@ public static IEnumerable CSharpPlugins(List source) } catch (Exception e) { + e.Data.Add(nameof(metadata.ID), metadata.ID); + e.Data.Add(nameof(metadata.Name), metadata.Name); + e.Data.Add(nameof(metadata.Website), metadata.Website); Logger.WoxError($"Couldn't load assembly for {metadata.Name}", e); return; } @@ -63,6 +66,9 @@ public static IEnumerable CSharpPlugins(List source) } catch (InvalidOperationException e) { + e.Data.Add(nameof(metadata.ID), metadata.ID); + e.Data.Add(nameof(metadata.Name), metadata.Name); + e.Data.Add(nameof(metadata.Website), metadata.Website); Logger.WoxError($"Can't find class implement IPlugin for <{metadata.Name}>", e); return; } @@ -73,6 +79,9 @@ public static IEnumerable CSharpPlugins(List source) } catch (Exception e) { + e.Data.Add(nameof(metadata.ID), metadata.ID); + e.Data.Add(nameof(metadata.Name), metadata.Name); + e.Data.Add(nameof(metadata.Website), metadata.Website); Logger.WoxError($"Can't create instance for <{metadata.Name}>", e); return; } diff --git a/Wox/ReportWindow.xaml.cs b/Wox/ReportWindow.xaml.cs index 5bdcc488a..59833c6a2 100644 --- a/Wox/ReportWindow.xaml.cs +++ b/Wox/ReportWindow.xaml.cs @@ -28,7 +28,18 @@ private void SetException(Exception exception, string id) var directory = new DirectoryInfo(path); var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First(); - var paragraph = Hyperlink("You can help us to fix this issue by opening issue in: ", Constant.Issue); + Paragraph paragraph; + string websiteKey = nameof(Plugin.PluginPair.Metadata.Website); + if (exception.Data.Contains(websiteKey)) + { + paragraph = Hyperlink("You can help plugin author to fix this issue by opening issue in: ", exception.Data[websiteKey].ToString()); + paragraph.Inlines.Add($"Plugin Name {exception.Data[nameof(Plugin.PluginPair.Metadata.Name)]}"); + paragraph.Inlines.Add($"Plugin ID {exception.Data[nameof(Plugin.PluginPair.Metadata.ID)]}"); + } + else + { + paragraph = Hyperlink("You can help us to fix this issue by opening issue in: ", Constant.Issue); + } paragraph.Inlines.Add($"1. upload log file: {log.FullName}\n"); paragraph.Inlines.Add($"2. copy below exception message"); ErrorTextbox.Document.Blocks.Add(paragraph); From 033becabf3618a40b26497c1e6ded46ea2dfb2d0 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 02:30:19 +0800 Subject: [PATCH 12/19] update plugin metadata --- Plugins/Wox.Plugin.Calculator/plugin.json | 2 +- Plugins/Wox.Plugin.Color/plugin.json | 2 +- Plugins/Wox.Plugin.ControlPanel/plugin.json | 2 +- Plugins/Wox.Plugin.Folder/plugin.json | 2 +- Plugins/Wox.Plugin.PluginIndicator/plugin.json | 2 +- Plugins/Wox.Plugin.PluginManagement/plugin.json | 2 +- Plugins/Wox.Plugin.Program/Main.cs | 1 + Plugins/Wox.Plugin.Program/plugin.json | 2 +- Plugins/Wox.Plugin.Shell/plugin.json | 2 +- Plugins/Wox.Plugin.Sys/plugin.json | 2 +- Plugins/Wox.Plugin.Url/plugin.json | 2 +- Plugins/Wox.Plugin.WebSearch/plugin.json | 2 +- 12 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Plugins/Wox.Plugin.Calculator/plugin.json b/Plugins/Wox.Plugin.Calculator/plugin.json index 925099548..68fc32dd3 100644 --- a/Plugins/Wox.Plugin.Calculator/plugin.json +++ b/Plugins/Wox.Plugin.Calculator/plugin.json @@ -6,7 +6,7 @@ "Author":"cxfksword", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Caculator.dll", "IcoPath":"Images\\calculator.png" } \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Color/plugin.json b/Plugins/Wox.Plugin.Color/plugin.json index cd8a285d9..117ac793f 100644 --- a/Plugins/Wox.Plugin.Color/plugin.json +++ b/Plugins/Wox.Plugin.Color/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Color.dll", "IcoPath":"Images\\color.png" } diff --git a/Plugins/Wox.Plugin.ControlPanel/plugin.json b/Plugins/Wox.Plugin.ControlPanel/plugin.json index 7dc455209..260379b81 100644 --- a/Plugins/Wox.Plugin.ControlPanel/plugin.json +++ b/Plugins/Wox.Plugin.ControlPanel/plugin.json @@ -6,7 +6,7 @@ "Author":"CoenraadS", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.ControlPanel.dll", "IcoPath":"Images\\ControlPanel.png" } diff --git a/Plugins/Wox.Plugin.Folder/plugin.json b/Plugins/Wox.Plugin.Folder/plugin.json index 1d9ac7482..80b258633 100644 --- a/Plugins/Wox.Plugin.Folder/plugin.json +++ b/Plugins/Wox.Plugin.Folder/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Folder.dll", "IcoPath":"Images\\folder.png" } diff --git a/Plugins/Wox.Plugin.PluginIndicator/plugin.json b/Plugins/Wox.Plugin.PluginIndicator/plugin.json index a817248e2..92ce9c321 100644 --- a/Plugins/Wox.Plugin.PluginIndicator/plugin.json +++ b/Plugins/Wox.Plugin.PluginIndicator/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.PluginIndicator.dll", "IcoPath":"Images\\work.png" } diff --git a/Plugins/Wox.Plugin.PluginManagement/plugin.json b/Plugins/Wox.Plugin.PluginManagement/plugin.json index d2d219fc4..c19c3f012 100644 --- a/Plugins/Wox.Plugin.PluginManagement/plugin.json +++ b/Plugins/Wox.Plugin.PluginManagement/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.PluginManagement.dll", "IcoPath":"Images\\plugin.png" } diff --git a/Plugins/Wox.Plugin.Program/Main.cs b/Plugins/Wox.Plugin.Program/Main.cs index b3063689e..c01cd8dbe 100644 --- a/Plugins/Wox.Plugin.Program/Main.cs +++ b/Plugins/Wox.Plugin.Program/Main.cs @@ -56,6 +56,7 @@ public void Save() public List Query(Query query) { + if (_updateSource != null && !_updateSource.IsCancellationRequested) { _updateSource.Cancel(); diff --git a/Plugins/Wox.Plugin.Program/plugin.json b/Plugins/Wox.Plugin.Program/plugin.json index 09389080c..07c21b07c 100644 --- a/Plugins/Wox.Plugin.Program/plugin.json +++ b/Plugins/Wox.Plugin.Program/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Program.dll", "IcoPath":"Images\\program.png" } diff --git a/Plugins/Wox.Plugin.Shell/plugin.json b/Plugins/Wox.Plugin.Shell/plugin.json index 4599bdcd0..9d4a10a5d 100644 --- a/Plugins/Wox.Plugin.Shell/plugin.json +++ b/Plugins/Wox.Plugin.Shell/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Shell.dll", "IcoPath":"Images\\shell.png" } diff --git a/Plugins/Wox.Plugin.Sys/plugin.json b/Plugins/Wox.Plugin.Sys/plugin.json index 372294cdd..4135c686d 100644 --- a/Plugins/Wox.Plugin.Sys/plugin.json +++ b/Plugins/Wox.Plugin.Sys/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Sys.dll", "IcoPath":"Images\\lock.png" } diff --git a/Plugins/Wox.Plugin.Url/plugin.json b/Plugins/Wox.Plugin.Url/plugin.json index f0048014c..7da5e2e56 100644 --- a/Plugins/Wox.Plugin.Url/plugin.json +++ b/Plugins/Wox.Plugin.Url/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Url.dll", "IcoPath":"Images\\url.png" } diff --git a/Plugins/Wox.Plugin.WebSearch/plugin.json b/Plugins/Wox.Plugin.WebSearch/plugin.json index b8b5e51b3..6e9dd5de4 100644 --- a/Plugins/Wox.Plugin.WebSearch/plugin.json +++ b/Plugins/Wox.Plugin.WebSearch/plugin.json @@ -28,7 +28,7 @@ "Author": "Wox", "Version": "1.0.0", "Language": "csharp", - "Website": "http://www.wox.one/plugin", + "Website": "https://github.com/Wox-launcher/Wox", "ExecuteFileName": "Wox.Plugin.WebSearch.dll", "IcoPath": "Images\\web_search.png" } From b7a295823f77e39a644e502b0bc7757974670f7d Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 02:30:40 +0800 Subject: [PATCH 13/19] remove duplicate exception handling --- Wox.Core/Plugin/PluginManager.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index b9c629c13..ef4f4f3e1 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -167,16 +167,7 @@ public static List QueryForPlugin(PluginPair pair, Query query) List results = new List(); var milliseconds = Logger.StopWatchDebug($"Query <{query.RawQuery}> Cost for {metadata.Name}", () => { - try - { - results = pair.Plugin.Query(query) ?? new List(); - } - catch (Exception e) - { - e.Data.Add(nameof(pair.Metadata.ID), pair.Metadata.ID); - e.Data.Add(nameof(pair.Metadata.Name), pair.Metadata.Name); - e.Data.Add(nameof(pair.Metadata.Website), pair.Metadata.Website); - } + results = pair.Plugin.Query(query) ?? new List(); UpdatePluginMetadata(results, metadata, query); }); metadata.QueryCount += 1; @@ -195,6 +186,9 @@ public static List QueryForPlugin(PluginPair pair, Query query) } catch (Exception e) { + e.Data.Add(nameof(pair.Metadata.ID), pair.Metadata.ID); + e.Data.Add(nameof(pair.Metadata.Name), pair.Metadata.Name); + e.Data.Add(nameof(pair.Metadata.Website), pair.Metadata.Website); Logger.WoxError($"Exception for plugin <{pair.Metadata.Name}> when query <{query}>", e); return new List(); } From 61c2b443b5b8cf22c3e9364ab72b62139bdd856c Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 02:32:28 +0800 Subject: [PATCH 14/19] check exist --- Wox/ReportWindow.xaml.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Wox/ReportWindow.xaml.cs b/Wox/ReportWindow.xaml.cs index 59833c6a2..5866d2d67 100644 --- a/Wox/ReportWindow.xaml.cs +++ b/Wox/ReportWindow.xaml.cs @@ -33,8 +33,16 @@ private void SetException(Exception exception, string id) if (exception.Data.Contains(websiteKey)) { paragraph = Hyperlink("You can help plugin author to fix this issue by opening issue in: ", exception.Data[websiteKey].ToString()); - paragraph.Inlines.Add($"Plugin Name {exception.Data[nameof(Plugin.PluginPair.Metadata.Name)]}"); - paragraph.Inlines.Add($"Plugin ID {exception.Data[nameof(Plugin.PluginPair.Metadata.ID)]}"); + string nameKey = nameof(Plugin.PluginPair.Metadata.Name); + if (exception.Data.Contains(nameKey)) + { + paragraph.Inlines.Add($"Plugin Name {exception.Data[nameKey]}"); + } + string idKey = nameof(Plugin.PluginPair.Metadata.ID); + if (exception.Data.Contains(idKey)) + { + paragraph.Inlines.Add($"Plugin ID {exception.Data[idKey]}"); + } } else { From 2b21f9644ccb950c795fe5e33b12bec5eb9ed2bd Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 02:33:53 +0800 Subject: [PATCH 15/19] collect more plugin info --- Wox.Core/Plugin/PluginManager.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index ef4f4f3e1..ce40d1e70 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -123,6 +123,9 @@ public static void InitializePlugins(IPublicAPI api) } catch (Exception e) { + e.Data.Add(nameof(pair.Metadata.ID), pair.Metadata.ID); + e.Data.Add(nameof(pair.Metadata.Name), pair.Metadata.Name); + e.Data.Add(nameof(pair.Metadata.Website), pair.Metadata.Website); Logger.WoxError($"Fail to Init plugin: {pair.Metadata.Name}", e); pair.Metadata.Disabled = true; failedPlugins.Enqueue(pair); From f93d2abc92e96bb4425f50b4c4acf3fd92692cb0 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 02:42:26 +0800 Subject: [PATCH 16/19] do not report network error --- Wox.Core/Updater.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Wox.Core/Updater.cs b/Wox.Core/Updater.cs index 3545629d3..582e5a3dd 100644 --- a/Wox.Core/Updater.cs +++ b/Wox.Core/Updater.cs @@ -43,7 +43,7 @@ public async Task UpdateApp(bool silentIfLatestVersion = true, bool updateToPrer } catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException) { - Logger.WoxError($"Check your connection and proxy settings to api.github.com.", e); + Logger.WoxError($"Check your connection and proxy settings to api.github.com. {e.Message}"); updateManager.Dispose(); return; } @@ -67,7 +67,7 @@ public async Task UpdateApp(bool silentIfLatestVersion = true, bool updateToPrer } catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException) { - Logger.WoxError($"Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e); + Logger.WoxError($"Check your connection and proxy settings to github-cloud.s3.amazonaws.com. {e.Message}"); updateManager.Dispose(); return; } @@ -86,11 +86,11 @@ public async Task UpdateApp(bool silentIfLatestVersion = true, bool updateToPrer } catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException) { - Logger.WoxError($"Please check your connection and proxy settings to api.github.com.", e); + Logger.WoxError($"Please check your connection and proxy settings {e.Message}"); } catch (Exception e) { - Logger.WoxError($"cannot check update", e); + Logger.WoxError($"cannot check update {e.Message}"); } } From bc15beac7d51ea45100d0de91a9c07fbd911b3e8 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 02:45:41 +0800 Subject: [PATCH 17/19] bump version --- Wox.Plugin/Feature.cs | 4 ++-- Wox.Plugin/Features/IContextMenu.cs | 2 +- Wox.Plugin/Features/IExclusiveQuery.cs | 2 +- Wox.Plugin/Features/IInstantQuery.cs | 2 +- Wox.Plugin/IPublicAPI.cs | 2 +- Wox.Plugin/Query.cs | 6 +++--- Wox/PublicAPIInstance.cs | 2 +- appveyor.yml | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Wox.Plugin/Feature.cs b/Wox.Plugin/Feature.cs index 6d1aa37fd..54f493634 100644 --- a/Wox.Plugin/Feature.cs +++ b/Wox.Plugin/Feature.cs @@ -11,10 +11,10 @@ public interface IContextMenu : IFeatures List LoadContextMenus(Result selectedResult); } - [Obsolete("If a plugin has a action keyword, then it is exclusive. This interface will be remove in v1.3.0")] + [Obsolete("If a plugin has a action keyword, then it is exclusive. This interface will be remove in v1.4.0")] public interface IExclusiveQuery : IFeatures { - [Obsolete("If a plugin has a action keyword, then it is exclusive. This method will be remove in v1.3.0")] + [Obsolete("If a plugin has a action keyword, then it is exclusive. This method will be remove in v1.4.0")] bool IsExclusiveQuery(Query query); } diff --git a/Wox.Plugin/Features/IContextMenu.cs b/Wox.Plugin/Features/IContextMenu.cs index f30b66abf..8c827fe1a 100644 --- a/Wox.Plugin/Features/IContextMenu.cs +++ b/Wox.Plugin/Features/IContextMenu.cs @@ -4,6 +4,6 @@ namespace Wox.Plugin.Features { [Obsolete("Delete Wox.Plugin.Features using directive, " + "and use Wox.Plugin.Feature.IContextMenu instead, " + - "this method will be removed in v1.3.0")] + "this method will be removed in v1.4.0")] public interface IContextMenu { } } \ No newline at end of file diff --git a/Wox.Plugin/Features/IExclusiveQuery.cs b/Wox.Plugin/Features/IExclusiveQuery.cs index a43303350..2e0af6584 100644 --- a/Wox.Plugin/Features/IExclusiveQuery.cs +++ b/Wox.Plugin/Features/IExclusiveQuery.cs @@ -4,6 +4,6 @@ namespace Wox.Plugin.Features { [Obsolete("Delete Wox.Plugin.Features using directive, " + "and use Wox.Plugin.Feature.IInstantQuery instead, " + - "this method will be removed in v1.3.0")] + "this method will be removed in v1.4.0")] public interface IExclusiveQuery { } } diff --git a/Wox.Plugin/Features/IInstantQuery.cs b/Wox.Plugin/Features/IInstantQuery.cs index 2fe81fad7..11004c404 100644 --- a/Wox.Plugin/Features/IInstantQuery.cs +++ b/Wox.Plugin/Features/IInstantQuery.cs @@ -4,6 +4,6 @@ namespace Wox.Plugin.Features { [Obsolete("Delete Wox.Plugin.Features using directive, " + "and use Wox.Plugin.Feature.IInstantQuery instead, " + - "this method will be removed in v1.3.0")] + "this method will be removed in v1.4.0")] public interface IInstantQuery { } } \ No newline at end of file diff --git a/Wox.Plugin/IPublicAPI.cs b/Wox.Plugin/IPublicAPI.cs index 3c5b34277..732e3fb17 100644 --- a/Wox.Plugin/IPublicAPI.cs +++ b/Wox.Plugin/IPublicAPI.cs @@ -14,7 +14,7 @@ public interface IPublicAPI /// /// /// - [Obsolete("This method will be removed in Wox 1.3")] + [Obsolete("This method will be removed in Wox 1.4")] void PushResults(Query query, PluginMetadata plugin, List results); /// diff --git a/Wox.Plugin/Query.cs b/Wox.Plugin/Query.cs index 07b640ab8..79ed20464 100644 --- a/Wox.Plugin/Query.cs +++ b/Wox.Plugin/Query.cs @@ -95,13 +95,13 @@ private string SplitSearch(int index) public override string ToString() => RawQuery; - [Obsolete("Use ActionKeyword, this property will be removed in v1.3.0")] + [Obsolete("Use ActionKeyword, this property will be removed in v1.4.0")] public string ActionName { get; internal set; } - [Obsolete("Use Search instead, this property will be removed in v1.3.0")] + [Obsolete("Use Search instead, this property will be removed in v1.4.0")] public List ActionParameters { get; internal set; } - [Obsolete("Use Search instead, this method will be removed in v1.3.0")] + [Obsolete("Use Search instead, this method will be removed in v1.4.0")] public string GetAllRemainingParameter() => Search; } } diff --git a/Wox/PublicAPIInstance.cs b/Wox/PublicAPIInstance.cs index c58533320..2a94b173e 100644 --- a/Wox/PublicAPIInstance.cs +++ b/Wox/PublicAPIInstance.cs @@ -143,7 +143,7 @@ public List GetAllPlugins() public event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent; - [Obsolete("This will be removed in Wox 1.3")] + [Obsolete("This will be removed in Wox 1.4")] public void PushResults(Query query, PluginMetadata plugin, List results) { results.ForEach(o => diff --git a/appveyor.yml b/appveyor.yml index cd566c57e..c91070025 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 1.3.{build} +version: 1.4.{build} image: Visual Studio 2019 configuration: Release assembly_info: From 453b65833013950ba51ce4e34ae7d0551f81e7cd Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 03:06:10 +0800 Subject: [PATCH 18/19] remove useless library --- Wox.Infrastructure/Wox.Infrastructure.csproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index f26fbf195..eb53f8999 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -91,9 +91,6 @@ 1.1.4 - - 5.10.2 - 9.0.1 From dc737ab7c06faca51c3e8f5fa4206b0820c9d651 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 20 May 2020 03:07:31 +0800 Subject: [PATCH 19/19] Found conflicts between different versions of the same dependent assembly. Found conflicts between different versions of the same dependent assembly. No way to resolve conflict between "System.Runtime.InteropServices.RuntimeInformation --- Wox/Wox.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 93997ddd0..aa1426dcc 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -2,6 +2,8 @@ + + true Debug AnyCPU {DB90F671-D861-46BB-93A3-F1304F5BA1C5}