[Feature] Migrate from deprecated FxCop analyzers to .NET analyzers (#152), version 1.0.17.16

This commit is contained in:
Markus Hofknecht 2021-04-17 02:39:48 +02:00
parent 83a9d29da2
commit a5e1ff4c25
36 changed files with 76 additions and 74 deletions

View file

@ -20,7 +20,7 @@ namespace SystemTrayMenu.Handler
private readonly KeyboardHook hook = new KeyboardHook();
private int iRowKey = -1;
private int iMenuKey = 0;
private int iMenuKey;
public KeyboardInput(Menu[] menus)
{
@ -39,7 +39,7 @@ namespace SystemTrayMenu.Handler
internal event EventHandlerEmpty Cleared;
internal bool InUse { get; set; } = false;
internal bool InUse { get; set; }
public void Dispose()
{

View file

@ -29,15 +29,15 @@ namespace SystemTrayMenu.Business
private readonly DgvMouseRow dgvMouseRow = new DgvMouseRow();
private readonly WaitToLoadMenu waitToOpenMenu = new WaitToLoadMenu();
private readonly KeyboardInput keyboardInput = null;
private readonly KeyboardInput keyboardInput;
private readonly Timer timerStillActiveCheck = new Timer();
private readonly WaitLeave waitLeave = new WaitLeave(MenuDefines.TimeUntilClose);
private DateTime deactivatedTime = DateTime.MinValue;
private OpenCloseState openCloseState = OpenCloseState.Default;
private RowData loadingRowData = null;
private bool showingMessageBox = false;
private RowData loadingRowData;
private bool showingMessageBox;
private TaskbarPosition taskbarPosition = new WindowsTaskbar().Position;
private bool searchTextChanging = false;
private bool searchTextChanging;
public Menus()
{
@ -480,7 +480,7 @@ namespace SystemTrayMenu.Business
menuToDispose.CmdKeyProcessed -= keyboardInput.CmdKeyProcessed;
menuToDispose.SearchTextChanging -= keyboardInput.SearchTextChanging;
menuToDispose.SearchTextChanged -= Menu_SearchTextChanged;
DataGridView dgv = menuToDispose?.GetDataGridView();
DataGridView dgv = menuToDispose.GetDataGridView();
if (dgv != null)
{
dgv.CellMouseEnter -= dgvMouseRow.CellMouseEnter;
@ -501,7 +501,7 @@ namespace SystemTrayMenu.Business
}
}
menuToDispose?.Dispose();
menuToDispose.Dispose();
}
}

View file

@ -14,12 +14,12 @@ namespace SystemTrayMenu.Handler
internal class WaitToLoadMenu : IDisposable
{
private readonly Timer timerStartLoad = new Timer();
private DataGridView dgv = null;
private int rowIndex = 0;
private DataGridView dgvTmp = null;
private int rowIndexTmp = 0;
private DataGridView dgv;
private int rowIndex;
private DataGridView dgvTmp;
private int rowIndexTmp;
private int mouseMoveEvents = 0;
private int mouseMoveEvents;
private DateTime dateTimeLastMouseMoveEvent = DateTime.Now;
private bool checkForMouseActive = true;
@ -37,7 +37,7 @@ namespace SystemTrayMenu.Handler
internal event Action<DataGridView, int> MouseEnterOk;
internal bool MouseActive { get; set; } = false;
internal bool MouseActive { get; set; }
public void Dispose()
{

View file

@ -15,10 +15,10 @@ namespace SystemTrayMenu
public static class Config
{
private static bool readDarkModeDone = false;
private static bool isDarkMode = false;
private static bool readHideFileExtdone = false;
private static bool isHideFileExtension = false;
private static bool readDarkModeDone;
private static bool isDarkMode;
private static bool readHideFileExtdone;
private static bool isHideFileExtension;
public static bool IsHideFileExtdone => IsHideFileExtension();

View file

@ -26,9 +26,9 @@ namespace SystemTrayMenu.DataClasses
private string workingDirectory;
private string arguments;
private string text;
private Icon icon = null;
private Icon icon;
private bool diposeIcon = true;
private bool isDisposed = false;
private bool isDisposed;
internal RowData()
{
@ -366,7 +366,8 @@ namespace SystemTrayMenu.DataClasses
{
Log.Warn(
$"path:'{TargetFilePath}', " +
$"iconFile:'{iconFile}'", ex);
$"iconFile:'{iconFile}'",
ex);
}
else
{
@ -404,7 +405,8 @@ namespace SystemTrayMenu.DataClasses
{
Log.Warn(
$"path:'{TargetFilePath}', " +
$"executable:'{executable}'", ex);
$"executable:'{executable}'",
ex);
}
else
{

View file

@ -10,8 +10,8 @@ namespace SystemTrayMenu.Helper
public class DgvMouseRow : IDisposable
{
private readonly Timer timerRaiseRowMouseLeave = new Timer();
private DataGridView dgv = null;
private DataGridViewCellEventArgs eventArgs = null;
private DataGridView dgv;
private DataGridViewCellEventArgs eventArgs;
internal DgvMouseRow()
{

View file

@ -22,8 +22,8 @@ namespace SystemTrayMenu.UserInterface
private readonly Timer timer = new Timer();
private FadingState state = FadingState.Idle;
private double opacity = 0.00;
private bool visible = false;
private double opacity;
private bool visible;
internal Fading()
{

View file

@ -42,27 +42,27 @@ namespace SystemTrayMenu.DllImports
}
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern bool IsIconic(IntPtr hWnd);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, IntPtr ProcessId);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern uint GetCurrentThreadId();
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern bool AttachThreadInput(uint idAttach, uint idAttachTo, bool fAttach);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern bool BringWindowToTop(IntPtr hWnd);
}
}

View file

@ -19,7 +19,7 @@ namespace SystemTrayMenu.DllImports
// The CreatePopupMenu function creates a drop-down menu, submenu, or shortcut menu. The menu is initially empty. You can insert or append menu items by using the InsertMenuItem function. You can also use the InsertMenu function to insert menu items and the AppendMenu function to append menu items.
[DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern IntPtr CreatePopupMenu();
}
}

View file

@ -18,7 +18,7 @@ namespace SystemTrayMenu.DllImports
}
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern int DestroyIcon(IntPtr hIcon);
}
}

View file

@ -19,7 +19,7 @@ namespace SystemTrayMenu.DllImports
// The DestroyMenu function destroys the specified menu and frees any memory that the menu occupies.
[DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern bool DestroyMenu(IntPtr hMenu);
}
}

View file

@ -18,7 +18,7 @@ namespace SystemTrayMenu.DllImports
}
[DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern int FindExecutable(string lpFile, string lpDirectory, [Out] StringBuilder lpResult);
}
}

View file

@ -18,7 +18,7 @@ namespace SystemTrayMenu.DllImports
}
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
}
}

View file

@ -18,7 +18,7 @@ namespace SystemTrayMenu.DllImports
}
[DllImport("gdi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
}
}

View file

@ -41,7 +41,7 @@ namespace SystemTrayMenu.DllImports
/// <param name="flags">flags.</param>
/// <returns>IntPtr.</returns>
[DllImport("comctl32", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
internal static extern IntPtr ImageList_GetIcon(
IntPtr himl,
int i,

View file

@ -19,7 +19,7 @@ namespace SystemTrayMenu.DllImports
// Determines the default menu item on the specified menu
[DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern int GetMenuDefaultItem(IntPtr hMenu, bool fByPos, uint gmdiFlags);
}
}

View file

@ -20,7 +20,7 @@ namespace SystemTrayMenu.DllImports
}
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern int GetSystemMetrics(int nIndex);
}
}

View file

@ -34,21 +34,21 @@ namespace SystemTrayMenu.DllImports
}
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint virtualKeyCode);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern uint MapVirtualKey(uint uCode, uint uMapType);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern int GetKeyNameText(uint lParam, [Out] StringBuilder lpString, int nSize);
}
}

View file

@ -41,7 +41,7 @@ namespace SystemTrayMenu.DllImports
}
[DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern IntPtr SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]

View file

@ -19,7 +19,7 @@ namespace SystemTrayMenu.DllImports
// Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace.
[DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern int SHGetDesktopFolder(out IntPtr ppshf);
}
}

View file

@ -30,7 +30,7 @@ namespace SystemTrayMenu.DllImports
}
[DllImport("Shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern IntPtr SHGetFileInfo(
string pszPath,
uint dwFileAttributes,

View file

@ -19,7 +19,7 @@ namespace SystemTrayMenu.DllImports
}
[DllImport("shfolder.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath);
}
}

View file

@ -33,7 +33,7 @@ namespace SystemTrayMenu.DllImports
}
[DllImport("user32.dll", EntryPoint = "SetWindowPos", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern bool SetWindowPos(
int hWnd, // Window handle
int hWndInsertAfter, // Placement-order handle

View file

@ -13,7 +13,7 @@ namespace SystemTrayMenu.DllImports
public static partial class NativeMethods
{
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
}
}

View file

@ -17,7 +17,7 @@ namespace SystemTrayMenu.DllImports
}
[DllImport("shlwapi.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern int StrCmpLogicalW(string x, string y);
}
}

View file

@ -20,7 +20,7 @@ namespace SystemTrayMenu.DllImports
// Takes a STRRET structure returned by IShellFolder::GetDisplayNameOf, converts it to a string, and places the result in a buffer.
[DllImport("shlwapi.dll", EntryPoint = "StrRetToBuf", ExactSpelling = false, SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern int StrRetToBuf(IntPtr pstr, IntPtr pidl, StringBuilder pszBuf, int cchBuf);
}
}

View file

@ -55,7 +55,7 @@ namespace SystemTrayMenu.DllImports
// The TrackPopupMenuEx function displays a shortcut menu at the specified location and tracks the selection of items on the shortcut menu. The shortcut menu can appear anywhere on the screen.
[DllImport("user32.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
private static extern uint TrackPopupMenuEx(IntPtr hmenu, TPM flags, int x, int y, IntPtr hwnd, IntPtr lptpm);
}
}

View file

@ -39,5 +39,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.17.15")]
[assembly: AssemblyFileVersion("1.0.17.15")]
[assembly: AssemblyVersion("1.0.17.16")]
[assembly: AssemblyFileVersion("1.0.17.16")]

View file

@ -223,11 +223,12 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.6">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.164">
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View file

@ -1,6 +1,6 @@
namespace SystemTrayMenu.UserInterface
{
partial class AboutBox
internal partial class AboutBox
{
/// <summary>
/// Required designer variable.

View file

@ -26,9 +26,9 @@ namespace SystemTrayMenu.UserInterface
/// http://www.forestmoon.com
/// .
/// </remarks>
public partial class AboutBox : Form
internal partial class AboutBox : Form
{
private bool isPainted = false;
private bool isPainted;
private string entryAssemblyName;
private string callingAssemblyName;
private string executingAssemblyName;
@ -814,8 +814,7 @@ namespace SystemTrayMenu.UserInterface
int intResult = string.Compare(
((ListViewItem)x).SubItems[intCol].Text,
((ListViewItem)y).SubItems[intCol].Text,
CultureInfo.InvariantCulture,
CompareOptions.None);
StringComparison.Ordinal);
if (isAscending)
{
return intResult;

View file

@ -19,7 +19,7 @@ namespace SystemTrayMenu.UserInterface
private const int Interval60FPS = 16; // 60fps=>1s/60fps=~16.6ms
private readonly Timer load = new Timer();
private readonly NotifyIcon notifyIcon = new NotifyIcon();
private readonly int indexLoad = 0;
private readonly int indexLoad;
private readonly List<Icon> bitmapsLoading = new List<Icon>()
{
R.L010, R.L020, R.L030,
@ -28,8 +28,8 @@ namespace SystemTrayMenu.UserInterface
};
private DateTime timeLoadingStart;
private bool threadsLoading = false;
private int loadCount = 0;
private bool threadsLoading;
private int loadCount;
public AppNotifyIcon()
{

View file

@ -128,7 +128,7 @@ namespace SystemTrayMenu.UserInterface.FolderBrowseDialog
}
[DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
internal static extern int SHCreateItemFromParsingName(
[MarshalAs(UnmanagedType.LPWStr)] string pszPath,
IntPtr pbc,

View file

@ -18,8 +18,8 @@ namespace SystemTrayMenu.UserInterface
internal partial class Menu : Form
{
private readonly Fading fading = new Fading();
private bool isShowing = false;
private bool directionToRight = false;
private bool isShowing;
private bool directionToRight;
internal Menu()
{
@ -155,7 +155,7 @@ namespace SystemTrayMenu.UserInterface
TopRight,
}
internal int Level { get; set; } = 0;
internal int Level { get; set; }
internal bool IsUsable => Visible && !fading.IsHiding &&
!IsDisposed && !Disposing;

View file

@ -18,7 +18,7 @@ namespace SystemTrayMenu.UserInterface
public partial class SettingsForm : Form
{
private readonly string newHotKey = string.Empty;
private bool inHotkey = false;
private bool inHotkey;
public SettingsForm()
{

View file

@ -12,9 +12,9 @@ namespace SystemTrayMenu.Utilities
internal static class FolderOptions
{
private static bool hideHiddenEntries = false;
private static bool hideSystemEntries = false;
private static IShellDispatch4 iShellDispatch4 = null;
private static bool hideHiddenEntries;
private static bool hideSystemEntries;
private static IShellDispatch4 iShellDispatch4;
internal static void Initialize()
{