mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
User/ryanbod/folders enable staticanalysis (#5137)
* Enabling static analysis and settings treat warnings as errors * Fixing/Supressing static analysis warnings in ContextmenuLoader and removing unused code * Fixing static analysis errors in Main.cs * Fixing static analysis warnings for folderpluginSettings.xaml.cs
This commit is contained in:
committed by
GitHub
parent
47736603af
commit
53c4c6cbb8
@@ -21,8 +21,9 @@ namespace Microsoft.Plugin.Folder
|
||||
public ContextMenuLoader(PluginInitContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alive, and instead log the exception")]
|
||||
public List<ContextMenuResult> LoadContextMenus(Result selectedResult)
|
||||
{
|
||||
var contextMenus = new List<ContextMenuResult>();
|
||||
@@ -95,6 +96,7 @@ namespace Microsoft.Plugin.Folder
|
||||
return contextMenus;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alive, and instead log the exception")]
|
||||
private ContextMenuResult CreateOpenContainingFolderResult(SearchResult record)
|
||||
{
|
||||
return new ContextMenuResult
|
||||
@@ -124,35 +126,7 @@ namespace Microsoft.Plugin.Folder
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private Result CreateOpenWithEditorResult(SearchResult record)
|
||||
{
|
||||
string editorPath = "notepad.exe"; // TODO add the ability to create a custom editor
|
||||
|
||||
var name = "Open With Editor: " + Path.GetFileNameWithoutExtension(editorPath);
|
||||
return new Result
|
||||
{
|
||||
Title = name,
|
||||
Action = _ =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(editorPath, record.FullPath);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var message = $"Fail to editor for file at {record.FullPath}";
|
||||
LogException(message, e);
|
||||
_context.API.ShowMsg(message);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
IcoPath = editorPath
|
||||
};
|
||||
}
|
||||
|
||||
public void LogException(string message, Exception e)
|
||||
public static void LogException(string message, Exception e)
|
||||
{
|
||||
Log.Exception($"|Microsoft.Plugin.Folder.ContextMenu|{message}", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user