From 23848e80147978e6cd894ac9aa2e869503ddc622 Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Sat, 5 Feb 2022 12:47:27 +0100 Subject: [PATCH] [Feature] Fix warnings (#313), version 1.2.3.8 --- .editorconfig | 4 ++++ Business/Menus.cs | 12 ++++++------ GlobalSuppressions.cs | 2 +- Helpers/DragDropHelper.cs | 16 ++++++---------- SystemTrayMenu.csproj | 20 ++++++++++++++++++-- SystemTrayMenu.sln | 5 +++++ UserInterface/Menu.cs | 12 ++++++------ Utilities/Log.cs | 2 +- Utilities/SingleAppInstance.cs | 2 +- 9 files changed, 48 insertions(+), 27 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7ff65bf --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# WFAC010: Unsupported high DPI configuration +dotnet_diagnostic.WFAC010.severity = silent diff --git a/Business/Menus.cs b/Business/Menus.cs index 05a18c0..b72ce6f 100644 --- a/Business/Menus.cs +++ b/Business/Menus.cs @@ -859,6 +859,12 @@ namespace SystemTrayMenu.Business Log.ProcessStart(path); } + private static int GetRowUnderCursor(DataGridView dgv, Point location) + { + DataGridView.HitTestInfo myHitTest = dgv.HitTest(location.X, location.Y); + return myHitTest.RowIndex; + } + private Menu Create(MenuData menuData, string title = null) { Menu menu = new(); @@ -1106,12 +1112,6 @@ namespace SystemTrayMenu.Business } } - private int GetRowUnderCursor(DataGridView dgv, Point location) - { - DataGridView.HitTestInfo myHitTest = dgv.HitTest(location.X, location.Y); - return myHitTest.RowIndex; - } - private void Dgv_MouseUp(object sender, MouseEventArgs e) { lastMouseDownRowIndex = -1; diff --git a/GlobalSuppressions.cs b/GlobalSuppressions.cs index 82fbfd9..a572331 100644 --- a/GlobalSuppressions.cs +++ b/GlobalSuppressions.cs @@ -13,4 +13,4 @@ using System.Diagnostics.CodeAnalysis; [assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1000:Keywords should be spaced correctly", Justification = "new() should not be replaced by new() ")] [assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "Standard codecleanup removes the this")] -[assembly: SuppressMessage("Interoperability", "CA1416:Check platform compatibility", Justification = "")] +[assembly: SuppressMessage("Interoperability", "CA1416:Check platform compatibility", Justification = "this is a long way to get platform compatibility")] diff --git a/Helpers/DragDropHelper.cs b/Helpers/DragDropHelper.cs index 258eddb..3d72883 100644 --- a/Helpers/DragDropHelper.cs +++ b/Helpers/DragDropHelper.cs @@ -74,18 +74,14 @@ namespace SystemTrayMenu.Helper string pathIconPng = Path.Combine(pathToStoreIcons, $"{hostname}.png"); string urlGoogleIconDownload = @"http://www.google.com/s2/favicons?sz=32&domain=" + url; - HttpClient client = new HttpClient(); + HttpClient client = new(); using (HttpResponseMessage response = client.GetAsync(urlGoogleIconDownload).Result) { - using (HttpContent content = response.Content) - { - Stream stream = content.ReadAsStreamAsync().Result; - using (var fileStream = File.Create(pathIconPng)) - { - stream.Seek(0, SeekOrigin.Begin); - stream.CopyTo(fileStream); - } - } + using HttpContent content = response.Content; + Stream stream = content.ReadAsStreamAsync().Result; + using var fileStream = File.Create(pathIconPng); + stream.Seek(0, SeekOrigin.Begin); + stream.CopyTo(fileStream); } string pathIcon = Path.Combine(pathToStoreIcons, $"{hostname}.ico"); diff --git a/SystemTrayMenu.csproj b/SystemTrayMenu.csproj index 8d927e6..61d50ed 100644 --- a/SystemTrayMenu.csproj +++ b/SystemTrayMenu.csproj @@ -33,14 +33,17 @@ bin\x64\Debug\ MinimumRecommendedRules.ruleset + 1701;1702;WFAC010 bin\AnyCPU\Debug\ MinimumRecommendedRules.ruleset + 1701;1702;WFAC010 bin\x86\Debug\ MinimumRecommendedRules.ruleset + 1701;1702;WFAC010 bin\x64\Release\ @@ -70,31 +73,37 @@ none true True + 1701;1702;WFAC010 none true True + 1701;1702;WFAC010 none true True + 1701;1702;WFAC010 none true True + 1701;1702;WFAC010 none true True + 1701;1702;WFAC010 none true True + 1701;1702;WFAC010 @@ -307,7 +316,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + @@ -320,6 +329,10 @@ SettingsSingleFileGenerator Settings.Designer.cs + + True + \ + taskkill /fi "pid gt 0" /im SystemTrayMenu.exe @@ -331,7 +344,10 @@ EXIT 0 LICENSE SystemTrayMenu - Resources\app.manifest 10.0.17763.0 + Resources\app.manifest + README.md + True + True \ No newline at end of file diff --git a/SystemTrayMenu.sln b/SystemTrayMenu.sln index e4695a9..a27e62d 100644 --- a/SystemTrayMenu.sln +++ b/SystemTrayMenu.sln @@ -17,6 +17,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SystemTrayMenuDocuments", " EndProject Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "Packaging", "Packaging\Packaging.wapproj", "{01D77F37-786A-4DC4-A1AD-BC1EEC54EAE3}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D34D9392-6592-4F44-B8D4-1781502FE7E6}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index ebe8703..ca01853 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -749,16 +749,16 @@ namespace SystemTrayMenu.UserInterface .Replace("*", " "); // Replace special characters - string tmp = new string(searchString); + string tmp = new(searchString); searchString = string.Empty; foreach (char ch in tmp) { - switch(ch) + searchString += ch switch { - case '[': searchString += "[[]"; break; - case ']': searchString += "[]]"; break; - default: searchString += ch; break; - } + '[' => "[[]", + ']' => "[]]", + _ => ch, + }; } string like = string.Empty; diff --git a/Utilities/Log.cs b/Utilities/Log.cs index 88a5091..fba1860 100644 --- a/Utilities/Log.cs +++ b/Utilities/Log.cs @@ -24,7 +24,7 @@ namespace SystemTrayMenu.Utilities internal static void Initialize() { string fileNamePath = GetLogFilePath(); - FileInfo fileInfo = new FileInfo(fileNamePath); + FileInfo fileInfo = new(fileNamePath); if (fileInfo.Length > 2000000) { string fileNamePathLast = GetLogFilePath(LogfileLastExtension); diff --git a/Utilities/SingleAppInstance.cs b/Utilities/SingleAppInstance.cs index c0fff7e..d385947 100644 --- a/Utilities/SingleAppInstance.cs +++ b/Utilities/SingleAppInstance.cs @@ -32,7 +32,7 @@ namespace SystemTrayMenu.Utilities try { - List virtualKeyCodesModifiers = new List(); + List virtualKeyCodesModifiers = new(); foreach (string key in modifiers.ToString().ToUpperInvariant().Split(", ")) { if (key == "NONE")