more braces and whitespace style errors (#5951)

This commit is contained in:
Clint Rutkas 2020-08-14 09:22:12 -07:00 committed by GitHub
parent 9e8b0d2807
commit 913615f1c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 80 additions and 68 deletions

View File

@ -51,8 +51,7 @@ namespace Microsoft.Plugin.Program.Logger
/// Logs an exception
/// </summary>
[MethodImpl(MethodImplOptions.Synchronized)]
internal static void LogException(string classname, string callingMethodName, string loadingProgramPath,
string interpretationMessage, Exception e)
internal static void LogException(string classname, string callingMethodName, string loadingProgramPath, string interpretationMessage, Exception e)
{
Debug.WriteLine($"ERROR{classname}|{callingMethodName}|{loadingProgramPath}|{interpretationMessage}");
@ -122,10 +121,14 @@ namespace Microsoft.Plugin.Program.Logger
private static bool IsKnownWinProgramError(Exception e, string callingMethodName)
{
if (e.TargetSite?.Name == "GetDescription" && callingMethodName == "LnkProgram")
{
return true;
}
if (e is SecurityException || e is UnauthorizedAccessException || e is DirectoryNotFoundException)
{
return true;
}
return false;
}
@ -135,10 +138,14 @@ namespace Microsoft.Plugin.Program.Logger
if (((e.HResult == -2147024774 || e.HResult == -2147009769) && callingMethodName == "ResourceFromPri")
|| (e.HResult == -2147024894 && (callingMethodName == "LogoPathFromUri" || callingMethodName == "ImageFromPath"))
|| (e.HResult == -2147024864 && callingMethodName == "InitializeAppInfo"))
{
return true;
}
if (callingMethodName == "XmlNamespaces")
{
return true;
}
return false;
}

View File

@ -52,13 +52,17 @@ namespace Microsoft.Plugin.Program
var a = Task.Run(() =>
{
if (IsStartupIndexProgramsRequired || !_win32ProgramRepository.Any())
{
Stopwatch.Normal("|Microsoft.Plugin.Program.Main|Win32Program index cost", _win32ProgramRepository.IndexPrograms);
}
});
var b = Task.Run(() =>
{
if (IsStartupIndexProgramsRequired || !_packageRepository.Any())
{
Stopwatch.Normal("|Microsoft.Plugin.Program.Main|Win32Program index cost", _packageRepository.IndexPrograms);
}
});
Task.WaitAll(a, b);
@ -92,7 +96,7 @@ namespace Microsoft.Plugin.Program
public void Init(PluginInitContext context)
{
_context = context ?? throw new ArgumentNullException(nameof(context)); ;
_context = context ?? throw new ArgumentNullException(nameof(context));
_context.API.ThemeChanged += OnThemeChanged;
UpdateUWPIconPath(_context.API.GetCurrentTheme());
}

View File

@ -52,5 +52,7 @@ namespace Microsoft.Plugin.Program
public string UniqueIdentifier { get; set; }
}
public class DisabledProgramSource : ProgramSource { }
public class DisabledProgramSource : ProgramSource
{
}
}

View File

@ -36,7 +36,6 @@ namespace Microsoft.Plugin.Program.Programs.ApplicationActivationHelper
[Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]
public class ApplicationActivationManager : IApplicationActivationManager
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)/*, PreserveSig*/]
public extern IntPtr ActivateApplication([In] string appUserModelId, [In] string arguments, [In] ActivateOptions options, [Out] out uint processId);

View File

@ -7,7 +7,6 @@ using Windows.Foundation;
namespace Microsoft.Plugin.Program.Programs
{
/// <summary>
/// This is a simple wrapper class around the PackageCatalog to facilitate unit testing.
/// </summary>

View File

@ -23,7 +23,9 @@ namespace Microsoft.Plugin.Program.Programs
public string InstalledLocation { get; } = string.Empty;
public PackageWrapper() { }
public PackageWrapper()
{
}
public PackageWrapper(string Name, string FullName, string FamilyName, bool IsFramework, bool IsDevelopmentMode, string InstalledLocation)
{
@ -65,8 +67,7 @@ namespace Microsoft.Plugin.Program.Programs
package.Id.FamilyName,
package.IsFramework,
package.IsDevelopmentMode,
path
);
path);
}
}
}

View File

@ -98,10 +98,8 @@ namespace Microsoft.Plugin.Program.Programs
Where(a => a.IsNamespaceDeclaration).
GroupBy(
a => a.Name.Namespace == XNamespace.None ? string.Empty : a.Name.LocalName,
a => XNamespace.Get(a.Value)
).Select(
g => g.First().ToString()
).ToArray();
a => XNamespace.Get(a.Value)).Select(
g => g.First().ToString()).ToArray();
return namespaces;
}
else

View File

@ -26,7 +26,6 @@ using static Microsoft.Plugin.Program.Programs.UWP;
namespace Microsoft.Plugin.Program.Programs
{
[Serializable]
public class UWPApplication : IProgram
{
@ -130,7 +129,7 @@ namespace Microsoft.Plugin.Program.Programs
Glyph = "\xE7EF",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.Enter,
AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
Action = _ =>
{
string command = "shell:AppsFolder\\" + UniqueIdentifier;
@ -142,8 +141,7 @@ namespace Microsoft.Plugin.Program.Programs
Process.Start(info);
return true;
},
}
);
});
}
contextMenus.Add(
@ -154,7 +152,7 @@ namespace Microsoft.Plugin.Program.Programs
Glyph = "\xE838",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.E,
AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
Action = _ =>
{
Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", Package.Location));

View File

@ -23,7 +23,6 @@ using Wox.Plugin;
namespace Microsoft.Plugin.Program.Programs
{
[Serializable]
public class Win32Program : IProgram
{
@ -211,7 +210,7 @@ namespace Microsoft.Plugin.Program.Programs
{
FileName = LnkResolvedPath ?? FullPath,
WorkingDirectory = ParentDirectory,
UseShellExecute = true
UseShellExecute = true,
};
Main.StartProcess(Process.Start, info);
@ -250,7 +249,7 @@ namespace Microsoft.Plugin.Program.Programs
Glyph = "\xE7EF",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.Enter,
AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
Action = _ =>
{
var info = new ProcessStartInfo
@ -258,7 +257,7 @@ namespace Microsoft.Plugin.Program.Programs
FileName = FullPath,
WorkingDirectory = ParentDirectory,
Verb = "runas",
UseShellExecute = true
UseShellExecute = true,
};
Task.Run(() => Main.StartProcess(Process.Start, info));
@ -276,7 +275,7 @@ namespace Microsoft.Plugin.Program.Programs
Glyph = "\xE838",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.E,
AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
Action = _ =>
{
Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", ParentDirectory));
@ -632,7 +631,6 @@ namespace Microsoft.Plugin.Program.Programs
// Function to obtain the list of applications, the locations of which have been added to the env variable PATH
private static ParallelQuery<Win32Program> PathEnvironmentPrograms(IList<string> suffixes)
{
// To get all the locations stored in the PATH env variable
var pathEnvVariable = Environment.GetEnvironmentVariable("PATH");
string[] searchPaths = pathEnvVariable.Split(Path.PathSeparator);
@ -757,14 +755,18 @@ namespace Microsoft.Plugin.Program.Programs
using (var key = root.OpenSubKey(subkey))
{
if (key == null)
{
return string.Empty;
}
var defaultValue = string.Empty;
path = key.GetValue(defaultValue) as string;
}
if (string.IsNullOrEmpty(path))
{
return string.Empty;
}
// fix path like this: ""\"C:\\folder\\executable.exe\""
return path = path.Trim('"', ' ');
@ -782,12 +784,16 @@ namespace Microsoft.Plugin.Program.Programs
private static Win32Program GetProgramFromPath(string path)
{
if (string.IsNullOrEmpty(path))
{
return new Win32Program();
}
path = Environment.ExpandEnvironmentVariables(path);
if (!File.Exists(path))
{
return new Win32Program();
}
var entry = CreateWin32Program(path);
entry.ExecutableName = Path.GetFileName(path);
@ -812,7 +818,6 @@ namespace Microsoft.Plugin.Program.Programs
{
public bool Equals(Win32Program app1, Win32Program app2)
{
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

@ -34,7 +34,6 @@ namespace Microsoft.Plugin.Program.Storage
{
if (args.IsComplete)
{
try
{
var packageWrapper = PackageWrapper.GetWrapperFromPackage(args.Package);

View File

@ -10,7 +10,6 @@ namespace Microsoft.Plugin.Program.Storage
{
internal class Win32ProgramFileSystemWatchers : IDisposable
{
public readonly string[] _pathsToWatch;
public List<FileSystemWatcherWrapper> _fileSystemWatchers;
private bool _disposed = false;

View File

@ -21,8 +21,7 @@ namespace Microsoft.Plugin.Program.Views.Commands
Location = x.Location,
Name = x.Name,
UniqueIdentifier = x.UniqueIdentifier,
}
));
}));
// Even though these are disabled, we still want to display them so users can enable later on
Main._settings
@ -40,8 +39,7 @@ namespace Microsoft.Plugin.Program.Views.Commands
Location = x.Location,
Name = x.Name,
UniqueIdentifier = x.UniqueIdentifier,
}
));
}));
return list;
}
@ -95,8 +93,7 @@ namespace Microsoft.Plugin.Program.Views.Commands
Location = x.Location,
UniqueIdentifier = x.UniqueIdentifier,
Enabled = false,
}
));
}));
}
internal static void RemoveDisabledFromSettings(this List<ProgramSource> list)
@ -115,13 +112,17 @@ namespace Microsoft.Plugin.Program.Views.Commands
internal static bool IsReindexRequired(this List<ProgramSource> selectedItems)
{
if (selectedItems.Where(t1 => t1.Enabled).Any())
{
return true;
}
// ProgramSources holds list of user added directories,
// so when we enable/disable we need to reindex to show/not show the programs
// that are found in those directories.
if (selectedItems.Where(t1 => Main._settings.ProgramSources.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier)).Any())
{
return true;
}
return false;
}

View File

@ -218,7 +218,9 @@ namespace Microsoft.Plugin.Program.Views
}
if (selectedItems.IsReindexRequired())
{
ReIndexing();
}
programSourceView.SelectedItems.Clear();

View File

@ -13,11 +13,9 @@ namespace Microsoft.Plugin.Program.Win32
class NativeMethods
{
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
internal static extern Hresult SHCreateStreamOnFileEx(string fileName, Stgm grfMode, uint attributes, bool create,
IStream reserved, out IStream stream);
internal static extern Hresult SHCreateStreamOnFileEx(string fileName, Stgm grfMode, uint attributes, bool create, IStream reserved, out IStream stream);
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
internal static extern Hresult SHLoadIndirectString(string pszSource, StringBuilder pszOutBuf, uint cchOutBuf,
IntPtr ppvReserved);
internal static extern Hresult SHLoadIndirectString(string pszSource, StringBuilder pszOutBuf, uint cchOutBuf, IntPtr ppvReserved);
}
}