From 807fa0ee54939b709dc3dd70866e1d837265976e Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Sat, 9 Apr 2022 16:47:17 +0200 Subject: [PATCH] Apply Rider recommendations --- VAR.HttpServer | 2 +- VAR.Toolbox/Code/Bots/AutomationBotFactory.cs | 6 ++---- VAR.Toolbox/Code/Bots/DummyBot.cs | 4 ++-- VAR.Toolbox/Code/Bots/IAutomationBot.cs | 4 ++-- VAR.Toolbox/Code/Bots/TetrisBot.cs | 6 +++--- VAR.Toolbox/Code/HexUtils.cs | 2 +- VAR.Toolbox/Code/Logger.cs | 2 +- VAR.Toolbox/Code/Mouse.cs | 2 +- .../ProxyCmdExecutors/ProxyCmdExecutorFactory.cs | 2 +- .../Code/ProxyCmdExecutors/ProxyCmdExecutorWMIC.cs | 4 ++-- VAR.Toolbox/Code/TextCoders/TextCoderFactory.cs | 2 +- VAR.Toolbox/Code/WorkLog/WorkLogImporterFactory.cs | 2 +- VAR.Toolbox/Properties/AssemblyInfo.cs | 2 +- VAR.Toolbox/UI/Tools/PnlSuspension.cs | 3 +-- .../FrmAutomationBotParams.Designer.cs | 2 +- .../Tools/ScreenAutomation/FrmAutomationBotParams.cs | 4 ++-- .../ScreenAutomation/FrmScreenAutomation.Designer.cs | 2 +- .../UI/Tools/ScreenAutomation/FrmScreenAutomation.cs | 4 ++-- VAR.Toolbox/UI/Tools/WorkLog/FrmWorkLogStats.cs | 12 +++--------- 19 files changed, 29 insertions(+), 38 deletions(-) diff --git a/VAR.HttpServer b/VAR.HttpServer index e80b0e3..f7c1a58 160000 --- a/VAR.HttpServer +++ b/VAR.HttpServer @@ -1 +1 @@ -Subproject commit e80b0e3619158e24d9330a26f554b686aef0c50a +Subproject commit f7c1a581e722512e23c572c0ea1892ba9f0cef60 diff --git a/VAR.Toolbox/Code/Bots/AutomationBotFactory.cs b/VAR.Toolbox/Code/Bots/AutomationBotFactory.cs index ccc1206..1f8894f 100644 --- a/VAR.Toolbox/Code/Bots/AutomationBotFactory.cs +++ b/VAR.Toolbox/Code/Bots/AutomationBotFactory.cs @@ -1,8 +1,6 @@ -using VAR.Toolbox.Code.Bots; - -namespace VAR.Toolbox.Code +namespace VAR.Toolbox.Code.Bots { - public class AutomationBotFactory: BaseFactory + public abstract class AutomationBotFactory: BaseFactory { } } \ No newline at end of file diff --git a/VAR.Toolbox/Code/Bots/DummyBot.cs b/VAR.Toolbox/Code/Bots/DummyBot.cs index c06a90a..9feb71d 100644 --- a/VAR.Toolbox/Code/Bots/DummyBot.cs +++ b/VAR.Toolbox/Code/Bots/DummyBot.cs @@ -12,12 +12,12 @@ namespace VAR.Toolbox.Code.Bots return null; } - public void Init(VAR.Toolbox.Code.IOutputHandler output, IConfiguration config) + public void Init(IOutputHandler output, IConfiguration config) { output.Clean(); } - public Bitmap Process(Bitmap bmpInput, VAR.Toolbox.Code.IOutputHandler output) + public Bitmap Process(Bitmap bmpInput, IOutputHandler output) { return bmpInput; } diff --git a/VAR.Toolbox/Code/Bots/IAutomationBot.cs b/VAR.Toolbox/Code/Bots/IAutomationBot.cs index 08d8966..71688c2 100644 --- a/VAR.Toolbox/Code/Bots/IAutomationBot.cs +++ b/VAR.Toolbox/Code/Bots/IAutomationBot.cs @@ -6,8 +6,8 @@ namespace VAR.Toolbox.Code.Bots public interface IAutomationBot: INamed { IConfiguration GetDefaultConfiguration(); - void Init(VAR.Toolbox.Code.IOutputHandler output, IConfiguration config); - Bitmap Process(Bitmap bmpInput, VAR.Toolbox.Code.IOutputHandler output); + void Init(IOutputHandler output, IConfiguration config); + Bitmap Process(Bitmap bmpInput, IOutputHandler output); string ResponseKeys(); } } \ No newline at end of file diff --git a/VAR.Toolbox/Code/Bots/TetrisBot.cs b/VAR.Toolbox/Code/Bots/TetrisBot.cs index 64ad89a..419c106 100644 --- a/VAR.Toolbox/Code/Bots/TetrisBot.cs +++ b/VAR.Toolbox/Code/Bots/TetrisBot.cs @@ -38,7 +38,7 @@ namespace VAR.Toolbox.Code.Bots return defaultConfiguration; } - public void Init(VAR.Toolbox.Code.IOutputHandler output, IConfiguration config) + public void Init(IOutputHandler output, IConfiguration config) { int gridWidth = config.Get("GridWidth", DefaultGridWidth); int gridHeight = config.Get("GridHeight", DefaultGridHeight); @@ -59,7 +59,7 @@ namespace VAR.Toolbox.Code.Bots output.AddLine($"TetrisBot: Starting {DateTime.UtcNow:s}"); } - public Bitmap Process(Bitmap bmpInput, VAR.Toolbox.Code.IOutputHandler output) + public Bitmap Process(Bitmap bmpInput, IOutputHandler output) { _grid.SampleFromBitmap(bmpInput); SearchShape(); @@ -549,7 +549,7 @@ namespace VAR.Toolbox.Code.Bots } } - public void Print(VAR.Toolbox.Code.IOutputHandler output) + public void Print(IOutputHandler output) { for (int y = 0; y < ShapeSize; y++) { diff --git a/VAR.Toolbox/Code/HexUtils.cs b/VAR.Toolbox/Code/HexUtils.cs index 4facf01..0b48dc8 100644 --- a/VAR.Toolbox/Code/HexUtils.cs +++ b/VAR.Toolbox/Code/HexUtils.cs @@ -3,7 +3,7 @@ using System.Text; namespace VAR.Toolbox.Code { - public class HexUtils + public static class HexUtils { public static byte[] HexStringToBytes(string input) { diff --git a/VAR.Toolbox/Code/Logger.cs b/VAR.Toolbox/Code/Logger.cs index b84cd18..7c58f81 100644 --- a/VAR.Toolbox/Code/Logger.cs +++ b/VAR.Toolbox/Code/Logger.cs @@ -3,7 +3,7 @@ using System.IO; namespace VAR.Toolbox.Code { - public class Logger + public static class Logger { /// /// Obtiene el StreamWriter de salida diff --git a/VAR.Toolbox/Code/Mouse.cs b/VAR.Toolbox/Code/Mouse.cs index ce0fab0..7f68bd7 100644 --- a/VAR.Toolbox/Code/Mouse.cs +++ b/VAR.Toolbox/Code/Mouse.cs @@ -4,7 +4,7 @@ using VAR.Toolbox.Code.Windows; namespace VAR.Toolbox.Code { - public class Mouse + public static class Mouse { public static void Move(int dx, int dy) { diff --git a/VAR.Toolbox/Code/ProxyCmdExecutors/ProxyCmdExecutorFactory.cs b/VAR.Toolbox/Code/ProxyCmdExecutors/ProxyCmdExecutorFactory.cs index 3fcd970..b507826 100644 --- a/VAR.Toolbox/Code/ProxyCmdExecutors/ProxyCmdExecutorFactory.cs +++ b/VAR.Toolbox/Code/ProxyCmdExecutors/ProxyCmdExecutorFactory.cs @@ -1,4 +1,4 @@ namespace VAR.Toolbox.Code.ProxyCmdExecutors { - public class ProxyCmdExecutorFactory : BaseFactory { } + public abstract class ProxyCmdExecutorFactory : BaseFactory { } } \ No newline at end of file diff --git a/VAR.Toolbox/Code/ProxyCmdExecutors/ProxyCmdExecutorWMIC.cs b/VAR.Toolbox/Code/ProxyCmdExecutors/ProxyCmdExecutorWMIC.cs index f109937..dc98656 100644 --- a/VAR.Toolbox/Code/ProxyCmdExecutors/ProxyCmdExecutorWMIC.cs +++ b/VAR.Toolbox/Code/ProxyCmdExecutors/ProxyCmdExecutorWMIC.cs @@ -15,8 +15,8 @@ namespace VAR.Toolbox.Code.ProxyCmdExecutors public bool ExecuteCmd(string cmd, IOutputHandler outputHandler) { - string parameters = string.Format(" /node:\"{0}\" process call create \"cmd.exe /c \\\"{1}\\\"\"", - _configWMIC.Replace("\"", "\\\""), cmd.Replace("\"", "\\\"")); + string parameters = + $" /node:\"{_configWMIC.Replace("\"", "\\\"")}\" process call create \"cmd.exe /c \\\"{cmd.Replace("\"", "\\\"")}\\\"\""; Process process = new Process(); process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; diff --git a/VAR.Toolbox/Code/TextCoders/TextCoderFactory.cs b/VAR.Toolbox/Code/TextCoders/TextCoderFactory.cs index b1c6530..d5d4388 100644 --- a/VAR.Toolbox/Code/TextCoders/TextCoderFactory.cs +++ b/VAR.Toolbox/Code/TextCoders/TextCoderFactory.cs @@ -1,4 +1,4 @@ namespace VAR.Toolbox.Code.TextCoders { - public class TextCoderFactory : BaseFactory { } + public abstract class TextCoderFactory : BaseFactory { } } \ No newline at end of file diff --git a/VAR.Toolbox/Code/WorkLog/WorkLogImporterFactory.cs b/VAR.Toolbox/Code/WorkLog/WorkLogImporterFactory.cs index 4ff2e18..d7ce834 100644 --- a/VAR.Toolbox/Code/WorkLog/WorkLogImporterFactory.cs +++ b/VAR.Toolbox/Code/WorkLog/WorkLogImporterFactory.cs @@ -1,4 +1,4 @@ namespace VAR.Toolbox.Code.WorkLog { - public class WorkLogImporterFactory : BaseFactory { } + public abstract class WorkLogImporterFactory : BaseFactory { } } \ No newline at end of file diff --git a/VAR.Toolbox/Properties/AssemblyInfo.cs b/VAR.Toolbox/Properties/AssemblyInfo.cs index abb6cd7..54fb472 100644 --- a/VAR.Toolbox/Properties/AssemblyInfo.cs +++ b/VAR.Toolbox/Properties/AssemblyInfo.cs @@ -6,7 +6,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("VAR.Toolbox")] -[assembly: AssemblyCopyright("Copyright © VAR 2017-2018")] +[assembly: AssemblyCopyright("Copyright © VAR 2017-2022")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/VAR.Toolbox/UI/Tools/PnlSuspension.cs b/VAR.Toolbox/UI/Tools/PnlSuspension.cs index 7d5c8a2..3d486ec 100644 --- a/VAR.Toolbox/UI/Tools/PnlSuspension.cs +++ b/VAR.Toolbox/UI/Tools/PnlSuspension.cs @@ -92,8 +92,7 @@ namespace VAR.Toolbox.UI.Tools private void SetCountdown(DateTime dateTime, DateTime now) { TimeSpan timeSpan = dateTime - now; - lblCountdown.Text = string.Format("{0:00}:{1:00}:{2:00}:{3:00}", timeSpan.Days, timeSpan.Hours, - timeSpan.Minutes, timeSpan.Seconds); + lblCountdown.Text = $"{timeSpan.Days:00}:{timeSpan.Hours:00}:{timeSpan.Minutes:00}:{timeSpan.Seconds:00}"; } private void CheckTime(CheckBox chk, DateTime dtSuspendAtCustom, DateTime now) diff --git a/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmAutomationBotParams.Designer.cs b/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmAutomationBotParams.Designer.cs index ca46f89..e721cc4 100644 --- a/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmAutomationBotParams.Designer.cs +++ b/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmAutomationBotParams.Designer.cs @@ -1,4 +1,4 @@ -namespace VAR.ScreenAutomation +namespace VAR.Toolbox.UI.Tools.ScreenAutomation { partial class FrmAutomationBotParams { diff --git a/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmAutomationBotParams.cs b/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmAutomationBotParams.cs index e641da2..e0ccd68 100644 --- a/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmAutomationBotParams.cs +++ b/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmAutomationBotParams.cs @@ -6,7 +6,7 @@ using System.Windows.Forms; using VAR.Toolbox.Code.Configuration; using VAR.Toolbox.Controls; -namespace VAR.ScreenAutomation +namespace VAR.Toolbox.UI.Tools.ScreenAutomation { public partial class FrmAutomationBotParams : Frame { @@ -69,7 +69,7 @@ namespace VAR.ScreenAutomation get { if (columnName == "Key" && Parent != null && Parent.Any( - x => x.Key == this.Key && !ReferenceEquals(x, this))) + x => x.Key == Key && !ReferenceEquals(x, this))) { return "duplicate key"; } diff --git a/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmScreenAutomation.Designer.cs b/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmScreenAutomation.Designer.cs index 8071cef..32b9e34 100644 --- a/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmScreenAutomation.Designer.cs +++ b/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmScreenAutomation.Designer.cs @@ -1,4 +1,4 @@ -namespace VAR.ScreenAutomation +namespace VAR.Toolbox.UI.Tools.ScreenAutomation { partial class FrmScreenAutomation { diff --git a/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmScreenAutomation.cs b/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmScreenAutomation.cs index d3ae91a..c2179e0 100644 --- a/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmScreenAutomation.cs +++ b/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmScreenAutomation.cs @@ -10,9 +10,9 @@ using VAR.Toolbox.Controls; // ReSharper disable LocalizableElement -namespace VAR.ScreenAutomation +namespace VAR.Toolbox.UI.Tools.ScreenAutomation { - public partial class FrmScreenAutomation : Frame, Toolbox.UI.IToolForm + public partial class FrmScreenAutomation : Frame, IToolForm { public string ToolName => "ScreenAutomation"; diff --git a/VAR.Toolbox/UI/Tools/WorkLog/FrmWorkLogStats.cs b/VAR.Toolbox/UI/Tools/WorkLog/FrmWorkLogStats.cs index 0135e4c..e09feef 100644 --- a/VAR.Toolbox/UI/Tools/WorkLog/FrmWorkLogStats.cs +++ b/VAR.Toolbox/UI/Tools/WorkLog/FrmWorkLogStats.cs @@ -104,16 +104,12 @@ namespace VAR.Toolbox.UI.Tools.WorkLog currentCulture.DateTimeFormat.CalendarWeekRule, currentCulture.DateTimeFormat.FirstDayOfWeek); if (week != null && week != weekCurrent) { - strDays.Add(string.Format(" [{0:00}] -- {1} h", - week, - tsWeek.TotalHours)); + strDays.Add($" [{week:00}] -- {tsWeek.TotalHours} h"); tsWeek = new TimeSpan(0); } TimeSpan tsDay = dictDaysHours[dateDayCurrent]; - strDays.Add(string.Format("[{0:00}] {1:yyyy-MM-dd} -- {2} h", - weekCurrent, dateDayCurrent, - tsDay.TotalHours)); + strDays.Add($"[{weekCurrent:00}] {dateDayCurrent:yyyy-MM-dd} -- {tsDay.TotalHours} h"); tsTotal += tsDay; tsWeek += tsDay; week = weekCurrent; @@ -124,9 +120,7 @@ namespace VAR.Toolbox.UI.Tools.WorkLog if (tsWeek.TotalHours > 0) { - strDays.Add(string.Format(" [{0:00}] -- {1} h", - week, - tsWeek.TotalHours)); + strDays.Add($" [{week:00}] -- {tsWeek.TotalHours} h"); } lsbDays.Items.Clear();