Dev/crutkas/fixing warnings (#5161)

* new lines & braces

* Tabs /space auto fix

Co-authored-by: Clint Rutkas <crutkas@microsoft.com>
This commit is contained in:
Clint Rutkas
2020-07-22 13:27:17 -07:00
committed by GitHub
parent 6efec9d280
commit 14247fa75a
114 changed files with 694 additions and 681 deletions

View File

@@ -23,7 +23,7 @@ namespace Wox.Infrastructure
private ConcurrentDictionary<string, string[][]> PinyinCache;
private BinaryStorage<Dictionary<string, string[][]>> _pinyinStorage;
private Settings _settings;
public void Initialize([NotNull] Settings settings)
{
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
@@ -60,10 +60,10 @@ namespace Wox.Infrastructure
if (!ContainsChinese(source))
return source;
var combination = PinyinCombination(source);
var pinyinArray=combination.Select(x => string.Join("", x));
var pinyinArray = combination.Select(x => string.Join("", x));
var acronymArray = combination.Select(Acronym).Distinct();
var joinedSingleStringCombination = new StringBuilder();
@@ -77,7 +77,7 @@ namespace Wox.Infrastructure
{
if (!_settings.ShouldUsePinyin)
{
return;
return;
}
_pinyinStorage.Save(GetPinyinCacheAsDictionary());
}

View File

@@ -90,12 +90,12 @@ namespace Wox.Infrastructure.Exception
else if (string.IsNullOrEmpty(ass.Location))
{
sb.Append("location is null or empty");
}
else
{
sb.Append(ass.Location);
sb.Append(ass.Location);
}
sb.AppendLine(")");
}

View File

@@ -8,7 +8,7 @@ namespace Wox.Infrastructure.FileSystemHelper
public FileVersionInfoWrapper() { }
public FileVersionInfo GetVersionInfo(string path)
{
if(File.Exists(path))
if (File.Exists(path))
{
return FileVersionInfo.GetVersionInfo(path);
}

View File

@@ -92,7 +92,7 @@ namespace Wox.Infrastructure
{
Process.Start(info);
}
catch(System.Exception ex)
catch (System.Exception ex)
{
Log.Exception($"Wox.Infrastructure.Helper| Unable to Run {path} as admin : {ex.Message}", ex);
}

View File

@@ -103,7 +103,7 @@ namespace Wox.Infrastructure.Hotkey
{
try
{
CharKey = (Key) Enum.Parse(typeof (Key), charKey);
CharKey = (Key)Enum.Parse(typeof(Key), charKey);
}
catch (ArgumentException)
{

View File

@@ -23,7 +23,7 @@ namespace Wox.Infrastructure.Image
var i = _data[path];
return i;
}
set
set
{
_data[path] = value;

View File

@@ -207,7 +207,7 @@ namespace Wox.Infrastructure.Image
int ImageCacheValue;
if (GuidToKey.TryGetValue(hash, out string key))
{ // image already exists
if(ImageCache.Usage.TryGetValue(path, out ImageCacheValue))
if (ImageCache.Usage.TryGetValue(path, out ImageCacheValue))
{
img = ImageCache[key];
}

View File

@@ -41,8 +41,8 @@ namespace Wox.Infrastructure.Image
internal interface IShellItem
{
void BindToHandler(IntPtr pbc,
[MarshalAs(UnmanagedType.LPStruct)]Guid bhid,
[MarshalAs(UnmanagedType.LPStruct)]Guid riid,
[MarshalAs(UnmanagedType.LPStruct)] Guid bhid,
[MarshalAs(UnmanagedType.LPStruct)] Guid riid,
out IntPtr ppv);
void GetParent(out IShellItem ppsi);

View File

@@ -49,7 +49,7 @@ namespace Wox.Infrastructure.Logger
return valid;
}
[MethodImpl(MethodImplOptions.Synchronized)]
public static void Exception(string className, string message, System.Exception exception, [CallerMemberName] string methodName = "")

View File

@@ -36,7 +36,7 @@ namespace Wox.Infrastructure.Storage
// 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(File.Exists(FilePath))
if (File.Exists(FilePath))
{
File.Delete(FilePath);
Log.Info($"|BinaryStorage.TryLoad|Deleting cached data| <{FilePath}>");

View File

@@ -8,14 +8,14 @@ namespace Wox.Infrastructure.Storage
{
public FileSystemWatcherWrapper() { }
Collection<string> IFileSystemWatcherWrapper.Filters
{
Collection<string> IFileSystemWatcherWrapper.Filters
{
get => this.Filters;
set
{
if(value != null)
set
{
if (value != null)
{
foreach(string filter in value)
foreach (string filter in value)
{
this.Filters.Add(filter);
}

View File

@@ -40,7 +40,7 @@ namespace Wox.Infrastructure.Storage
// 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(File.Exists(FilePath))
if (File.Exists(FilePath))
{
File.Delete(FilePath);
Log.Info($"|JsonStorage.TryLoad|Deleting cached data|<{FilePath}>");

View File

@@ -25,7 +25,7 @@ namespace Wox.Infrastructure.Storage
public ListRepository()
{
}
public void Set(IList<T> items)
@@ -35,7 +35,7 @@ namespace Wox.Infrastructure.Storage
{
_items = new ConcurrentDictionary<int, T>(items.ToDictionary(i => i.GetHashCode()));
}
catch(ArgumentException e)
catch (ArgumentException e)
{
Log.Info($"|LisRepository.Set| Trying to insert a duplicate item", e.Message);
}
@@ -52,7 +52,7 @@ namespace Wox.Infrastructure.Storage
{
Log.Error($"|ListRepository.Add| Item Already Exists <{insertedItem}>");
}
}
public void Remove(T removedItem)

View File

@@ -2,7 +2,7 @@
namespace Wox.Infrastructure.Storage
{
public class PluginJsonStorage<T> :JsonStorage<T> where T : new()
public class PluginJsonStorage<T> : JsonStorage<T> where T : new()
{
public PluginJsonStorage()
{

View File

@@ -11,7 +11,7 @@ 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
public bool clearCache = false;
private String currentPowerToysVersion = String.Empty;
private String FilePath { get; set; } = String.Empty;
@@ -32,17 +32,17 @@ namespace Wox.Infrastructure.Storage
// If there is some error in populating/retrieving the version numbers, then the cache must be deleted
// This case will not be hit, but is present as a fail safe
if(String.IsNullOrEmpty(version1) || String.IsNullOrEmpty(version2))
if (String.IsNullOrEmpty(version1) || String.IsNullOrEmpty(version2))
{
return true;
}
string[] split1 = version1.Split( new string[] { version, period }, StringSplitOptions.RemoveEmptyEntries);
string[] split2 = version2.Split( new string[] { version, period }, StringSplitOptions.RemoveEmptyEntries);
string[] split1 = version1.Split(new string[] { version, period }, StringSplitOptions.RemoveEmptyEntries);
string[] split2 = version2.Split(new string[] { version, period }, StringSplitOptions.RemoveEmptyEntries);
for(int i=0; i<versionLength; i++)
for (int i = 0; i < versionLength; i++)
{
if(int.Parse(split1[i]) < int.Parse(split2[i]))
if (int.Parse(split1[i]) < int.Parse(split2[i]))
{
return true;
}
@@ -70,11 +70,11 @@ namespace Wox.Infrastructure.Storage
string cacheSuffix = ".cache";
string jsonSuffix = ".json";
if(type == (uint)StorageType.BINARY_STORAGE)
if (type == (uint)StorageType.BINARY_STORAGE)
{
suffix = cacheSuffix;
}
else if(type == (uint)StorageType.JSON_STORAGE)
else if (type == (uint)StorageType.JSON_STORAGE)
{
suffix = jsonSuffix;
}

View File

@@ -58,8 +58,8 @@ namespace Wox.Infrastructure
/// </summary>
public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption opt)
{
if (string.IsNullOrEmpty(stringToCompare) || string.IsNullOrEmpty(query)) return new MatchResult (false, UserSettingSearchPrecision);
if (string.IsNullOrEmpty(stringToCompare) || string.IsNullOrEmpty(query)) return new MatchResult(false, UserSettingSearchPrecision);
query = query.Trim();
if (_alphabet != null)
@@ -70,8 +70,8 @@ namespace Wox.Infrastructure
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare;
var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query;
var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query;
var querySubstrings = queryWithoutCase.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
int currentQuerySubstringIndex = 0;
var currentQuerySubstring = querySubstrings[currentQuerySubstringIndex];
@@ -153,9 +153,9 @@ namespace Wox.Infrastructure
currentQuerySubstring = querySubstrings[currentQuerySubstringIndex];
currentQuerySubstringCharacterIndex = 0;
}
}
// proceed to calculate score if every char or substring without whitespaces matched
}
// proceed to calculate score if every char or substring without whitespaces matched
if (allQuerySubstringsMatched)
{
var nearestSpaceIndex = CalculateClosestSpaceIndex(spaceIndices, firstMatchIndex);
@@ -164,13 +164,13 @@ namespace Wox.Infrastructure
return new MatchResult(true, UserSettingSearchPrecision, indexList, score);
}
return new MatchResult (false, UserSettingSearchPrecision);
return new MatchResult(false, UserSettingSearchPrecision);
}
// To get the index of the closest space which preceeds the first matching index
private int CalculateClosestSpaceIndex(List<int> spaceIndices, int firstMatchIndex)
{
if(spaceIndices.Count == 0)
if (spaceIndices.Count == 0)
{
return -1;
}
@@ -182,7 +182,7 @@ namespace Wox.Infrastructure
}
}
private static bool AllPreviousCharsMatched(int startIndexToVerify, int currentQuerySubstringCharacterIndex,
private static bool AllPreviousCharsMatched(int startIndexToVerify, int currentQuerySubstringCharacterIndex,
string fullStringToCompareWithoutCase, string currentQuerySubstring)
{
var allMatch = true;
@@ -196,8 +196,8 @@ namespace Wox.Infrastructure
}
return allMatch;
}
}
private static List<int> GetUpdatedIndexList(int startIndexToVerify, int currentQuerySubstringCharacterIndex, int firstMatchIndexInWord, List<int> indexList)
{
var updatedList = new List<int>();
@@ -240,7 +240,7 @@ namespace Wox.Infrastructure
{
int count = query.Count(c => !char.IsWhiteSpace(c));
int threshold = 4;
if(count <= threshold)
if (count <= threshold)
{
score += count * 10;
}

View File

@@ -27,7 +27,7 @@ namespace Wox.Infrastructure.UserSettings
{
ID = metadata.ID,
Name = metadata.Name,
ActionKeywords = metadata.ActionKeywords,
ActionKeywords = metadata.ActionKeywords,
Disabled = metadata.Disabled
};
}

View File

@@ -11,13 +11,14 @@ namespace Wox.Infrastructure.UserSettings
{
private string _hotkey = "Alt + Space";
private string _previousHotkey = "";
public string PreviousHotkey {
public string PreviousHotkey
{
get
{
return _previousHotkey;
}
}
public string Hotkey
public string Hotkey
{
get
{
@@ -84,7 +85,7 @@ namespace Wox.Infrastructure.UserSettings
public double WindowTop { get; set; }
private int _maxResultsToShow = 4;
public int MaxResultsToShow
public int MaxResultsToShow
{
get
{