style cop wox.core whitespace changes (#5744)

* whitespace changes

* undoing csproj tweak to keep stylecop off
This commit is contained in:
Clint Rutkas 2020-08-06 16:51:47 -07:00 committed by GitHub
parent b95a1fb604
commit d7994ca67d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 54 additions and 29 deletions

View File

@ -10,6 +10,7 @@ namespace Wox.Core.Plugin
internal class ExecutablePlugin : JsonRPCPlugin internal class ExecutablePlugin : JsonRPCPlugin
{ {
private readonly ProcessStartInfo _startInfo; private readonly ProcessStartInfo _startInfo;
public override string SupportedLanguage { get; set; } = AllowedLanguage.Executable; public override string SupportedLanguage { get; set; } = AllowedLanguage.Executable;
public ExecutablePlugin(string filename) public ExecutablePlugin(string filename)

View File

@ -1,4 +1,7 @@
 // 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, /* 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 * 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. * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
@ -74,18 +77,22 @@ namespace Wox.Core.Plugin
{ {
return "null"; return "null";
} }
if (parameter is string) if (parameter is string)
{ {
return string.Format(@"\""{0}\""", ReplaceEscapes(parameter.ToString())); return string.Format(@"\""{0}\""", ReplaceEscapes(parameter.ToString()));
} }
if (parameter is int || parameter is float || parameter is double) if (parameter is int || parameter is float || parameter is double)
{ {
return string.Format(@"{0}", parameter); return string.Format(@"{0}", parameter);
} }
if (parameter is bool) if (parameter is bool)
{ {
return string.Format(@"{0}", parameter.ToString().ToLower()); return string.Format(@"{0}", parameter.ToString().ToLower());
} }
return parameter.ToString(); return parameter.ToString();
} }

View File

@ -28,7 +28,9 @@ namespace Wox.Core.Plugin
public abstract string SupportedLanguage { get; set; } public abstract string SupportedLanguage { get; set; }
protected abstract string ExecuteQuery(Query query); protected abstract string ExecuteQuery(Query query);
protected abstract string ExecuteCallback(JsonRPCRequestModel rpcRequest); protected abstract string ExecuteCallback(JsonRPCRequestModel rpcRequest);
protected abstract string ExecuteContextMenu(Result selectedResult); protected abstract string ExecuteContextMenu(Result selectedResult);
public List<Result> Query(Query query) public List<Result> Query(Query query)
@ -97,10 +99,12 @@ namespace Wox.Core.Plugin
} }
} }
} }
return !result1.JsonRPCAction.DontHideAfterAction; return !result1.JsonRPCAction.DontHideAfterAction;
}; };
results.Add(result); results.Add(result);
} }
return results; return results;
} }
else else
@ -120,7 +124,7 @@ namespace Wox.Core.Plugin
} }
catch (Exception) catch (Exception)
{ {
#if (DEBUG) #if DEBUG
{ {
throw; throw;
} }

View File

@ -12,7 +12,6 @@ using Wox.Plugin;
namespace Wox.Core.Plugin namespace Wox.Core.Plugin
{ {
internal abstract class PluginConfig internal abstract class PluginConfig
{ {
private const string PluginConfigName = "plugin.json"; private const string PluginConfigName = "plugin.json";
@ -72,8 +71,10 @@ namespace Wox.Core.Plugin
{ {
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath)); metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
metadata.PluginDirectory = pluginDirectory; metadata.PluginDirectory = pluginDirectory;
// for plugins which doesn't has ActionKeywords key // for plugins which doesn't has ActionKeywords key
metadata.ActionKeywords = metadata.ActionKeywords ?? new List<string> { metadata.ActionKeyword }; metadata.ActionKeywords = metadata.ActionKeywords ?? new List<string> { metadata.ActionKeyword };
// for plugin still use old ActionKeyword // for plugin still use old ActionKeyword
metadata.ActionKeyword = metadata.ActionKeywords?[0]; metadata.ActionKeyword = metadata.ActionKeywords?[0];
} }

View File

@ -22,6 +22,7 @@ namespace Wox.Core.Plugin
{ {
Directory.Delete(tempFolder, true); Directory.Delete(tempFolder, true);
} }
UnZip(path, tempFolder, true); UnZip(path, tempFolder, true);
string iniPath = Path.Combine(tempFolder, "plugin.json"); string iniPath = Path.Combine(tempFolder, "plugin.json");
@ -114,7 +115,7 @@ namespace Wox.Core.Plugin
catch (Exception) catch (Exception)
{ {
string error = $"Parse plugin config {configPath} failed: json format is not valid"; string error = $"Parse plugin config {configPath} failed: json format is not valid";
#if (DEBUG) #if DEBUG
{ {
throw new Exception(error); throw new Exception(error);
} }
@ -125,17 +126,18 @@ namespace Wox.Core.Plugin
if (!AllowedLanguage.IsAllowed(metadata.Language)) if (!AllowedLanguage.IsAllowed(metadata.Language))
{ {
string error = $"Parse plugin config {configPath} failed: invalid language {metadata.Language}"; string error = $"Parse plugin config {configPath} failed: invalid language {metadata.Language}";
#if (DEBUG) #if DEBUG
{ {
throw new Exception(error); throw new Exception(error);
} }
#endif #endif
return null; return null;
} }
if (!File.Exists(metadata.ExecuteFilePath)) if (!File.Exists(metadata.ExecuteFilePath))
{ {
string error = $"Parse plugin config {configPath} failed: ExecuteFile {metadata.ExecuteFilePath} didn't exist"; string error = $"Parse plugin config {configPath} failed: ExecuteFile {metadata.ExecuteFilePath} didn't exist";
#if (DEBUG) #if DEBUG
{ {
throw new Exception(error); throw new Exception(error);
} }
@ -192,6 +194,7 @@ namespace Wox.Core.Plugin
else else
break; break;
} }
streamWriter.Close(); streamWriter.Close();
} }
} }

View File

@ -26,8 +26,8 @@ namespace Wox.Core.Plugin
/// <summary> /// <summary>
/// Directories that will hold Wox plugin directory /// Directories that will hold Wox plugin directory
/// </summary> /// </summary>
public static List<PluginPair> AllPlugins { get; private set; } public static List<PluginPair> AllPlugins { get; private set; }
public static readonly List<PluginPair> GlobalPlugins = new List<PluginPair>(); public static readonly List<PluginPair> GlobalPlugins = new List<PluginPair>();
public static readonly Dictionary<string, PluginPair> NonGlobalPlugins = new Dictionary<string, PluginPair>(); public static readonly Dictionary<string, PluginPair> NonGlobalPlugins = new Dictionary<string, PluginPair>();
@ -255,6 +255,7 @@ namespace Wox.Core.Plugin
{ {
NonGlobalPlugins[newActionKeyword] = plugin; NonGlobalPlugins[newActionKeyword] = plugin;
} }
plugin.Metadata.ActionKeywords.Add(newActionKeyword); plugin.Metadata.ActionKeywords.Add(newActionKeyword);
} }

View File

@ -35,7 +35,6 @@ namespace Wox.Core.Plugin
{ {
var milliseconds = Stopwatch.Debug($"|PluginsLoader.CSharpPlugins|Constructor init cost for {metadata.Name}", () => var milliseconds = Stopwatch.Debug($"|PluginsLoader.CSharpPlugins|Constructor init cost for {metadata.Name}", () =>
{ {
#if DEBUG #if DEBUG
var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(metadata.ExecuteFilePath); var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(metadata.ExecuteFilePath);
var types = assembly.GetTypes(); var types = assembly.GetTypes();
@ -83,6 +82,7 @@ namespace Wox.Core.Plugin
}); });
metadata.InitTime += milliseconds; metadata.InitTime += milliseconds;
} }
return plugins; return plugins;
} }

View File

@ -43,6 +43,7 @@ namespace Wox.Core.Plugin
RawQuery = rawQuery, RawQuery = rawQuery,
ActionKeyword = actionKeyword, ActionKeyword = actionKeyword,
Search = search, Search = search,
// Obsolete value initialisation // Obsolete value initialisation
ActionName = actionKeyword, ActionName = actionKeyword,
ActionParameters = actionParameters ActionParameters = actionParameters

View File

@ -12,6 +12,7 @@ namespace Wox.Core.Resource
public static class FontHelper public static class FontHelper
{ {
static FontWeightConverter fontWeightConverter = new FontWeightConverter(); static FontWeightConverter fontWeightConverter = new FontWeightConverter();
public static FontWeight GetFontWeightFromInvariantStringOrNormal(string value) public static FontWeight GetFontWeightFromInvariantStringOrNormal(string value)
{ {
if (value == null) return FontWeights.Normal; if (value == null) return FontWeights.Normal;
@ -27,6 +28,7 @@ namespace Wox.Core.Resource
} }
static FontStyleConverter fontStyleConverter = new FontStyleConverter(); static FontStyleConverter fontStyleConverter = new FontStyleConverter();
public static FontStyle GetFontStyleFromInvariantStringOrNormal(string value) public static FontStyle GetFontStyleFromInvariantStringOrNormal(string value)
{ {
if (value == null) return FontStyles.Normal; if (value == null) return FontStyles.Normal;
@ -42,6 +44,7 @@ namespace Wox.Core.Resource
} }
static FontStretchConverter fontStretchConverter = new FontStretchConverter(); static FontStretchConverter fontStretchConverter = new FontStretchConverter();
public static FontStretch GetFontStretchFromInvariantStringOrNormal(string value) public static FontStretch GetFontStretchFromInvariantStringOrNormal(string value)
{ {
if (value == null) return FontStretches.Normal; if (value == null) return FontStretches.Normal;

View File

@ -19,6 +19,7 @@ namespace Wox.Core.Resource
public class Internationalization public class Internationalization
{ {
public Settings Settings { get; set; } public Settings Settings { get; set; }
private const string Folder = "Languages"; private const string Folder = "Languages";
private const string DefaultFile = "en.xaml"; private const string DefaultFile = "en.xaml";
private const string Extension = ".xaml"; private const string Extension = ".xaml";
@ -29,6 +30,7 @@ namespace Wox.Core.Resource
{ {
AddPluginLanguageDirectories(); AddPluginLanguageDirectories();
LoadDefaultLanguage(); LoadDefaultLanguage();
// we don't want to load /Languages/en.xaml twice // we don't want to load /Languages/en.xaml twice
// so add wox language directory after load plugin language files // so add wox language directory after load plugin language files
AddWoxLanguageDirectory(); AddWoxLanguageDirectory();
@ -97,6 +99,7 @@ namespace Wox.Core.Resource
{ {
LoadLanguage(language); LoadLanguage(language);
} }
UpdatePluginMetadataTranslations(); UpdatePluginMetadataTranslations();
} }

View File

@ -23,6 +23,7 @@ namespace Wox.Core.Resource
} }
} }
} }
return instance; return instance;
} }
} }