From 701ccfdbccc6d08f484b16d883e583707be6c8bf Mon Sep 17 00:00:00 2001
From: Avneet Kaur <72103212+avneet-kr@users.noreply.github.com>
Date: Mon, 19 Oct 2020 19:48:51 -0700
Subject: [PATCH] FxCopAnalyzer fix for Wox.Core (PR#2of3) - Removing unused
JsonRPC files (#7211)
* Removed unused JsonRPC related files and references
- Files Removed: ExecutablePlugin.cs, JsonRPCClientRequestModel.cs, JsonRPCErrorModel.cs, JsonRPCModelBase.cs, JsonRPCPlugin.cs, JsonRPCQueryResponseModel.cs, JsonRPCRequestModel.cs, JsonRPCResponseModel.cs, JsonRPCResult.cs, JsonRPCServerRequestModel.cs
- Modified PluginsLoader.cs:
- Removed method ExecutablePlugins
- In method Plugins(): Removed call to ExecutablePlugins()
* Suppressed warning for catching general exception type
* Addressing comments: Replaced in source suppression with attribute and logged exception information
---
.../Wox.Core/Plugin/ExecutablePlugin.cs | 60 -----
.../Plugin/JsonRPCClientRequestModel.cs | 34 ---
.../Wox.Core/Plugin/JsonRPCErrorModel.cs | 29 ---
.../Wox.Core/Plugin/JsonRPCModelBase.cs | 25 --
.../launcher/Wox.Core/Plugin/JsonRPCPlugin.cs | 227 ------------------
.../Plugin/JsonRPCQueryResponseModel.cs | 27 ---
.../Wox.Core/Plugin/JsonRPCRequestModel.cs | 78 ------
.../Wox.Core/Plugin/JsonRPCResponseModel.cs | 27 ---
.../launcher/Wox.Core/Plugin/JsonRPCResult.cs | 32 ---
.../Plugin/JsonRPCServerRequestModel.cs | 32 ---
.../Wox.Core/Plugin/PluginInstaller.cs | 6 +-
.../launcher/Wox.Core/Plugin/PluginsLoader.cs | 17 +-
12 files changed, 6 insertions(+), 588 deletions(-)
delete mode 100644 src/modules/launcher/Wox.Core/Plugin/ExecutablePlugin.cs
delete mode 100644 src/modules/launcher/Wox.Core/Plugin/JsonRPCClientRequestModel.cs
delete mode 100644 src/modules/launcher/Wox.Core/Plugin/JsonRPCErrorModel.cs
delete mode 100644 src/modules/launcher/Wox.Core/Plugin/JsonRPCModelBase.cs
delete mode 100644 src/modules/launcher/Wox.Core/Plugin/JsonRPCPlugin.cs
delete mode 100644 src/modules/launcher/Wox.Core/Plugin/JsonRPCQueryResponseModel.cs
delete mode 100644 src/modules/launcher/Wox.Core/Plugin/JsonRPCRequestModel.cs
delete mode 100644 src/modules/launcher/Wox.Core/Plugin/JsonRPCResponseModel.cs
delete mode 100644 src/modules/launcher/Wox.Core/Plugin/JsonRPCResult.cs
delete mode 100644 src/modules/launcher/Wox.Core/Plugin/JsonRPCServerRequestModel.cs
diff --git a/src/modules/launcher/Wox.Core/Plugin/ExecutablePlugin.cs b/src/modules/launcher/Wox.Core/Plugin/ExecutablePlugin.cs
deleted file mode 100644
index 0a595a4202..0000000000
--- a/src/modules/launcher/Wox.Core/Plugin/ExecutablePlugin.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// 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 Wox.Plugin;
-
-namespace Wox.Core.Plugin
-{
- internal class ExecutablePlugin : JsonRPCPlugin
- {
- private readonly ProcessStartInfo _startInfo;
-
- public override string SupportedLanguage { get; set; } = AllowedLanguage.Executable;
-
- public ExecutablePlugin(string filename)
- {
- _startInfo = new ProcessStartInfo
- {
- FileName = filename,
- UseShellExecute = false,
- CreateNoWindow = true,
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- };
- }
-
- protected override string ExecuteQuery(Query query)
- {
- JsonRPCServerRequestModel request = new JsonRPCServerRequestModel
- {
- Method = "query",
- Parameters = new object[] { query.Search },
- };
-
- _startInfo.Arguments = $"\"{request}\"";
-
- return Execute(_startInfo);
- }
-
- protected override string ExecuteCallback(JsonRPCRequestModel rpcRequest)
- {
- _startInfo.Arguments = $"\"{rpcRequest}\"";
- return Execute(_startInfo);
- }
-
- protected override string ExecuteContextMenu(Result selectedResult)
- {
- JsonRPCServerRequestModel request = new JsonRPCServerRequestModel
- {
- Method = "contextmenu",
- Parameters = new object[] { selectedResult.ContextData },
- };
-
- _startInfo.Arguments = $"\"{request}\"";
-
- return Execute(_startInfo);
- }
- }
-}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCClientRequestModel.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCClientRequestModel.cs
deleted file mode 100644
index 22cdb05b17..0000000000
--- a/src/modules/launcher/Wox.Core/Plugin/JsonRPCClientRequestModel.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
- * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
- * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
- *
- * When execute a query:
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCQueryResponseModel--------- client
- *
- * When execute a action (which mean user select an item in reulst item):
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCResponseModel-------------- client
- *
- */
-
-namespace Wox.Core.Plugin
-{
- ///
- /// Json RPC Request(in query response) that client sent to Wox
- ///
- public class JsonRPCClientRequestModel : JsonRPCRequestModel
- {
- public bool DontHideAfterAction { get; set; }
-
- public override string ToString()
- {
- string rpc = base.ToString();
- return rpc + "}";
- }
- }
-}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCErrorModel.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCErrorModel.cs
deleted file mode 100644
index 7130d1e604..0000000000
--- a/src/modules/launcher/Wox.Core/Plugin/JsonRPCErrorModel.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
- * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
- * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
- *
- * When execute a query:
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCQueryResponseModel--------- client
- *
- * When execute a action (which mean user select an item in reulst item):
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCResponseModel-------------- client
- *
- */
-
-namespace Wox.Core.Plugin
-{
- public class JsonRPCErrorModel
- {
- public int Code { get; set; }
-
- public string Message { get; set; }
-
- public string Data { get; set; }
- }
-}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCModelBase.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCModelBase.cs
deleted file mode 100644
index 9040a345c1..0000000000
--- a/src/modules/launcher/Wox.Core/Plugin/JsonRPCModelBase.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
- * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
- * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
- *
- * When execute a query:
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCQueryResponseModel--------- client
- *
- * When execute a action (which mean user select an item in reulst item):
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCResponseModel-------------- client
- *
- */
-
-namespace Wox.Core.Plugin
-{
- public class JsonRPCModelBase
- {
- public int Id { get; set; }
- }
-}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCPlugin.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCPlugin.cs
deleted file mode 100644
index ae0512eea1..0000000000
--- a/src/modules/launcher/Wox.Core/Plugin/JsonRPCPlugin.cs
+++ /dev/null
@@ -1,227 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// 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;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Windows.Forms;
-using Newtonsoft.Json;
-using Wox.Infrastructure.Logger;
-using Wox.Plugin;
-
-namespace Wox.Core.Plugin
-{
- ///
- /// Represent the plugin that using JsonPRC
- /// every JsonRPC plugin should has its own plugin instance
- ///
- internal abstract class JsonRPCPlugin : IPlugin, IContextMenu
- {
- protected PluginInitContext Context { get; set; }
-
- public const string JsonRPC = "JsonRPC";
-
- ///
- /// Gets or sets the language this JsonRPCPlugin support
- ///
- public abstract string SupportedLanguage { get; set; }
-
- protected abstract string ExecuteQuery(Query query);
-
- protected abstract string ExecuteCallback(JsonRPCRequestModel rpcRequest);
-
- protected abstract string ExecuteContextMenu(Result selectedResult);
-
- public List Query(Query query)
- {
- string output = ExecuteQuery(query);
- try
- {
- return DeserializedResult(output);
- }
- catch (Exception e)
- {
- Log.Exception($"Exception when query <{query}>", e, GetType());
- return null;
- }
- }
-
- public List LoadContextMenus(Result selectedResult)
- {
- string output = ExecuteContextMenu(selectedResult);
- try
- {
- // This should not hit. If it does it's because Wox shares the same interface for querying context menu items as well as search results. In this case please file a bug.
- // To my knowledge we aren't supporting this JSonRPC commands in Launcher, and am not able to repro this, but I will leave this here for the time being in case I'm proven wrong.
- // We should remove this, or identify and test officially supported use cases and Deserialize this properly.
- // return DeserializedResult(output);
- throw new NotImplementedException();
- }
- catch (Exception e)
- {
- Log.Exception($"THIS IS A BUG - Exception on result <{selectedResult}>", e, GetType());
- return null;
- }
- }
-
- private List DeserializedResult(string output)
- {
- if (!string.IsNullOrEmpty(output))
- {
- List results = new List();
-
- JsonRPCQueryResponseModel queryResponseModel = JsonConvert.DeserializeObject(output);
- if (queryResponseModel.Result == null)
- {
- return null;
- }
-
- foreach (JsonRPCResult result in queryResponseModel.Result)
- {
- JsonRPCResult result1 = result;
- result.Action = c =>
- {
- if (result1.JsonRPCAction == null)
- {
- return false;
- }
-
- if (!string.IsNullOrEmpty(result1.JsonRPCAction.Method))
- {
- if (result1.JsonRPCAction.Method.StartsWith("Wox."))
- {
- ExecuteWoxAPI(result1.JsonRPCAction.Method.Substring(4), result1.JsonRPCAction.Parameters);
- }
- else
- {
- string actionResponse = ExecuteCallback(result1.JsonRPCAction);
- JsonRPCRequestModel jsonRpcRequestModel = JsonConvert.DeserializeObject(actionResponse);
- if (jsonRpcRequestModel != null
- && !string.IsNullOrEmpty(jsonRpcRequestModel.Method)
- && jsonRpcRequestModel.Method.StartsWith("Wox."))
- {
- ExecuteWoxAPI(jsonRpcRequestModel.Method.Substring(4), jsonRpcRequestModel.Parameters);
- }
- }
- }
-
- return !result1.JsonRPCAction.DontHideAfterAction;
- };
- results.Add(result);
- }
-
- return results;
- }
- else
- {
- return null;
- }
- }
-
- private void ExecuteWoxAPI(string method, object[] parameters)
- {
- MethodInfo methodInfo = PluginManager.API.GetType().GetMethod(method);
- if (methodInfo != null)
- {
- try
- {
- methodInfo.Invoke(PluginManager.API, parameters);
- }
- catch (Exception)
- {
-#if DEBUG
- {
- throw;
- }
-#endif
- }
- }
- }
-
- ///
- /// Execute external program and return the output
- ///
- /// file to execute
- /// args to pass in to that exe
- /// results
- protected string Execute(string fileName, string arguments)
- {
- ProcessStartInfo start = new ProcessStartInfo
- {
- FileName = fileName,
- Arguments = arguments,
- UseShellExecute = false,
- CreateNoWindow = true,
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- };
-
- return Execute(start);
- }
-
- protected string Execute(ProcessStartInfo startInfo)
- {
- try
- {
- using (var process = Process.Start(startInfo))
- {
- if (process != null)
- {
- using (var standardOutput = process.StandardOutput)
- {
- var result = standardOutput.ReadToEnd();
- if (string.IsNullOrEmpty(result))
- {
- using (var standardError = process.StandardError)
- {
- var error = standardError.ReadToEnd();
- if (!string.IsNullOrEmpty(error))
- {
- Log.Error(error, GetType());
-
- return string.Empty;
- }
- else
- {
- Log.Error("Empty standard output and standard error.", GetType());
-
- return string.Empty;
- }
- }
- }
- else if (result.StartsWith("DEBUG:"))
- {
- MessageBox.Show(new Form { TopMost = true }, result.Substring(6));
-
- return string.Empty;
- }
- else
- {
- return result;
- }
- }
- }
- else
- {
- Log.Error("Can't start new process", GetType());
-
- return string.Empty;
- }
- }
- }
- catch (Exception e)
- {
- Log.Exception($"Exception for filename <{startInfo.FileName}> with argument <{startInfo.Arguments}>", e, GetType());
-
- return string.Empty;
- }
- }
-
- public void Init(PluginInitContext ctx)
- {
- Context = ctx;
- }
- }
-}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCQueryResponseModel.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCQueryResponseModel.cs
deleted file mode 100644
index 9ded1a4fcf..0000000000
--- a/src/modules/launcher/Wox.Core/Plugin/JsonRPCQueryResponseModel.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
- * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
- * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
- *
- * When execute a query:
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCQueryResponseModel--------- client
- *
- * When execute a action (which mean user select an item in reulst item):
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCResponseModel-------------- client
- *
- */
-
-using System.Collections.Generic;
-
-namespace Wox.Core.Plugin
-{
- public class JsonRPCQueryResponseModel : JsonRPCResponseModel
- {
- public new List Result { get; set; }
- }
-}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCRequestModel.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCRequestModel.cs
deleted file mode 100644
index 967cd1930b..0000000000
--- a/src/modules/launcher/Wox.Core/Plugin/JsonRPCRequestModel.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
- * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
- * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
- *
- * When execute a query:
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCQueryResponseModel--------- client
- *
- * When execute a action (which mean user select an item in reulst item):
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCResponseModel-------------- client
- *
- */
-
-using System.Linq;
-
-namespace Wox.Core.Plugin
-{
- public class JsonRPCRequestModel : JsonRPCModelBase
- {
- public string Method { get; set; }
-
- public object[] Parameters { get; set; }
-
- public override string ToString()
- {
- string rpc = string.Empty;
- if (Parameters != null && Parameters.Length > 0)
- {
- string parameters = Parameters.Aggregate("[", (current, o) => current + (GetParameterByType(o) + ","));
- parameters = parameters.Substring(0, parameters.Length - 1) + "]";
- rpc = string.Format(@"{{\""method\"":\""{0}\"",\""parameters\"":{1}", Method, parameters);
- }
- else
- {
- rpc = string.Format(@"{{\""method\"":\""{0}\"",\""parameters\"":[]", Method);
- }
-
- return rpc;
- }
-
- private string GetParameterByType(object parameter)
- {
- if (parameter == null)
- {
- return "null";
- }
-
- if (parameter is string)
- {
- return string.Format(@"\""{0}\""", ReplaceEscapes(parameter.ToString()));
- }
-
- if (parameter is int || parameter is float || parameter is double)
- {
- return string.Format(@"{0}", parameter);
- }
-
- if (parameter is bool)
- {
- return string.Format(@"{0}", parameter.ToString().ToLower());
- }
-
- return parameter.ToString();
- }
-
- private string ReplaceEscapes(string str)
- {
- return str.Replace(@"\", @"\\") // Escapes in ProcessStartInfo
- .Replace(@"\", @"\\") // Escapes itself when passed to client
- .Replace(@"""", @"\\""""");
- }
- }
-}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCResponseModel.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCResponseModel.cs
deleted file mode 100644
index a6b5723a2b..0000000000
--- a/src/modules/launcher/Wox.Core/Plugin/JsonRPCResponseModel.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
- * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
- * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
- *
- * When execute a query:
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCQueryResponseModel--------- client
- *
- * When execute a action (which mean user select an item in reulst item):
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCResponseModel-------------- client
- *
- */
-
-namespace Wox.Core.Plugin
-{
- public class JsonRPCResponseModel : JsonRPCModelBase
- {
- public string Result { get; set; }
-
- public JsonRPCErrorModel Error { get; set; }
- }
-}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCResult.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCResult.cs
deleted file mode 100644
index a9eb036957..0000000000
--- a/src/modules/launcher/Wox.Core/Plugin/JsonRPCResult.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
- * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
- * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
- *
- * When execute a query:
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCQueryResponseModel--------- client
- *
- * When execute a action (which mean user select an item in reulst item):
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCResponseModel-------------- client
- *
- */
-
-using Wox.Plugin;
-
-namespace Wox.Core.Plugin
-{
- ///
- /// Represent the json-rpc result item that client send to Wox
- /// Typically, we will send back this request model to client after user select the result item
- /// But if the request method starts with "Wox.", we will invoke the public APIs we expose.
- ///
- public class JsonRPCResult : Result
- {
- public JsonRPCClientRequestModel JsonRPCAction { get; set; }
- }
-}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCServerRequestModel.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCServerRequestModel.cs
deleted file mode 100644
index a7d7f57b95..0000000000
--- a/src/modules/launcher/Wox.Core/Plugin/JsonRPCServerRequestModel.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
- * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
- * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
- *
- * When execute a query:
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCQueryResponseModel--------- client
- *
- * When execute a action (which mean user select an item in reulst item):
- * Wox -------JsonRPCServerRequestModel--------> client
- * Wox <------JsonRPCResponseModel-------------- client
- *
- */
-
-namespace Wox.Core.Plugin
-{
- ///
- /// Json RPC Request that Wox sent to client
- ///
- public class JsonRPCServerRequestModel : JsonRPCRequestModel
- {
- public override string ToString()
- {
- string rpc = base.ToString();
- return rpc + "}";
- }
- }
-}
diff --git a/src/modules/launcher/Wox.Core/Plugin/PluginInstaller.cs b/src/modules/launcher/Wox.Core/Plugin/PluginInstaller.cs
index 38f74320ee..e70745189d 100644
--- a/src/modules/launcher/Wox.Core/Plugin/PluginInstaller.cs
+++ b/src/modules/launcher/Wox.Core/Plugin/PluginInstaller.cs
@@ -4,9 +4,11 @@
using System;
using System.IO;
+using System.Reflection;
using System.Windows;
using ICSharpCode.SharpZipLib.Zip;
using Newtonsoft.Json;
+using Wox.Infrastructure.Logger;
using Wox.Plugin;
namespace Wox.Core.Plugin
@@ -96,6 +98,7 @@ namespace Wox.Core.Plugin
}
}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "All exception information is being logged")]
private static PluginMetadata GetMetadataFromJson(string pluginDirectory)
{
string configPath = Path.Combine(pluginDirectory, "plugin.json");
@@ -111,9 +114,10 @@ namespace Wox.Core.Plugin
metadata = JsonConvert.DeserializeObject(File.ReadAllText(configPath));
metadata.PluginDirectory = pluginDirectory;
}
- catch (Exception)
+ catch (Exception e)
{
string error = $"Parse plugin config {configPath} failed: json format is not valid";
+ Log.Exception(error, e, MethodBase.GetCurrentMethod().DeclaringType);
#if DEBUG
{
throw new Exception(error);
diff --git a/src/modules/launcher/Wox.Core/Plugin/PluginsLoader.cs b/src/modules/launcher/Wox.Core/Plugin/PluginsLoader.cs
index 61b209d80e..d946d7fc14 100644
--- a/src/modules/launcher/Wox.Core/Plugin/PluginsLoader.cs
+++ b/src/modules/launcher/Wox.Core/Plugin/PluginsLoader.cs
@@ -20,9 +20,7 @@ namespace Wox.Core.Plugin
public static List Plugins(List metadatas)
{
var csharpPlugins = CSharpPlugins(metadatas).ToList();
- var executablePlugins = ExecutablePlugins(metadatas);
- var plugins = csharpPlugins.Concat(executablePlugins).ToList();
- return plugins;
+ return csharpPlugins;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "All exception information is being logged")]
@@ -87,18 +85,5 @@ namespace Wox.Core.Plugin
return plugins;
}
-
- public static IEnumerable ExecutablePlugins(IEnumerable source)
- {
- var metadatas = source.Where(o => o.Language.ToUpperInvariant() == AllowedLanguage.Executable);
-
- var plugins = metadatas.Select(metadata => new PluginPair
- {
- Plugin = new ExecutablePlugin(metadata.ExecuteFilePath),
- Metadata = metadata,
- });
-
- return plugins;
- }
}
}