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

@@ -44,7 +44,7 @@ namespace Microsoft.Plugin.Calculator
var result = MagesEngine.Interpret(query.Search);
// This could happen for some incorrect queries, like pi(2)
if(result == null)
if (result == null)
{
return new List<Result>();
}
@@ -86,7 +86,7 @@ namespace Microsoft.Plugin.Calculator
thread.Join();
return ret;
}
}
}
};
}
}

View File

@@ -63,7 +63,7 @@ namespace Microsoft.Plugin.Calculator
{
return Translate(input, this.sourceCulture, this.targetCulture, this.splitRegexForSource);
}
/// <summary>
/// Translate from target to source culture.
/// </summary>

View File

@@ -111,7 +111,7 @@ namespace Microsoft.Plugin.Folder
{
Process.Start("explorer.exe", $" /select,\"{record.FullPath}\"");
}
catch(Exception e)
catch (Exception e)
{
var message = $"Fail to open file at {record.FullPath}";
LogException(message, e);
@@ -159,7 +159,7 @@ namespace Microsoft.Plugin.Folder
private bool CanRunAsDifferentUser(string path)
{
switch(Path.GetExtension(path))
switch (Path.GetExtension(path))
{
case ".exe":
case ".bat":

View File

@@ -197,7 +197,7 @@ namespace Microsoft.Plugin.Folder
{
if ((fileSystemInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue;
if(fileSystemInfo is DirectoryInfo)
if (fileSystemInfo is DirectoryInfo)
{
var folderSubtitleString = fileSystemInfo.FullName;
@@ -246,7 +246,7 @@ namespace Microsoft.Plugin.Folder
return true;
},
ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath}
ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath }
};
return result;
}

View File

@@ -24,7 +24,7 @@ namespace Microsoft.Plugin.Indexer
}
// Extensions for adding run as admin context menu item for applications
private readonly string[] appExtensions = { ".exe", ".bat", ".appref-ms", ".lnk" };
private readonly string[] appExtensions = { ".exe", ".bat", ".appref-ms", ".lnk" };
public ContextMenuLoader(PluginInitContext context)
{
@@ -44,7 +44,7 @@ namespace Microsoft.Plugin.Indexer
}
// Test to check if File can be Run as admin, if yes, we add a 'run as admin' context menu item
if(CanFileBeRunAsAdmin(record.Path))
if (CanFileBeRunAsAdmin(record.Path))
{
contextMenus.Add(CreateRunAsAdminContextMenu(record));
}
@@ -55,7 +55,7 @@ namespace Microsoft.Plugin.Indexer
Title = _context.API.GetTranslation("Microsoft_plugin_indexer_copy_path"),
Glyph = "\xE8C8",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.C,
AcceleratorKey = Key.C,
AcceleratorModifiers = ModifierKeys.Control,
Action = (context) =>
@@ -128,7 +128,7 @@ namespace Microsoft.Plugin.Indexer
Task.Run(() => Helper.RunAsAdmin(record.Path));
return true;
}
catch(Exception e)
catch (Exception e)
{
Log.Exception($"|Microsoft.Plugin.Indexer.ContextMenu| Failed to run {record.Path} as admin, {e.Message}", e);
return false;
@@ -142,9 +142,9 @@ namespace Microsoft.Plugin.Indexer
private bool CanFileBeRunAsAdmin(string path)
{
string fileExtension = Path.GetExtension(path);
foreach(string extension in appExtensions)
foreach (string extension in appExtensions)
{
if(extension.Equals(fileExtension, StringComparison.OrdinalIgnoreCase))
if (extension.Equals(fileExtension, StringComparison.OrdinalIgnoreCase))
{
return true;
}
@@ -169,7 +169,7 @@ namespace Microsoft.Plugin.Indexer
{
Process.Start("explorer.exe", $" /select,\"{record.Path}\"");
}
catch(Exception e)
catch (Exception e)
{
var message = $"Fail to open file at {record.Path}";
LogException(message, e);

View File

@@ -14,10 +14,10 @@ namespace Microsoft.Plugin.Indexer.DriveDetection
{
using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey(registryLocation))
{
if(regKey != null)
if (regKey != null)
{
Object value = regKey.GetValue(valueName);
if(value != null)
if (value != null)
{
return (int)value;
}

View File

@@ -69,7 +69,7 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
resultDisposed = true;
}
if(conn.State == System.Data.ConnectionState.Closed)
if (conn.State == System.Data.ConnectionState.Closed)
{
connDisposed = true;
}

View File

@@ -30,7 +30,7 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
List<OleDBResult> oleDBResults = WindowsIndexerSearch.Query(queryHelper.ConnectionString, sqlQuery);
// Loop over all records from the database
foreach(OleDBResult oleDBResult in oleDBResults)
foreach (OleDBResult oleDBResult in oleDBResults)
{
if (oleDBResult.fieldData[0] == DBNull.Value || oleDBResult.fieldData[1] == DBNull.Value || oleDBResult.fieldData[2] == DBNull.Value)
{
@@ -49,7 +49,7 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
Title = (string)oleDBResult.fieldData[1]
};
_Result.Add(result);
}
}
}
return _Result;
@@ -105,7 +105,8 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
public IEnumerable<SearchResult> Search(string keyword, string pattern = "*", int maxCount = 30)
{
lock(_lock){
lock (_lock)
{
ISearchQueryHelper queryHelper;
InitQueryHelper(out queryHelper, maxCount);
ModifyQueryHelper(ref queryHelper, pattern);

View File

@@ -79,7 +79,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
// Arrange
PackageWrapper invalidPackagedApp = new PackageWrapper();
Main._settings = new Settings();
List<IPackage> packages = new List<IPackage>() {invalidPackagedApp };
List<IPackage> packages = new List<IPackage>() { invalidPackagedApp };
var mock = new Mock<IPackageManager>();
mock.Setup(x => x.FindPackagesForCurrentUser()).Returns(packages);
UWP.PackageManagerWrapper = mock.Object;

View File

@@ -56,7 +56,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Name = "Command Prompt",
ExecutableName = "cmd.exe",
FullPath = "c:\\windows\\system32\\cmd.exe",
LnkResolvedPath ="c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\system tools\\command prompt.lnk",
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\system tools\\command prompt.lnk",
AppType = 2
};

View File

@@ -64,8 +64,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
{
//Arrange
ListRepository<string> repository = new ListRepository<string>();
var numItems = 1000;
for(var i=0; i<numItems;++i)
var numItems = 1000;
for (var i = 0; i < numItems; ++i)
{
repository.Add($"OriginalItem_{i}");
}
@@ -87,16 +87,16 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
});
//Act - Insert on another thread
var addTask = Task.Run(() =>
{
for (var i = 0; i < numItems; ++i)
{
repository.Add($"NewItem_{i}");
}
});
var addTask = Task.Run(() =>
{
for (var i = 0; i < numItems; ++i)
{
repository.Add($"NewItem_{i}");
}
});
//Assert that this does not throw. Collections that aren't syncronized will throw an invalidoperatioexception if the list is modified while enumerating
Assert.DoesNotThrowAsync(async () =>
Assert.DoesNotThrowAsync(async () =>
{
await Task.WhenAll(new Task[] { iterationTask, addTask });
});

View File

@@ -42,9 +42,9 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
// Arrange
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32>>("Win32"), _settings, _pathsToWatch);
Win32 item1 = new Win32
{
Name = name,
Win32 item1 = new Win32
{
Name = name,
ExecutableName = exename,
FullPath = fullPath,
Description = description1
@@ -108,7 +108,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
{
// Arrange
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32>>("Win32"), _settings, _pathsToWatch);
RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory , newpath, oldpath);
RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory, newpath, oldpath);
string oldFullPath = directory + "\\" + oldpath;
string newFullPath = directory + "\\" + newpath;
@@ -132,12 +132,12 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
// Arrange
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32>>("Win32"), _settings, _pathsToWatch);
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Created, "directory", path);
// FileVersionInfo must be mocked for exe applications
var mockFileVersionInfo = new Mock<IFileVersionInfoWrapper>();
mockFileVersionInfo.Setup(m => m.GetVersionInfo(It.IsAny<string>())).Returns((FileVersionInfo)null);
Win32._fileVersionInfoWrapper = mockFileVersionInfo.Object;
// Act
_fileSystemMocks[0].Raise(m => m.Created += null, e);
@@ -377,7 +377,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
string oldFullPath = directory + "\\" + oldpath;
string FullPath = directory + "\\" + path;
// ShellLinkHelper must be mocked for lnk applications
var mockShellLink = new Mock<IShellLinkHelper>();
mockShellLink.Setup(m => m.RetrieveTargetPath(It.IsAny<string>())).Returns(String.Empty);

View File

@@ -66,7 +66,7 @@ namespace Microsoft.Plugin.Program
Task.WaitAll(a, b);
_settings.LastIndexTime = DateTime.Today;
}
public void Save()

View File

@@ -74,7 +74,7 @@ namespace Microsoft.Plugin.Program.Programs
public interface IAppxManifestProperties
{
[PreserveSig]
int GetBoolValue([MarshalAs(UnmanagedType.LPWStr)]string name, out bool value);
int GetBoolValue([MarshalAs(UnmanagedType.LPWStr)] string name, out bool value);
[PreserveSig]
int GetStringValue([MarshalAs(UnmanagedType.LPWStr)] string name, [MarshalAs(UnmanagedType.LPWStr)] out string value);
}

View File

@@ -36,7 +36,7 @@ namespace Microsoft.Plugin.Program.Programs
string path;
try
{
path = package.InstalledLocation.Path;
path = package.InstalledLocation.Path;
}
catch (Exception e) when (e is ArgumentException || e is FileNotFoundException)
{
@@ -48,11 +48,11 @@ namespace Microsoft.Plugin.Program.Programs
package.Id.Name,
package.Id.FullName,
package.Id.FamilyName,
package.IsFramework,
package.IsFramework,
package.IsDevelopmentMode,
path
);
}
}
}

View File

@@ -117,7 +117,7 @@ namespace Microsoft.Plugin.Program.Programs
{
((IPersistFile)link).Load(path, STGM_READ);
}
catch(System.IO.FileNotFoundException ex)
catch (System.IO.FileNotFoundException ex)
{
ProgramLogger.LogException($"|Win32| ShellLinkHelper.retrieveTargetPath | {path} | Path could not be retrieved", ex);
return String.Empty;

View File

@@ -41,7 +41,7 @@ namespace Microsoft.Plugin.Program.Programs
public static IPackageManager PackageManagerWrapper { get; set; } = new PackageManagerWrapper();
public UWP(IPackage package)
{
{
Name = package.Name;
FullName = package.FullName;
FamilyName = package.FamilyName;
@@ -63,10 +63,10 @@ namespace Microsoft.Plugin.Program.Programs
if (hResult == Hresult.Ok)
{
var apps = new List<Application>();
var apps = new List<Application>();
List<AppxPackageHelper.IAppxManifestApplication> _apps = _helper.getAppsFromManifest(stream);
foreach(var _app in _apps)
foreach (var _app in _apps)
{
var app = new Application(_app, this);
apps.Add(app);
@@ -194,12 +194,12 @@ namespace Microsoft.Plugin.Program.Programs
}
catch (Exception e)
{
ProgramLogger.LogException("UWP" ,"CurrentUserPackages", $"id","An unexpected error occurred and "
ProgramLogger.LogException("UWP", "CurrentUserPackages", $"id", "An unexpected error occurred and "
+ $"unable to verify if package is valid", e);
return false;
}
}
return valid;
});
@@ -242,7 +242,7 @@ namespace Microsoft.Plugin.Program.Programs
public string Name => DisplayName;
public string Location => Package.Location;
public bool Enabled { get; set; }
public bool CanRunElevated {get;set;}
public bool CanRunElevated { get; set; }
public string LogoUri { get; set; }
public string LogoPath { get; set; }
@@ -253,7 +253,7 @@ namespace Microsoft.Plugin.Program.Programs
{
var displayNameMatch = StringMatcher.FuzzySearch(query, DisplayName);
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
var score = new[] { displayNameMatch.Score, descriptionMatch.Score/2 }.Max();
var score = new[] { displayNameMatch.Score, descriptionMatch.Score / 2 }.Max();
return score;
}
@@ -325,23 +325,23 @@ namespace Microsoft.Plugin.Program.Programs
}
}
);
}
contextMenus.Add(
new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
Glyph = "\xE838",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.E,
AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
Action = _ =>
{
Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", Package.Location));
return true;
}
});
}
contextMenus.Add(
new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
Glyph = "\xE838",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.E,
AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
Action = _ =>
{
Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", Package.Location));
return true;
}
});
contextMenus.Add(new ContextMenuResult
{
@@ -436,7 +436,7 @@ namespace Microsoft.Plugin.Program.Programs
if (File.Exists(manifest))
{
var file = File.ReadAllText(manifest);
if(file.Contains("TrustLevel=\"mediumIL\"", StringComparison.InvariantCultureIgnoreCase))
if (file.Contains("TrustLevel=\"mediumIL\"", StringComparison.InvariantCultureIgnoreCase))
{
return true;
}
@@ -565,8 +565,8 @@ namespace Microsoft.Plugin.Program.Programs
{
var end = path.Length - extension.Length;
var prefix = path.Substring(0, end);
var paths = new List<string> { path };
var paths = new List<string> { path };
var scaleFactors = new Dictionary<PackageVersion, List<int>>
{
// scale factors on win10: https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-app-assets#asset-size-tables,
@@ -594,7 +594,7 @@ namespace Microsoft.Plugin.Program.Programs
else
{
int appIconSize = 36;
var targetSizes = new List<int>{16, 24, 30, 36, 44, 60, 72, 96, 128, 180, 256}.AsParallel();
var targetSizes = new List<int> { 16, 24, 30, 36, 44, 60, 72, 96, 128, 180, 256 }.AsParallel();
Dictionary<string, int> pathFactorPairs = new Dictionary<string, int>();
foreach (var factor in targetSizes)

View File

@@ -64,7 +64,7 @@ namespace Microsoft.Plugin.Program.Programs
var nameMatch = StringMatcher.FuzzySearch(query, Name);
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
var executableNameMatch = StringMatcher.FuzzySearch(query, ExecutableName);
var score = new[] { nameMatch.Score, descriptionMatch.Score/2, executableNameMatch.Score }.Max();
var score = new[] { nameMatch.Score, descriptionMatch.Score / 2, executableNameMatch.Score }.Max();
return score;
}
@@ -81,7 +81,7 @@ namespace Microsoft.Plugin.Program.Programs
public bool FilterWebApplication(string query)
{
// If the app is not a web application, then do not filter it
if(!IsWebApplication())
if (!IsWebApplication())
{
return false;
}
@@ -101,7 +101,7 @@ namespace Microsoft.Plugin.Program.Programs
pathContainsQuery = true;
}
if(Name.Contains(subquery, StringComparison.OrdinalIgnoreCase))
if (Name.Contains(subquery, StringComparison.OrdinalIgnoreCase))
{
nameContainsQuery = true;
}
@@ -112,19 +112,19 @@ namespace Microsoft.Plugin.Program.Programs
// Function to set the subtitle based on the Type of application
private string SetSubtitle(IPublicAPI api)
{
if(AppType == (uint)ApplicationTypes.WIN32_APPLICATION)
if (AppType == (uint)ApplicationTypes.WIN32_APPLICATION)
{
return api.GetTranslation("powertoys_run_plugin_program_win32_application");
}
else if(AppType == (uint)ApplicationTypes.INTERNET_SHORTCUT_APPLICATION)
else if (AppType == (uint)ApplicationTypes.INTERNET_SHORTCUT_APPLICATION)
{
return api.GetTranslation("powertoys_run_plugin_program_internet_shortcut_application");
}
else if(AppType == (uint)ApplicationTypes.WEB_APPLICATION)
else if (AppType == (uint)ApplicationTypes.WEB_APPLICATION)
{
return api.GetTranslation("powertoys_run_plugin_program_web_application");
}
else if(AppType == (uint)ApplicationTypes.RUN_COMMAND)
else if (AppType == (uint)ApplicationTypes.RUN_COMMAND)
{
return api.GetTranslation("powertoys_run_plugin_program_run_command");
}
@@ -153,7 +153,7 @@ namespace Microsoft.Plugin.Program.Programs
return null;
}
if(!hasArguments)
if (!hasArguments)
{
var noArgumentScoreModifier = 5;
score += noArgumentScoreModifier;
@@ -168,7 +168,7 @@ namespace Microsoft.Plugin.Program.Programs
}
// NOTE: This is to display run commands only when there is an exact match, like in start menu
if(!QueryEqualsNameForRunCommands(query))
if (!QueryEqualsNameForRunCommands(query))
{
return null;
}
@@ -330,27 +330,27 @@ namespace Microsoft.Plugin.Program.Programs
const string urlPrefix = "URL=";
const string iconFilePrefix = "IconFile=";
foreach(string line in lines)
foreach (string line in lines)
{
if(line.StartsWith(urlPrefix))
if (line.StartsWith(urlPrefix))
{
urlPath = line.Substring(urlPrefix.Length);
Uri uri = new Uri(urlPath);
// To filter out only those steam shortcuts which have 'run' or 'rungameid' as the hostname
if(InternetShortcutURLPrefixes.Match(urlPath).Success)
if (InternetShortcutURLPrefixes.Match(urlPath).Success)
{
validApp = true;
}
}
if(line.StartsWith(iconFilePrefix))
if (line.StartsWith(iconFilePrefix))
{
iconPath = line.Substring(iconFilePrefix.Length);
}
}
if(!validApp)
if (!validApp)
{
return new Win32() { Valid = false, Enabled = false };
}
@@ -386,8 +386,8 @@ namespace Microsoft.Plugin.Program.Programs
try
{
const int MAX_PATH = 260;
StringBuilder buffer = new StringBuilder(MAX_PATH);
StringBuilder buffer = new StringBuilder(MAX_PATH);
string target = _helper.RetrieveTargetPath(path);
if (!string.IsNullOrEmpty(target))
@@ -473,25 +473,25 @@ namespace Microsoft.Plugin.Program.Programs
string extension = Path.GetExtension(path);
if(extension.Equals(exeExtension, StringComparison.OrdinalIgnoreCase))
if (extension.Equals(exeExtension, StringComparison.OrdinalIgnoreCase))
{
app = ExeProgram(path);
}
else if(extension.Equals(lnkExtension, StringComparison.OrdinalIgnoreCase))
else if (extension.Equals(lnkExtension, StringComparison.OrdinalIgnoreCase))
{
app = LnkProgram(path);
}
else if(extension.Equals(apprefExtension, StringComparison.OrdinalIgnoreCase))
else if (extension.Equals(apprefExtension, StringComparison.OrdinalIgnoreCase))
{
app = Win32Program(path);
}
else if(extension.Equals(urlExtenion, StringComparison.OrdinalIgnoreCase))
else if (extension.Equals(urlExtenion, StringComparison.OrdinalIgnoreCase))
{
app = InternetShortcutProgram(path);
}
// if the app is valid, only then return the application, else return null
if(app?.Valid ?? false)
if (app?.Valid ?? false)
{
return app;
}
@@ -511,8 +511,8 @@ namespace Microsoft.Plugin.Program.Programs
var files = new List<string>();
var folderQueue = new Queue<string>();
folderQueue.Enqueue(directory);
folderQueue.Enqueue(directory);
do
{
var currentDirectory = folderQueue.Dequeue();
@@ -540,7 +540,7 @@ namespace Microsoft.Plugin.Program.Programs
try
{
// If the search is set to be non-recursive, then do not enqueue the child directories.
if(!recursiveSearch)
if (!recursiveSearch)
{
continue;
}
@@ -606,9 +606,9 @@ namespace Microsoft.Plugin.Program.Programs
IEnumerable<String> toFilterAllPaths = new List<String>();
bool isRecursiveSearch = true;
foreach(string path in searchPaths)
foreach (string path in searchPaths)
{
if(path.Length > 0)
if (path.Length > 0)
{
// to expand any environment variables present in the path
string directory = Environment.ExpandEnvironmentVariables(path);
@@ -629,7 +629,7 @@ namespace Microsoft.Plugin.Program.Programs
var allPrograms = programs1.Concat(programs2).Where(p => p.Valid)
.Concat(programs3).Where(p => p.Valid)
.Concat(programs4).Where(p => p.Valid)
.Select( p => { p.AppType = (uint)ApplicationTypes.RUN_COMMAND; return p; });
.Select(p => { p.AppType = (uint)ApplicationTypes.RUN_COMMAND; return p; });
return allPrograms;
}
@@ -643,8 +643,8 @@ namespace Microsoft.Plugin.Program.Programs
{
var _paths = ProgramPaths(location, suffixes);
toFilter = toFilter.Concat(_paths);
}
}
var paths = toFilter
.Where(t1 => !disabledProgramsList.Any(x => x.UniqueIdentifier == t1))
.Select(t1 => t1)
@@ -665,7 +665,7 @@ namespace Microsoft.Plugin.Program.Programs
{
var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.Programs);
var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms);
List<string> IndexLocation = new List<string>() { directory1, directory2};
List<string> IndexLocation = new List<string>() { directory1, directory2 };
return IndexPath(suffixes, IndexLocation);
}
@@ -777,8 +777,8 @@ namespace Microsoft.Plugin.Program.Programs
{
public bool Equals(Win32 app1, Win32 app2)
{
if(!string.IsNullOrEmpty(app1.Name) && !string.IsNullOrEmpty(app2.Name)
if (!string.IsNullOrEmpty(app1.Name) && !string.IsNullOrEmpty(app2.Name)
&& !string.IsNullOrEmpty(app1.ExecutableName) && !string.IsNullOrEmpty(app2.ExecutableName)
&& !string.IsNullOrEmpty(app1.FullPath) && !string.IsNullOrEmpty(app2.FullPath))
{

View File

@@ -9,7 +9,7 @@ namespace Microsoft.Plugin.Program
public DateTime LastIndexTime { get; set; }
public List<ProgramSource> ProgramSources { get; set; } = new List<ProgramSource>();
public List<DisabledProgramSource> DisabledProgramSources { get; set; } = new List<DisabledProgramSource>();
public string[] ProgramSuffixes { get; set; } = {"bat", "appref-ms", "exe", "lnk", "url"};
public string[] ProgramSuffixes { get; set; } = { "bat", "appref-ms", "exe", "lnk", "url" };
public bool EnableStartMenuSource { get; set; } = true;

View File

@@ -35,7 +35,7 @@ namespace Microsoft.Plugin.Program.Storage
try
{
var packageWrapper = PackageWrapper.GetWrapperFromPackage(args.Package);
if(!string.IsNullOrEmpty(packageWrapper.InstalledLocation))
if (!string.IsNullOrEmpty(packageWrapper.InstalledLocation))
{
var uwp = new UWP(packageWrapper);
uwp.InitializeAppInfo(packageWrapper.InstalledLocation);

View File

@@ -52,7 +52,7 @@ namespace Microsoft.Plugin.Program.Storage
{
if (disposing)
{
for(int index = 0; index < _pathsToWatch.Length; index++)
for (int index = 0; index < _pathsToWatch.Length; index++)
{
_fileSystemWatchers[index].Dispose();
}

View File

@@ -17,7 +17,7 @@ namespace Microsoft.Plugin.Program.Storage
private IList<IFileSystemWatcherWrapper> _fileSystemWatcherHelpers;
private string[] _pathsToWatch;
private int _numberOfPathsToWatch;
private Collection<string> extensionsToWatch = new Collection<string>{ "*.exe", "*.lnk", "*.appref-ms", "*.url" };
private Collection<string> extensionsToWatch = new Collection<string> { "*.exe", "*.lnk", "*.appref-ms", "*.url" };
private readonly string lnkExtension = ".lnk";
private readonly string urlExtension = ".url";
@@ -33,7 +33,7 @@ namespace Microsoft.Plugin.Program.Storage
private void InitializeFileSystemWatchers()
{
for(int index = 0; index < _numberOfPathsToWatch; index++)
for (int index = 0; index < _numberOfPathsToWatch; index++)
{
// To set the paths to monitor
_fileSystemWatcherHelpers[index].Path = _pathsToWatch[index];
@@ -77,7 +77,7 @@ namespace Microsoft.Plugin.Program.Storage
{
oldApp = new Win32() { Name = Path.GetFileNameWithoutExtension(e.OldName), ExecutableName = newApp.ExecutableName, FullPath = newApp.FullPath };
}
else if(extension.Equals(urlExtension, StringComparison.OrdinalIgnoreCase))
else if (extension.Equals(urlExtension, StringComparison.OrdinalIgnoreCase))
{
oldApp = new Win32() { Name = Path.GetFileNameWithoutExtension(e.OldName), ExecutableName = Path.GetFileName(e.OldName), FullPath = newApp.FullPath };
}
@@ -126,7 +126,7 @@ namespace Microsoft.Plugin.Program.Storage
app = Programs.Win32.GetAppFromPath(path);
}
}
catch(Exception ex)
catch (Exception ex)
{
Log.Info($"|Win32ProgramRepository|OnAppDeleted-{extension}Program|{path}|Unable to create program from {path}| {ex.Message}");
}
@@ -154,7 +154,7 @@ namespace Microsoft.Plugin.Program.Storage
// Unlike the rename event args, since we do not have a newPath, we iterate through all the programs and find the one with the same LnkResolved path.
private Programs.Win32 GetAppWithSameLnkResolvedPath(string lnkResolvedPath)
{
foreach(Programs.Win32 app in Items)
foreach (Programs.Win32 app in Items)
{
if (lnkResolvedPath.ToLower().Equals(app.LnkResolvedPath))
{
@@ -167,7 +167,7 @@ namespace Microsoft.Plugin.Program.Storage
private void OnAppCreated(object sender, FileSystemEventArgs e)
{
string path = e.FullPath;
if(!Path.GetExtension(path).Equals(urlExtension))
if (!Path.GetExtension(path).Equals(urlExtension))
{
Programs.Win32 app = Programs.Win32.GetAppFromPath(path);
if (app != null)

View File

@@ -58,7 +58,7 @@ namespace Microsoft.Plugin.Program.Views
private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
{
var add = new AddProgramSource(context, _settings);
if(add.ShowDialog() ?? false)
if (add.ShowDialog() ?? false)
{
ReIndexing();
}
@@ -139,14 +139,14 @@ namespace Microsoft.Plugin.Program.Views
UniqueIdentifier = directory
};
directoriesToAdd.Add(source);
directoriesToAdd.Add(source);
}
}
if (directoriesToAdd.Count() > 0)
{
directoriesToAdd.ForEach(x => _settings.ProgramSources.Add(x));
directoriesToAdd.ForEach(x => ProgramSettingDisplayList.Add(x));
directoriesToAdd.ForEach(x => ProgramSettingDisplayList.Add(x));
programSourceView.Items.Refresh();
ReIndexing();
@@ -212,8 +212,8 @@ namespace Microsoft.Plugin.Program.Views
ProgramSettingDisplayList.SetProgramSourcesStatus(selectedItems, true);
ProgramSettingDisplayList.RemoveDisabledFromSettings();
}
}
if (selectedItems.IsReindexRequired())
ReIndexing();
@@ -256,7 +256,7 @@ namespace Microsoft.Plugin.Program.Views
var sortBy = columnBinding?.Path.Path ?? headerClicked.Column.Header as string;
Sort(sortBy, direction);
_lastHeaderClicked = headerClicked;
_lastDirection = direction;
}

View File

@@ -198,7 +198,7 @@ namespace Microsoft.Plugin.Shell
else if (_settings.Shell == Shell.RunCommand)
{
//Open explorer if the path is a file or directory
if(Directory.Exists(command) || File.Exists(command))
if (Directory.Exists(command) || File.Exists(command))
{
info = ShellCommand.SetProcessStartInfo("explorer.exe", arguments: command, verb: runAsAdministratorArg);
}
@@ -236,11 +236,11 @@ namespace Microsoft.Plugin.Shell
return info;
}
private void Execute(Func<ProcessStartInfo, Process> startProcess,ProcessStartInfo info)
private void Execute(Func<ProcessStartInfo, Process> startProcess, ProcessStartInfo info)
{
try
{
startProcess(info);
startProcess(info);
}
catch (FileNotFoundException e)
{
@@ -248,7 +248,7 @@ namespace Microsoft.Plugin.Shell
var message = $"Command not found: {e.Message}";
_context.API.ShowMsg(name, message);
}
catch(Win32Exception e)
catch (Win32Exception e)
{
var name = "Plugin: Shell";
var message = $"Error running the command: {e.Message}";

View File

@@ -5,7 +5,7 @@ namespace Microsoft.Plugin.Shell
public class Settings
{
public Shell Shell { get; set; } = Shell.RunCommand;
// not overriding Win+R
// crutkas we need to earn the right for Win+R override
public bool ReplaceWinR { get; set; } = false;

View File

@@ -49,10 +49,10 @@ namespace Microsoft.Plugin.Shell
_settings.ReplaceWinR = false;
};
ShellComboBox.SelectedIndex = (int) _settings.Shell;
ShellComboBox.SelectedIndex = (int)_settings.Shell;
ShellComboBox.SelectionChanged += (o, e) =>
{
_settings.Shell = (Shell) ShellComboBox.SelectedIndex;
_settings.Shell = (Shell)ShellComboBox.SelectedIndex;
LeaveShellOpen.IsEnabled = _settings.Shell != Shell.RunCommand;
};
}

View File

@@ -815,7 +815,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
[DllImport("psapi.dll")]
public static extern uint GetProcessImageFileName(IntPtr hProcess, [Out] StringBuilder lpImageFileName, [In] [MarshalAs(UnmanagedType.U4)] int nSize);
public static extern uint GetProcessImageFileName(IntPtr hProcess, [Out] StringBuilder lpImageFileName, [In][MarshalAs(UnmanagedType.U4)] int nSize);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr GetProp(IntPtr hWnd, string lpString);
@@ -824,7 +824,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
public static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId);
[DllImport("dwmapi.dll", EntryPoint = "#113", CallingConvention = CallingConvention.StdCall)]
public static extern int DwmpActivateLivePreview([MarshalAs(UnmanagedType.Bool)]bool fActivate, IntPtr hWndExclude, IntPtr hWndInsertBefore, LivePreviewTrigger lpt, IntPtr prcFinalRect);
public static extern int DwmpActivateLivePreview([MarshalAs(UnmanagedType.Bool)] bool fActivate, IntPtr hWndExclude, IntPtr hWndInsertBefore, LivePreviewTrigger lpt, IntPtr prcFinalRect);
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);

View File

@@ -91,7 +91,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
Window newWindow = new Window(hwnd);
if (newWindow.IsWindow && newWindow.Visible && newWindow.IsOwner &&
(!newWindow.IsToolWindow || newWindow.IsAppWindow ) && !newWindow.TaskListDeleted &&
(!newWindow.IsToolWindow || newWindow.IsAppWindow) && !newWindow.TaskListDeleted &&
newWindow.ClassName != "Windows.UI.Core.CoreWindow")
{
windows.Add(newWindow);

View File

@@ -94,7 +94,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
/// Event handler for when the search text has been updated
/// </summary>
public async Task UpdateSearchText(string searchText)
{
{
this.SearchText = searchText;
await SyncOpenWindowsWithModelAsync();
}

View File

@@ -6,13 +6,13 @@ using System.Threading.Tasks;
namespace Microsoft.Plugin.WindowWalker.Components
{
class WindowResult:Window
class WindowResult : Window
{
/// <summary>
/// Number of letters in between constant for when
/// the result hasn't been set yet
/// </summary>
public const int NoResult = -1;
public const int NoResult = -1;
/// <summary>
/// Properties that signify how many characters (including spaces)
@@ -27,7 +27,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
/// <summary>
/// Constructor for WindowResult
/// </summary>
public WindowResult(Window window):base(window.Hwnd)
public WindowResult(Window window) : base(window.Hwnd)
{
LettersInBetweenScore = WindowResult.NoResult;
}