whitespace stylecop fixes for Wox.Infra (#5689)

* Limited to whitespace

* removing stylecop again
This commit is contained in:
Clint Rutkas 2020-08-06 11:28:13 -07:00 committed by GitHub
parent 7b767df0b5
commit d6e46d73b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 81 additions and 28 deletions

View File

@ -167,7 +167,7 @@ namespace Wox.Infrastructure
if (word.Length > 40) if (word.Length > 40)
{ {
//Skip strings that are too long string for Pinyin conversion. // Skip strings that are too long string for Pinyin conversion.
return false; return false;
} }

View File

@ -18,7 +18,7 @@ namespace Wox.Infrastructure.Exception
return CreateExceptionReport(exception); return CreateExceptionReport(exception);
} }
//todo log /display line by line // todo log /display line by line
private static string CreateExceptionReport(System.Exception ex) private static string CreateExceptionReport(System.Exception ex)
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
@ -96,12 +96,10 @@ namespace Wox.Infrastructure.Exception
else if (string.IsNullOrEmpty(ass.Location)) else if (string.IsNullOrEmpty(ass.Location))
{ {
sb.Append("location is null or empty"); sb.Append("location is null or empty");
} }
else else
{ {
sb.Append(ass.Location); sb.Append(ass.Location);
} }
sb.AppendLine(")"); sb.AppendLine(")");
@ -151,9 +149,7 @@ namespace Wox.Infrastructure.Exception
else if (install == "1") else if (install == "1")
result.Add(string.Format("{0} {1} {2}", versionKeyName, subKeyName, name)); result.Add(string.Format("{0} {1} {2}", versionKeyName, subKeyName, name));
} }
} }
} }
} }
} }
@ -179,7 +175,6 @@ namespace Wox.Infrastructure.Exception
{ {
return new List<string>(); return new List<string>();
} }
} }
} }
} }

View File

@ -10,6 +10,7 @@ namespace Wox.Infrastructure.FileSystemHelper
public class FileVersionInfoWrapper : IFileVersionInfoWrapper public class FileVersionInfoWrapper : IFileVersionInfoWrapper
{ {
public FileVersionInfoWrapper() { } public FileVersionInfoWrapper() { }
public FileVersionInfo GetVersionInfo(string path) public FileVersionInfo GetVersionInfo(string path)
{ {
if (File.Exists(path)) if (File.Exists(path))

View File

@ -9,6 +9,7 @@ namespace Wox.Infrastructure.FileSystemHelper
public interface IFileVersionInfoWrapper public interface IFileVersionInfoWrapper
{ {
FileVersionInfo GetVersionInfo(string path); FileVersionInfo GetVersionInfo(string path);
string FileDescription { get; set; } string FileDescription { get; set; }
} }
} }

View File

@ -12,15 +12,19 @@ namespace Wox.Infrastructure.Hotkey
public class HotkeyModel public class HotkeyModel
{ {
public bool Alt { get; set; } public bool Alt { get; set; }
public bool Shift { get; set; } public bool Shift { get; set; }
public bool Win { get; set; } public bool Win { get; set; }
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" },
{Key.Oem3, "~"} { Key.Oem3, "~" }
}; };
public ModifierKeys ModifierKeys public ModifierKeys ModifierKeys
@ -54,7 +58,6 @@ namespace Wox.Infrastructure.Hotkey
public HotkeyModel() public HotkeyModel()
{ {
} }
public HotkeyModel(string hotkeyString) public HotkeyModel(string hotkeyString)
@ -119,7 +122,6 @@ namespace Wox.Infrastructure.Hotkey
} }
catch (ArgumentException) catch (ArgumentException)
{ {
} }
} }
} }

View File

@ -27,6 +27,7 @@ namespace Wox.Infrastructure.Http
} }
public static HttpProxy Proxy { private get; set; } public static HttpProxy Proxy { private get; set; }
public static IWebProxy WebProxy() public static IWebProxy WebProxy()
{ {
if (Proxy != null && Proxy.Enabled && !string.IsNullOrEmpty(Proxy.Server)) if (Proxy != null && Proxy.Enabled && !string.IsNullOrEmpty(Proxy.Server))

View File

@ -26,6 +26,7 @@ namespace Wox.Infrastructure.Image
var i = _data[path]; var i = _data[path];
return i; return i;
} }
set set
{ {
_data[path] = value; _data[path] = value;
@ -89,5 +90,4 @@ namespace Wox.Infrastructure.Image
Usage = new ConcurrentDictionary<string, int>(usage); Usage = new ConcurrentDictionary<string, int>(usage);
} }
} }
} }

View File

@ -48,7 +48,6 @@ namespace Wox.Infrastructure.Image
{ {
return null; return null;
} }
} }
} }
} }

View File

@ -69,7 +69,7 @@ namespace Wox.Infrastructure.Image
_storage.Save(ImageCache.GetUsageAsDictionary()); _storage.Save(ImageCache.GetUsageAsDictionary());
} }
//Todo : Update it with icons specific to each theme. // Todo : Update it with icons specific to each theme.
public static void UpdateIconPath(Theme theme) public static void UpdateIconPath(Theme theme)
{ {
if (theme == Theme.Light || theme == Theme.HighContrastWhite) if (theme == Theme.Light || theme == Theme.HighContrastWhite)
@ -93,6 +93,7 @@ namespace Wox.Infrastructure.Image
} }
public ImageType ImageType { get; } public ImageType ImageType { get; }
public ImageSource ImageSource { get; } public ImageSource ImageSource { get; }
} }
@ -145,7 +146,6 @@ namespace Wox.Infrastructure.Image
type = ImageType.Folder; type = ImageType.Folder;
image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize, image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize,
Constant.ThumbnailSize, ThumbnailOptions.IconOnly); Constant.ThumbnailSize, ThumbnailOptions.IconOnly);
} }
else if (File.Exists(path)) else if (File.Exists(path))
{ {

View File

@ -50,11 +50,13 @@ namespace Wox.Infrastructure.Image
out IntPtr ppv); out IntPtr ppv);
void GetParent(out IShellItem ppsi); void GetParent(out IShellItem ppsi);
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
{ {
@ -105,9 +107,9 @@ namespace Wox.Infrastructure.Image
private int height; private int height;
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)
{ {

View File

@ -12,6 +12,7 @@ namespace Wox.Infrastructure
{ {
private static readonly Dictionary<string, long> Count = new Dictionary<string, long>(); private static readonly Dictionary<string, long> Count = new Dictionary<string, long>();
private static readonly object Locker = new object(); private static readonly object Locker = new object();
/// <summary> /// <summary>
/// This stopwatch will appear only in Debug mode /// This stopwatch will appear only in Debug mode
/// </summary> /// </summary>

View File

@ -37,6 +37,7 @@ namespace Wox.Infrastructure.Storage
public T TryLoad(T defaultData) public T TryLoad(T defaultData)
{ {
_storageHelper = new StoragePowerToysVersionInfo(FilePath, BINARY_STORAGE); _storageHelper = new StoragePowerToysVersionInfo(FilePath, BINARY_STORAGE);
// Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible // Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible
if (_storageHelper.clearCache) if (_storageHelper.clearCache)
{ {
@ -72,7 +73,7 @@ namespace Wox.Infrastructure.Storage
private T Deserialize(FileStream stream, T defaultData) private T Deserialize(FileStream stream, T defaultData)
{ {
//http://stackoverflow.com/questions/2120055/binaryformatter-deserialize-gives-serializationexception // http://stackoverflow.com/questions/2120055/binaryformatter-deserialize-gives-serializationexception
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
BinaryFormatter binaryFormatter = new BinaryFormatter BinaryFormatter binaryFormatter = new BinaryFormatter
{ {

View File

@ -11,15 +11,22 @@ namespace Wox.Infrastructure.Storage
{ {
// Events to watch out for // Events to watch out for
event FileSystemEventHandler Created; event FileSystemEventHandler Created;
event FileSystemEventHandler Deleted; event FileSystemEventHandler Deleted;
event FileSystemEventHandler Changed; event FileSystemEventHandler Changed;
event RenamedEventHandler Renamed; event RenamedEventHandler Renamed;
// Properties of File System watcher // Properties of File System watcher
Collection<string> Filters { get; set; } Collection<string> Filters { get; set; }
bool EnableRaisingEvents { get; set; } bool EnableRaisingEvents { get; set; }
NotifyFilters NotifyFilter { get; set; } NotifyFilters NotifyFilter { get; set; }
string Path { get; set; } string Path { get; set; }
bool IncludeSubdirectories { get; set; } bool IncludeSubdirectories { get; set; }
} }
} }

View File

@ -9,9 +9,13 @@ namespace Wox.Infrastructure.Storage
public interface IRepository<T> public interface IRepository<T>
{ {
void Add(T insertedItem); void Add(T insertedItem);
void Remove(T removedItem); void Remove(T removedItem);
bool Contains(T item); bool Contains(T item);
void Set(IList<T> list); void Set(IList<T> list);
bool Any(); bool Any();
} }
} }

View File

@ -17,10 +17,13 @@ namespace Wox.Infrastructure.Storage
{ {
private readonly JsonSerializerSettings _serializerSettings; private readonly JsonSerializerSettings _serializerSettings;
private T _data; private T _data;
// need a new directory name // need a new directory name
public const string DirectoryName = "Settings"; public const string DirectoryName = "Settings";
public const string FileSuffix = ".json"; public const string FileSuffix = ".json";
public string FilePath { get; set; } public string FilePath { get; set; }
public string DirectoryPath { get; set; } public string DirectoryPath { get; set; }
// This storage helper returns whether or not to delete the json storage items // This storage helper returns whether or not to delete the json storage items
@ -41,6 +44,7 @@ namespace Wox.Infrastructure.Storage
public T Load() public T Load()
{ {
_storageHelper = new StoragePowerToysVersionInfo(FilePath, JSON_STORAGE); _storageHelper = new StoragePowerToysVersionInfo(FilePath, JSON_STORAGE);
// Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible // Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible
if (_storageHelper.clearCache) if (_storageHelper.clearCache)
{ {
@ -108,6 +112,7 @@ namespace Wox.Infrastructure.Storage
var backupName = $"{originName}-{timestamp}{FileSuffix}"; var backupName = $"{originName}-{timestamp}{FileSuffix}";
var backupPath = Path.Combine(directory, backupName); var backupPath = Path.Combine(directory, backupName);
File.Copy(FilePath, backupPath, true); File.Copy(FilePath, backupPath, true);
// todo give user notification for the backup process // todo give user notification for the backup process
} }

View File

@ -24,12 +24,11 @@ namespace Wox.Infrastructure.Storage
public ListRepository() public ListRepository()
{ {
} }
public void Set(IList<T> items) public void Set(IList<T> items)
{ {
//enforce that internal representation // enforce that internal representation
try try
{ {
_items = new ConcurrentDictionary<int, T>(items.ToDictionary(i => i.GetHashCode())); _items = new ConcurrentDictionary<int, T>(items.ToDictionary(i => i.GetHashCode()));
@ -51,7 +50,6 @@ namespace Wox.Infrastructure.Storage
{ {
Log.Error($"|ListRepository.Add| Item Already Exists <{insertedItem}>"); Log.Error($"|ListRepository.Add| Item Already Exists <{insertedItem}>");
} }
} }
public void Remove(T removedItem) public void Remove(T removedItem)

View File

@ -13,6 +13,7 @@ namespace Wox.Infrastructure.Storage
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;
// As of now this information is not pertinent but may be in the future // As of now this information is not pertinent but may be in the future
@ -102,6 +103,7 @@ namespace Wox.Infrastructure.Storage
public StoragePowerToysVersionInfo(String AssociatedFilePath, int type) public StoragePowerToysVersionInfo(String AssociatedFilePath, int type)
{ {
FilePath = GetFilePath(AssociatedFilePath, type); FilePath = GetFilePath(AssociatedFilePath, type);
// Get the previous version of PowerToys and cache Storage details from the CacheDetails.json storage file // Get the previous version of PowerToys and cache Storage details from the CacheDetails.json storage file
String previousVersion = GetPreviousVersion(); String previousVersion = GetPreviousVersion();
currentPowerToysVersion = Microsoft.PowerToys.Settings.UI.Lib.Utilities.Helper.GetProductVersion(); currentPowerToysVersion = Microsoft.PowerToys.Settings.UI.Lib.Utilities.Helper.GetProductVersion();

View File

@ -9,6 +9,7 @@ using System.Runtime.CompilerServices;
using static Wox.Infrastructure.StringMatcher; using static Wox.Infrastructure.StringMatcher;
[assembly: InternalsVisibleToAttribute("Microsoft.Plugin.Program.UnitTests")] [assembly: InternalsVisibleToAttribute("Microsoft.Plugin.Program.UnitTests")]
namespace Wox.Infrastructure namespace Wox.Infrastructure
{ {
public class StringMatcher public class StringMatcher
@ -301,6 +302,7 @@ namespace Wox.Infrastructure
public int RawScore public int RawScore
{ {
get { return _rawScore; } get { return _rawScore; }
set set
{ {
_rawScore = value; _rawScore = value;

View File

@ -7,9 +7,13 @@ namespace Wox.Infrastructure.UserSettings
public class HttpProxy public class HttpProxy
{ {
public bool Enabled { get; set; } = false; public bool Enabled { get; set; } = false;
public string Server { get; set; } public string Server { get; set; }
public int Port { get; set; } public int Port { get; set; }
public string UserName { get; set; } public string UserName { get; set; }
public string Password { get; set; } public string Password { get; set; }
} }
} }

View File

@ -9,6 +9,7 @@ namespace Wox.Infrastructure.UserSettings
public class CustomPluginHotkey : BaseModel public class CustomPluginHotkey : BaseModel
{ {
public string Hotkey { get; set; } public string Hotkey { get; set; }
public string ActionKeyword { get; set; } public string ActionKeyword { get; set; }
} }
} }

View File

@ -43,7 +43,9 @@ namespace Wox.Infrastructure.UserSettings
public class Plugin public class Plugin
{ {
public string ID { get; set; } public string ID { get; set; }
public string Name { get; set; } public string Name { get; set; }
public List<string> ActionKeywords { get; set; } // a reference of the action keywords from plugin manager public List<string> ActionKeywords { get; set; } // a reference of the action keywords from plugin manager
/// <summary> /// <summary>

View File

@ -15,6 +15,7 @@ namespace Wox.Infrastructure.UserSettings
{ {
private string _hotkey = "Alt + Space"; private string _hotkey = "Alt + Space";
private string _previousHotkey = ""; private string _previousHotkey = "";
public string PreviousHotkey public string PreviousHotkey
{ {
get get
@ -29,6 +30,7 @@ namespace Wox.Infrastructure.UserSettings
{ {
return _hotkey; return _hotkey;
} }
set set
{ {
if (_hotkey != value) if (_hotkey != value)
@ -41,14 +43,23 @@ 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;
public string QueryBoxFontStyle { get; set; } public string QueryBoxFontStyle { get; set; }
public string QueryBoxFontWeight { get; set; } public string QueryBoxFontWeight { get; set; }
public string QueryBoxFontStretch { get; set; } public string QueryBoxFontStretch { get; set; }
public string ResultFont { get; set; } = FontFamily.GenericSansSerif.Name; public string ResultFont { get; set; } = FontFamily.GenericSansSerif.Name;
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>
@ -62,6 +73,7 @@ namespace Wox.Infrastructure.UserSettings
public string QuerySearchPrecisionString public string QuerySearchPrecisionString
{ {
get { return QuerySearchPrecision.ToString(); } get { return QuerySearchPrecision.ToString(); }
set set
{ {
try try
@ -87,15 +99,18 @@ namespace Wox.Infrastructure.UserSettings
public bool AutoUpdates { get; set; } = false; public bool AutoUpdates { get; set; } = false;
public double WindowLeft { get; set; } public double WindowLeft { get; set; }
public double WindowTop { get; set; } public double WindowTop { get; set; }
private int _maxResultsToShow = 4; private int _maxResultsToShow = 4;
public int MaxResultsToShow public int MaxResultsToShow
{ {
get get
{ {
return _maxResultsToShow; return _maxResultsToShow;
} }
set set
{ {
if (_maxResultsToShow != value) if (_maxResultsToShow != value)
@ -111,6 +126,7 @@ namespace Wox.Infrastructure.UserSettings
// 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
[JsonProperty(Order = 1)] [JsonProperty(Order = 1)]
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings(); public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; set; } = new ObservableCollection<CustomPluginHotkey>(); public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; set; } = new ObservableCollection<CustomPluginHotkey>();
[Obsolete] [Obsolete]
@ -120,14 +136,19 @@ namespace Wox.Infrastructure.UserSettings
public OpacityMode OpacityMode { get; set; } = OpacityMode.Normal; public OpacityMode OpacityMode { get; set; } = OpacityMode.Normal;
public bool DontPromptUpdateMsg { get; set; } public bool DontPromptUpdateMsg { get; set; }
public bool EnableUpdateLog { get; set; } public bool EnableUpdateLog { get; set; }
public bool StartWoxOnSystemStartup { get; set; } = true; public bool StartWoxOnSystemStartup { get; set; } = true;
public bool HideOnStartup { get; set; } public bool HideOnStartup { get; set; }
bool _hideNotifyIcon { get; set; } bool _hideNotifyIcon { get; set; }
public bool HideNotifyIcon public bool HideNotifyIcon
{ {
get { return _hideNotifyIcon; } get { return _hideNotifyIcon; }
set set
{ {
_hideNotifyIcon = value; _hideNotifyIcon = value;
@ -136,10 +157,13 @@ namespace Wox.Infrastructure.UserSettings
} }
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;
public bool RememberLastLaunchLocation { get; set; } public bool RememberLastLaunchLocation { get; set; }
public bool IgnoreHotkeysOnFullscreen { get; set; } public bool IgnoreHotkeysOnFullscreen { get; set; }
public HttpProxy Proxy { get; set; } = new HttpProxy(); public HttpProxy Proxy { get; set; } = new HttpProxy();

View File

@ -22,6 +22,7 @@ namespace Wox.Infrastructure
public static bool IsPortableMode; public static bool IsPortableMode;
public const string PortableFolderName = "UserData"; public const string PortableFolderName = "UserData";
public static string PortableDataPath = Path.Combine(ProgramDirectory, PortableFolderName); public static string PortableDataPath = Path.Combine(ProgramDirectory, PortableFolderName);
public static string DetermineDataDirectory() public static string DetermineDataDirectory()
{ {
if (Directory.Exists(PortableDataPath)) if (Directory.Exists(PortableDataPath))