mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
[NetAnalyzers]CA1031 suppressions cleanup (#18706)
This commit is contained in:
committed by
GitHub
parent
33072c7ee3
commit
b33bc2ecd0
@@ -168,7 +168,6 @@ namespace Microsoft.Plugin.Program
|
||||
return menuOptions;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alive and show the user a warning message")]
|
||||
public static void StartProcess(Func<ProcessStartInfo, Process> runProcess, ProcessStartInfo info)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -30,7 +30,6 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
: Enumerable.Empty<IPackage>();
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to catch all exception to prevent error in a program from affecting loading of program plugin.")]
|
||||
private static PackageWrapper TryGetWrapperFromPackage(Package package)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -132,7 +132,6 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
public bool HasArguments { get; set; }
|
||||
|
||||
// Retrieve the target path using Shell Link
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "HRESULT E_FAIL is thrown while fetching description and E_FAIL does not relate to any specific exception.")]
|
||||
public string RetrieveTargetPath(string path)
|
||||
{
|
||||
var link = new ShellLink();
|
||||
|
||||
@@ -127,7 +127,6 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
Version = PackageVersion.Unknown;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Intentionally keeping the process alive.")]
|
||||
public static UWPApplication[] All()
|
||||
{
|
||||
var windows10 = new Version(10, 0);
|
||||
@@ -164,7 +163,6 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Intentionally keeping the process alive.")]
|
||||
private static IEnumerable<IPackage> CurrentUserPackages()
|
||||
{
|
||||
return PackageManagerWrapper.FindPackagesForCurrentUser().Where(p =>
|
||||
|
||||
@@ -125,7 +125,6 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
return result;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Intentionally keeping the process alive.")]
|
||||
public List<ContextMenuResult> ContextMenus(string queryArguments, IPublicAPI api)
|
||||
{
|
||||
if (api == null)
|
||||
@@ -205,7 +204,6 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
return contextMenus;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Intentionally keeping the process alive, and showing the user an error message")]
|
||||
private async void Launch(IPublicAPI api, string queryArguments)
|
||||
{
|
||||
var appManager = new ApplicationActivationHelper.ApplicationActivationManager();
|
||||
@@ -288,9 +286,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#pragma warning disable CA1031 // Do not catch general exception types
|
||||
catch (Exception e)
|
||||
#pragma warning restore CA1031 // Do not catch general exception types
|
||||
{
|
||||
ProgramLogger.Exception($"Unable to parse manifest file for {DisplayName}", e, MethodBase.GetCurrentMethod().DeclaringType, manifest);
|
||||
}
|
||||
|
||||
@@ -247,7 +247,6 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
return result;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Intentionally keeping the process alive.")]
|
||||
public List<ContextMenuResult> ContextMenus(string queryArguments, IPublicAPI api)
|
||||
{
|
||||
if (api == null)
|
||||
@@ -361,8 +360,6 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
return ExecutableName;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Any error in CreateWin32Program should not prevent other programs from loading.")]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "User facing path needs to be shown in lowercase.")]
|
||||
private static Win32Program CreateWin32Program(string path)
|
||||
{
|
||||
try
|
||||
@@ -400,8 +397,6 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
private static readonly Regex InternetShortcutURLPrefixes = new Regex(@"^steam:\/\/(rungameid|run)\/|^com\.epicgames\.launcher:\/\/apps\/", RegexOptions.Compiled);
|
||||
|
||||
// This function filters Internet Shortcut programs
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Any error in InternetShortcutProgram should not prevent other programs from loading.")]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "User facing path needs to be shown in lowercase.")]
|
||||
private static Win32Program InternetShortcutProgram(string path)
|
||||
{
|
||||
try
|
||||
@@ -481,8 +476,6 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Unsure of what exceptions are caught here while enabling static analysis")]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "User facing path needs to be shown in lowercase.")]
|
||||
private static Win32Program LnkProgram(string path)
|
||||
{
|
||||
try
|
||||
@@ -544,7 +537,6 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Any error in ExeProgram should not prevent other programs from loading.")]
|
||||
private static Win32Program ExeProgram(string path)
|
||||
{
|
||||
try
|
||||
@@ -652,7 +644,6 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
: null;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Minimise the effect of error on other programs")]
|
||||
private static IEnumerable<string> ProgramPaths(string directory, IList<string> suffixes, bool recursiveSearch = true)
|
||||
{
|
||||
if (!Directory.Exists(directory))
|
||||
@@ -925,7 +916,6 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
return program;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Keeping the process alive but logging the exception")]
|
||||
public static IList<Win32Program> All(ProgramPluginSettings settings)
|
||||
{
|
||||
if (settings == null)
|
||||
|
||||
@@ -44,9 +44,7 @@ namespace Microsoft.Plugin.Program.Storage
|
||||
{
|
||||
Directory.GetFiles(path);
|
||||
}
|
||||
#pragma warning disable CA1031 // Do not catch general exception types
|
||||
catch (Exception ex)
|
||||
#pragma warning restore CA1031 // Do not catch general exception types
|
||||
{
|
||||
Log.Exception($"Failed to get files in {path}", ex, typeof(Win32ProgramFileSystemWatchers));
|
||||
invalidPaths.Add(path);
|
||||
|
||||
@@ -92,7 +92,6 @@ namespace Microsoft.Plugin.Program.Storage
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Intentionally keeping the process alive>")]
|
||||
private void OnAppRenamed(object sender, RenamedEventArgs e)
|
||||
{
|
||||
string oldPath = e.OldFullPath;
|
||||
@@ -142,7 +141,6 @@ namespace Microsoft.Plugin.Program.Storage
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Intentionally keeping the process alive")]
|
||||
private void OnAppDeleted(object sender, FileSystemEventArgs e)
|
||||
{
|
||||
string path = e.FullPath;
|
||||
|
||||
Reference in New Issue
Block a user