smaller stylecop fixes in Wox.Core and Wox.Infra (#5671)

* Headers
unneeded usings
files need blank line at bottom
Fixed double returns
Returns after braces

* commenting out stylecop
This commit is contained in:
Clint Rutkas
2020-08-05 14:06:42 -07:00
committed by GitHub
parent 30b65028fe
commit 92a2b83bc8
50 changed files with 308 additions and 116 deletions

View File

@@ -1,4 +1,7 @@
using System; // 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 System.Diagnostics;
using Wox.Plugin; using Wox.Plugin;
@@ -53,4 +56,4 @@ namespace Wox.Core.Plugin
return Execute(_startInfo); return Execute(_startInfo);
} }
} }
} }

View File

@@ -66,7 +66,6 @@ namespace Wox.Core.Plugin
} }
return rpc; return rpc;
} }
private string GetParameterByType(object parameter) private string GetParameterByType(object parameter)

View File

@@ -1,13 +1,13 @@
using System; // 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.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Reflection; using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Newtonsoft.Json; using Newtonsoft.Json;
using Wox.Infrastructure.Exception;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Plugin; using Wox.Plugin;
@@ -205,4 +205,4 @@ namespace Wox.Core.Plugin
context = ctx; context = ctx;
} }
} }
} }

View File

@@ -1,10 +1,12 @@
using System; // 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.Collections.Generic;
using System.Linq; using System.Linq;
using System.IO; using System.IO;
using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
using Wox.Infrastructure.Exception;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Plugin; using Wox.Plugin;
@@ -81,7 +83,6 @@ namespace Wox.Core.Plugin
return null; return null;
} }
if (!AllowedLanguage.IsAllowed(metadata.Language)) if (!AllowedLanguage.IsAllowed(metadata.Language))
{ {
Log.Error($"|PluginConfig.GetPluginMetadata|Invalid language <{metadata.Language}> for config <{configPath}>"); Log.Error($"|PluginConfig.GetPluginMetadata|Invalid language <{metadata.Language}> for config <{configPath}>");
@@ -97,4 +98,4 @@ namespace Wox.Core.Plugin
return metadata; return metadata;
} }
} }
} }

View File

@@ -1,4 +1,8 @@
using System; // 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.IO; using System.IO;
using System.Windows; using System.Windows;
using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.Zip;
@@ -118,7 +122,6 @@ namespace Wox.Core.Plugin
return null; return null;
} }
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}";

View File

@@ -1,4 +1,8 @@
using System; // 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.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@@ -221,7 +225,6 @@ namespace Wox.Core.Plugin
{ {
return new List<ContextMenuResult>(); return new List<ContextMenuResult>();
} }
} }
public static bool ActionKeywordRegistered(string actionKeyword) public static bool ActionKeywordRegistered(string actionKeyword)
@@ -275,7 +278,6 @@ namespace Wox.Core.Plugin
if (oldActionkeyword != Query.GlobalPluginWildcardSign) if (oldActionkeyword != Query.GlobalPluginWildcardSign)
NonGlobalPlugins.Remove(oldActionkeyword); NonGlobalPlugins.Remove(oldActionkeyword);
plugin.Metadata.ActionKeywords.Remove(oldActionkeyword); plugin.Metadata.ActionKeywords.Remove(oldActionkeyword);
} }

View File

@@ -1,11 +1,13 @@
using System; // 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.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.Loader; using System.Runtime.Loader;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Infrastructure.Exception;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Infrastructure.UserSettings; using Wox.Infrastructure.UserSettings;
using Wox.Plugin; using Wox.Plugin;
@@ -80,7 +82,6 @@ namespace Wox.Core.Plugin
plugins.Add(pair); plugins.Add(pair);
}); });
metadata.InitTime += milliseconds; metadata.InitTime += milliseconds;
} }
return plugins; return plugins;
} }
@@ -96,6 +97,5 @@ namespace Wox.Core.Plugin
}); });
return plugins; return plugins;
} }
} }
} }

View File

@@ -1,4 +1,8 @@
using System; // 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.Collections.Generic;
using System.Linq; using System.Linq;
using Wox.Plugin; using Wox.Plugin;
@@ -47,4 +51,4 @@ namespace Wox.Core.Plugin
return query; return query;
} }
} }
} }

View File

@@ -1,3 +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.
using System.Collections.Generic; using System.Collections.Generic;
namespace Wox.Core.Resource namespace Wox.Core.Resource

View File

@@ -1,4 +1,8 @@
using System; // 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.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
@@ -69,6 +73,5 @@ namespace Wox.Core.Resource
return family.FamilyTypefaces.FirstOrDefault(o => o.Style == styleObj && o.Weight == weightObj && o.Stretch == stretchObj) return family.FamilyTypefaces.FirstOrDefault(o => o.Style == styleObj && o.Weight == weightObj && o.Stretch == stretchObj)
?? family.ChooseRegularFamilyTypeface(); ?? family.ChooseRegularFamilyTypeface();
} }
} }
} }

View File

@@ -1,4 +1,8 @@
using System; // 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.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -30,14 +34,12 @@ namespace Wox.Core.Resource
AddWoxLanguageDirectory(); AddWoxLanguageDirectory();
} }
private void AddWoxLanguageDirectory() private void AddWoxLanguageDirectory()
{ {
var directory = Path.Combine(Constant.ProgramDirectory, Folder); var directory = Path.Combine(Constant.ProgramDirectory, Folder);
_languageDirectories.Add(directory); _languageDirectories.Add(directory);
} }
private void AddPluginLanguageDirectories() private void AddPluginLanguageDirectories()
{ {
foreach (var plugin in PluginManager.GetPluginsForInterface<IPluginI18n>()) foreach (var plugin in PluginManager.GetPluginsForInterface<IPluginI18n>())
@@ -96,7 +98,6 @@ namespace Wox.Core.Resource
LoadLanguage(language); LoadLanguage(language);
} }
UpdatePluginMetadataTranslations(); UpdatePluginMetadataTranslations();
} }
public bool PromptShouldUsePinyin(string languageCodeToSet) public bool PromptShouldUsePinyin(string languageCodeToSet)
@@ -214,4 +215,4 @@ namespace Wox.Core.Resource
} }
} }
} }
} }

View File

@@ -1,4 +1,8 @@
namespace Wox.Core.Resource // 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.
namespace Wox.Core.Resource
{ {
public static class InternationalizationManager public static class InternationalizationManager
{ {
@@ -23,4 +27,4 @@
} }
} }
} }
} }

View File

@@ -1,4 +1,8 @@
namespace Wox.Core.Resource // 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.
namespace Wox.Core.Resource
{ {
public class Language public class Language
{ {

View File

@@ -67,5 +67,19 @@
<ProjectReference Include="..\Wox.Infrastructure\Wox.Infrastructure.csproj" /> <ProjectReference Include="..\Wox.Infrastructure\Wox.Infrastructure.csproj" />
<ProjectReference Include="..\Wox.Plugin\Wox.Plugin.csproj" /> <ProjectReference Include="..\Wox.Plugin\Wox.Plugin.csproj" />
</ItemGroup> </ItemGroup>
<!-- <ItemGroup>
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
<Link>StyleCop.json</Link>
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>-->
</Project> </Project>

View File

@@ -1,4 +1,8 @@
using System; // 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.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -79,6 +83,7 @@ namespace Wox.Infrastructure
{ {
return; return;
} }
_pinyinStorage.Save(GetPinyinCacheAsDictionary()); _pinyinStorage.Save(GetPinyinCacheAsDictionary());
} }

View File

@@ -1,9 +1,12 @@
using System; // 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.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Xml;
using Microsoft.Win32; using Microsoft.Win32;
namespace Wox.Infrastructure.Exception namespace Wox.Infrastructure.Exception
@@ -37,6 +40,7 @@ namespace Wox.Infrastructure.Exception
exsb.Append(" Source: "); exsb.Append(" Source: ");
exsb.AppendLine(ex.Source); exsb.AppendLine(ex.Source);
} }
if (ex.TargetSite != null) if (ex.TargetSite != null)
{ {
exsb.Append(" TargetAssembly: "); exsb.Append(" TargetAssembly: ");
@@ -46,6 +50,7 @@ namespace Wox.Infrastructure.Exception
exsb.Append(" TargetSite: "); exsb.Append(" TargetSite: ");
exsb.AppendLine(ex.TargetSite.ToString()); exsb.AppendLine(ex.TargetSite.ToString());
} }
exsb.AppendLine(ex.StackTrace); exsb.AppendLine(ex.StackTrace);
exlist.Add(exsb); exlist.Add(exsb);
@@ -56,6 +61,7 @@ namespace Wox.Infrastructure.Exception
{ {
sb.AppendLine(result); sb.AppendLine(result);
} }
sb.AppendLine("```"); sb.AppendLine("```");
sb.AppendLine(); sb.AppendLine();
@@ -97,6 +103,7 @@ namespace Wox.Infrastructure.Exception
sb.Append(ass.Location); sb.Append(ass.Location);
} }
sb.AppendLine(")"); sb.AppendLine(")");
} }
@@ -129,6 +136,7 @@ namespace Wox.Infrastructure.Exception
{ {
continue; continue;
} }
foreach (string subKeyName in versionKey.GetSubKeyNames()) foreach (string subKeyName in versionKey.GetSubKeyNames())
{ {
RegistryKey subKey = versionKey.OpenSubKey(subKeyName); RegistryKey subKey = versionKey.OpenSubKey(subKeyName);
@@ -149,6 +157,7 @@ namespace Wox.Infrastructure.Exception
} }
} }
} }
using (RegistryKey ndpKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\")) using (RegistryKey ndpKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"))
{ {
int releaseKey = (int)ndpKey.GetValue("Release"); int releaseKey = (int)ndpKey.GetValue("Release");
@@ -163,6 +172,7 @@ namespace Wox.Infrastructure.Exception
result.Add("4.5.1 installed on Windows 8, Windows 7 SP1, or Windows Vista SP2"); result.Add("4.5.1 installed on Windows 8, Windows 7 SP1, or Windows Vista SP2");
} }
} }
return result; return result;
} }
catch (System.Exception e) catch (System.Exception e)

View File

@@ -1,4 +1,8 @@
using System.Diagnostics; // 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 System.IO; using System.IO;
namespace Wox.Infrastructure.FileSystemHelper namespace Wox.Infrastructure.FileSystemHelper

View File

@@ -1,9 +1,10 @@
using System; // Copyright (c) Microsoft Corporation
using System.Collections.Generic; // The Microsoft Corporation licenses this file to you under the MIT license.
using System.Text; // See the LICENSE file in the project root for more information.
using System;
using System.IO; using System.IO;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using System.Threading;
namespace Wox.Infrastructure.FileSystemHelper namespace Wox.Infrastructure.FileSystemHelper
{ {

View File

@@ -1,4 +1,8 @@
using System.Diagnostics; // 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;
namespace Wox.Infrastructure.FileSystemHelper namespace Wox.Infrastructure.FileSystemHelper
{ {

View File

@@ -1,6 +1,6 @@
using System; // Copyright (c) Microsoft Corporation
using System.Collections.Generic; // The Microsoft Corporation licenses this file to you under the MIT license.
using System.Text; // See the LICENSE file in the project root for more information.
namespace Wox.Infrastructure.FileSystemHelper namespace Wox.Infrastructure.FileSystemHelper
{ {

View File

@@ -1,4 +1,8 @@
using System; // 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;
namespace Wox.Infrastructure namespace Wox.Infrastructure
{ {

View File

@@ -1,4 +1,8 @@
using System; // 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.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -97,6 +101,7 @@ namespace Wox.Infrastructure
Log.Exception($"Wox.Infrastructure.Helper| Unable to Run {path} as admin : {ex.Message}", ex); Log.Exception($"Wox.Infrastructure.Helper| Unable to Run {path} as admin : {ex.Message}", ex);
} }
} }
public static Process OpenInConsole(string path) public static Process OpenInConsole(string path)
{ {
var processStartInfo = new ProcessStartInfo var processStartInfo = new ProcessStartInfo

View File

@@ -1,4 +1,8 @@
using System; // 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.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Input; using System.Windows.Input;
@@ -13,7 +17,6 @@ namespace Wox.Infrastructure.Hotkey
public bool Ctrl { get; set; } public bool Ctrl { get; set; }
public Key CharKey { get; set; } public Key CharKey { get; set; }
Dictionary<Key, string> specialSymbolDictionary = new Dictionary<Key, string> Dictionary<Key, string> specialSymbolDictionary = new Dictionary<Key, string>
{ {
{Key.Space, "Space"}, {Key.Space, "Space"},
@@ -29,18 +32,22 @@ namespace Wox.Infrastructure.Hotkey
{ {
modifierKeys = ModifierKeys.Alt; modifierKeys = ModifierKeys.Alt;
} }
if (Shift) if (Shift)
{ {
modifierKeys = modifierKeys | ModifierKeys.Shift; modifierKeys = modifierKeys | ModifierKeys.Shift;
} }
if (Win) if (Win)
{ {
modifierKeys = modifierKeys | ModifierKeys.Windows; modifierKeys = modifierKeys | ModifierKeys.Windows;
} }
if (Ctrl) if (Ctrl)
{ {
modifierKeys = modifierKeys | ModifierKeys.Control; modifierKeys = modifierKeys | ModifierKeys.Control;
} }
return modifierKeys; return modifierKeys;
} }
} }
@@ -70,27 +77,32 @@ namespace Wox.Infrastructure.Hotkey
{ {
return; return;
} }
List<string> keys = hotkeyString.Replace(" ", "").Split('+').ToList(); List<string> keys = hotkeyString.Replace(" ", "").Split('+').ToList();
if (keys.Contains("Alt")) if (keys.Contains("Alt"))
{ {
Alt = true; Alt = true;
keys.Remove("Alt"); keys.Remove("Alt");
} }
if (keys.Contains("Shift")) if (keys.Contains("Shift"))
{ {
Shift = true; Shift = true;
keys.Remove("Shift"); keys.Remove("Shift");
} }
if (keys.Contains("Win")) if (keys.Contains("Win"))
{ {
Win = true; Win = true;
keys.Remove("Win"); keys.Remove("Win");
} }
if (keys.Contains("Ctrl")) if (keys.Contains("Ctrl"))
{ {
Ctrl = true; Ctrl = true;
keys.Remove("Ctrl"); keys.Remove("Ctrl");
} }
if (keys.Count > 0) if (keys.Count > 0)
{ {
string charKey = keys[0]; string charKey = keys[0];
@@ -120,14 +132,17 @@ namespace Wox.Infrastructure.Hotkey
{ {
text += "Ctrl + "; text += "Ctrl + ";
} }
if (Alt) if (Alt)
{ {
text += "Alt + "; text += "Alt + ";
} }
if (Shift) if (Shift)
{ {
text += "Shift + "; text += "Shift + ";
} }
if (Win) if (Win)
{ {
text += "Win + "; text += "Win + ";

View File

@@ -1,3 +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.
namespace Wox.Infrastructure.Hotkey namespace Wox.Infrastructure.Hotkey
{ {
public enum KeyEvent public enum KeyEvent
@@ -22,4 +26,4 @@ namespace Wox.Infrastructure.Hotkey
/// </summary> /// </summary>
WM_SYSKEYDOWN = 260 WM_SYSKEYDOWN = 260
} }
} }

View File

@@ -1,4 +1,8 @@
using System.IO; // 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.IO;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
@@ -80,4 +84,4 @@ namespace Wox.Infrastructure.Http
} }
} }
} }
} }

View File

@@ -1,8 +1,11 @@
using System; // 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.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using System.Windows.Media; using System.Windows.Media;
namespace Wox.Infrastructure.Image namespace Wox.Infrastructure.Image
@@ -87,4 +90,4 @@ namespace Wox.Infrastructure.Image
} }
} }
} }

View File

@@ -1,4 +1,8 @@
using System; // 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.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Windows.Media; using System.Windows.Media;
@@ -10,6 +14,7 @@ namespace Wox.Infrastructure.Image
{ {
string GetHashFromImage(ImageSource image); string GetHashFromImage(ImageSource image);
} }
public class ImageHashGenerator : IImageHashGenerator public class ImageHashGenerator : IImageHashGenerator
{ {
public string GetHashFromImage(ImageSource imageSource) public string GetHashFromImage(ImageSource imageSource)
@@ -46,4 +51,4 @@ namespace Wox.Infrastructure.Image
} }
} }
} }

View File

@@ -1,4 +1,8 @@
using System; // 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.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@@ -32,7 +36,6 @@ namespace Wox.Infrastructure.Image
".ico" ".ico"
}; };
public static void Initialize(Theme theme) public static void Initialize(Theme theme)
{ {
_storage = new BinaryStorage<Dictionary<string, int>>("Image"); _storage = new BinaryStorage<Dictionary<string, int>>("Image");
@@ -45,6 +48,7 @@ namespace Wox.Infrastructure.Image
img.Freeze(); img.Freeze();
ImageCache[icon] = img; ImageCache[icon] = img;
} }
UpdateIconPath(theme); UpdateIconPath(theme);
Task.Run(() => Task.Run(() =>
{ {
@@ -112,6 +116,7 @@ namespace Wox.Infrastructure.Image
{ {
return new ImageResult(ImageCache[ErrorIconPath], ImageType.Error); return new ImageResult(ImageCache[ErrorIconPath], ImageType.Error);
} }
if (ImageCache.ContainsKey(path)) if (ImageCache.ContainsKey(path))
{ {
return new ImageResult(ImageCache[path], ImageType.Cache); return new ImageResult(ImageCache[path], ImageType.Cache);
@@ -188,6 +193,7 @@ namespace Wox.Infrastructure.Image
image = ImageCache[ErrorIconPath]; image = ImageCache[ErrorIconPath];
ImageCache[path] = image; ImageCache[path] = image;
} }
return new ImageResult(image, type); return new ImageResult(image, type);
} }
@@ -221,7 +227,6 @@ namespace Wox.Infrastructure.Image
ImageCache[path] = img; ImageCache[path] = img;
} }
return img; return img;
} }
@@ -235,4 +240,4 @@ namespace Wox.Infrastructure.Image
return image; return image;
} }
} }
} }

View File

@@ -1,4 +1,8 @@
using System; // 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.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.IO; using System.IO;
using System.Windows.Interop; using System.Windows.Interop;
@@ -49,7 +53,8 @@ namespace Wox.Infrastructure.Image
void GetDisplayName(SIGDN sigdnName, out IntPtr ppszName); void GetDisplayName(SIGDN sigdnName, out IntPtr ppszName);
void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs); void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
void Compare(IShellItem psi, uint hint, out int piOrder); void Compare(IShellItem psi, uint hint, out int piOrder);
}; }
;
internal enum SIGDN : uint internal enum SIGDN : uint
{ {
@@ -101,8 +106,8 @@ namespace Wox.Infrastructure.Image
public int Width { set { width = value; } } public int Width { set { width = value; } }
public int Height { set { height = value; } } public int Height { set { height = value; } }
}; }
;
public static BitmapSource GetThumbnail(string fileName, int width, int height, ThumbnailOptions options) public static BitmapSource GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
{ {
@@ -150,4 +155,4 @@ namespace Wox.Infrastructure.Image
throw new COMException($"Error while extracting thumbnail for {fileName}", Marshal.GetExceptionForHR((int)hr)); throw new COMException($"Error while extracting thumbnail for {fileName}", Marshal.GetExceptionForHR((int)hr));
} }
} }
} }

View File

@@ -1,4 +1,7 @@
using System.Diagnostics; // 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.IO; using System.IO;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using NLog; using NLog;
@@ -49,8 +52,6 @@ namespace Wox.Infrastructure.Logger
return valid; return valid;
} }
[MethodImpl(MethodImplOptions.Synchronized)] [MethodImpl(MethodImplOptions.Synchronized)]
public static void Exception(string className, string message, System.Exception exception, [CallerMemberName] string methodName = "") public static void Exception(string className, string message, System.Exception exception, [CallerMemberName] string methodName = "")
{ {
@@ -193,4 +194,4 @@ namespace Wox.Infrastructure.Logger
LogInternal(message, LogLevel.Warn); LogInternal(message, LogLevel.Warn);
} }
} }
} }

View File

@@ -1,6 +1,10 @@
using System.Runtime.CompilerServices; // 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.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Wox")] [assembly: InternalsVisibleTo("Wox")]
[assembly: InternalsVisibleTo("PowerLauncher")] [assembly: InternalsVisibleTo("PowerLauncher")]
[assembly: InternalsVisibleTo("Wox.Core")] [assembly: InternalsVisibleTo("Wox.Core")]
[assembly: InternalsVisibleTo("Wox.Test")] [assembly: InternalsVisibleTo("Wox.Test")]

View File

@@ -1,4 +1,8 @@
using System; // 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.Collections.Generic;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;

View File

@@ -1,4 +1,8 @@
using System; // 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.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@@ -104,6 +108,7 @@ namespace Wox.Infrastructure.Storage
break; break;
} }
} }
return ayResult; return ayResult;
} }
@@ -125,6 +130,7 @@ namespace Wox.Infrastructure.Storage
Log.Exception($"|BinaryStorage.Save|serialize error for file <{FilePath}>", e); Log.Exception($"|BinaryStorage.Save|serialize error for file <{FilePath}>", e);
} }
} }
_storageHelper.Close(); _storageHelper.Close();
Log.Info($"|BinaryStorage.Save|Saving cached data| <{FilePath}>"); Log.Info($"|BinaryStorage.Save|Saving cached data| <{FilePath}>");
} }

View File

@@ -1,4 +1,8 @@
using System.Collections.ObjectModel; // 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.Collections.ObjectModel;
using System.IO; using System.IO;
namespace Wox.Infrastructure.Storage namespace Wox.Infrastructure.Storage

View File

@@ -1,4 +1,8 @@
using System.Collections.ObjectModel; // 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.Collections.ObjectModel;
using System.IO; using System.IO;
namespace Wox.Infrastructure.Storage namespace Wox.Infrastructure.Storage

View File

@@ -1,7 +1,8 @@
using System; // 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.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Wox.Infrastructure.Storage namespace Wox.Infrastructure.Storage
{ {

View File

@@ -1,4 +1,8 @@
namespace Wox.Infrastructure.Storage // 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.
namespace Wox.Infrastructure.Storage
{ {
/// <summary> /// <summary>
/// Save plugin settings/cache, /// Save plugin settings/cache,

View File

@@ -1,7 +1,6 @@
using System; // Copyright (c) Microsoft Corporation
using System.Collections.Generic; // The Microsoft Corporation licenses this file to you under the MIT license.
using System.Text; // See the LICENSE file in the project root for more information.
using System.Threading.Tasks;
namespace Wox.Infrastructure.Storage namespace Wox.Infrastructure.Storage
{ {

View File

@@ -1,4 +1,8 @@
using System; // 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.Globalization; using System.Globalization;
using System.IO; using System.IO;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -63,6 +67,7 @@ namespace Wox.Infrastructure.Storage
{ {
LoadDefault(); LoadDefault();
} }
return _data.NonNull(); return _data.NonNull();
} }

View File

@@ -1,13 +1,12 @@
using NLog.Filters; // 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;
using System.Collections; using System.Collections;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls.Primitives;
using Wox.Infrastructure;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
namespace Wox.Infrastructure.Storage namespace Wox.Infrastructure.Storage

View File

@@ -1,4 +1,8 @@
using System.IO; // 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.IO;
namespace Wox.Infrastructure.Storage namespace Wox.Infrastructure.Storage
{ {

View File

@@ -1,8 +1,9 @@
using System; // Copyright (c) Microsoft Corporation
using System.Collections.Generic; // The Microsoft Corporation licenses this file to you under the MIT license.
using System.Text; // See the LICENSE file in the project root for more information.
using System;
using System.IO; using System.IO;
using System.Windows.Markup;
namespace Wox.Infrastructure.Storage namespace Wox.Infrastructure.Storage
{ {
@@ -11,7 +12,6 @@ namespace Wox.Infrastructure.Storage
// This detail is accessed by the storage items and is used to decide if the cache must be deleted or not // This detail is accessed by the storage items and is used to decide if the cache must be deleted or not
public bool clearCache = false; public bool clearCache = false;
private String currentPowerToysVersion = String.Empty; private String currentPowerToysVersion = String.Empty;
private String FilePath { get; set; } = String.Empty; private String FilePath { get; set; } = String.Empty;

View File

@@ -1,9 +1,8 @@
using System; // Copyright (c) Microsoft Corporation
using System.Collections.Generic; // 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.IO; using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Wox.Infrastructure.Storage namespace Wox.Infrastructure.Storage
{ {
@@ -18,4 +17,4 @@ namespace Wox.Infrastructure.Storage
FilePath = Path.Combine(directoryPath, $"{filename}{FileSuffix}"); FilePath = Path.Combine(directoryPath, $"{filename}{FileSuffix}");
} }
} }
} }

View File

@@ -1,6 +1,9 @@
// 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using static Wox.Infrastructure.StringMatcher; using static Wox.Infrastructure.StringMatcher;

View File

@@ -1,4 +1,8 @@
namespace Wox.Infrastructure.UserSettings // 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.
namespace Wox.Infrastructure.UserSettings
{ {
public class HttpProxy public class HttpProxy
{ {
@@ -8,4 +12,4 @@
public string UserName { get; set; } public string UserName { get; set; }
public string Password { get; set; } public string Password { get; set; }
} }
} }

View File

@@ -1,4 +1,8 @@
using Wox.Plugin; // 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 Wox.Plugin;
namespace Wox.Infrastructure.UserSettings namespace Wox.Infrastructure.UserSettings
{ {

View File

@@ -1,4 +1,8 @@
using System.Collections.Generic; // 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.Collections.Generic;
using Wox.Plugin; using Wox.Plugin;
namespace Wox.Infrastructure.UserSettings namespace Wox.Infrastructure.UserSettings
@@ -19,6 +23,7 @@ namespace Wox.Infrastructure.UserSettings
metadata.ActionKeywords = settings.ActionKeywords; metadata.ActionKeywords = settings.ActionKeywords;
metadata.ActionKeyword = settings.ActionKeywords[0]; metadata.ActionKeyword = settings.ActionKeywords[0];
} }
metadata.Disabled = settings.Disabled; metadata.Disabled = settings.Disabled;
} }
else else
@@ -34,6 +39,7 @@ namespace Wox.Infrastructure.UserSettings
} }
} }
} }
public class Plugin public class Plugin
{ {
public string ID { get; set; } public string ID { get; set; }

View File

@@ -1,3 +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.
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Drawing; using System.Drawing;
@@ -18,6 +22,7 @@ namespace Wox.Infrastructure.UserSettings
return _previousHotkey; return _previousHotkey;
} }
} }
public string Hotkey public string Hotkey
{ {
get get
@@ -34,6 +39,7 @@ namespace Wox.Infrastructure.UserSettings
} }
} }
} }
public string Language { get; set; } = "en"; public string Language { get; set; } = "en";
public string Theme { get; set; } = "Dark"; public string Theme { get; set; } = "Dark";
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name; public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;
@@ -44,8 +50,7 @@ namespace Wox.Infrastructure.UserSettings
public string ResultFontStyle { get; set; } public string ResultFontStyle { get; set; }
public string ResultFontWeight { get; set; } public string ResultFontWeight { get; set; }
public string ResultFontStretch { get; set; } public string ResultFontStretch { get; set; }
/// <summary> /// <summary>
/// when false Alphabet static service will always return empty results /// when false Alphabet static service will always return empty results
/// </summary> /// </summary>
@@ -100,6 +105,7 @@ namespace Wox.Infrastructure.UserSettings
} }
} }
} }
public int ActivateTimes { get; set; } public int ActivateTimes { get; set; }
// Order defaults to 0 or -1, so 1 will let this property appear last // Order defaults to 0 or -1, so 1 will let this property appear last
@@ -128,6 +134,7 @@ namespace Wox.Infrastructure.UserSettings
OnPropertyChanged(); OnPropertyChanged();
} }
} }
public bool LeaveCmdOpen { get; set; } public bool LeaveCmdOpen { get; set; }
public bool HideWhenDeactivated { get; set; } = true; public bool HideWhenDeactivated { get; set; } = true;
public bool ClearInputOnLaunch { get; set; } = false; public bool ClearInputOnLaunch { get; set; } = false;
@@ -155,4 +162,4 @@ namespace Wox.Infrastructure.UserSettings
LayeredWindow = 1, LayeredWindow = 1,
DWM = 2 DWM = 2
} }
} }

View File

@@ -69,5 +69,19 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<!--<ItemGroup>
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
<Link>StyleCop.json</Link>
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>-->
</Project> </Project>

View File

@@ -1,3 +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.
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;