From 191f1f30209c5fee4f36424e0a2b86e32d387d32 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Tue, 8 Mar 2022 10:37:58 +1000 Subject: [PATCH] Enable CA1044 and fix noncompliance getters with lower visibility than setters, or set-only props --- Common.ruleset | 2 +- src/BizHawk.Client.Common/IMainFormForApi.cs | 4 ++-- src/BizHawk.Client.Common/lua/LuaLibraryBase.cs | 2 +- src/BizHawk.Client.Common/movie/MovieSession.cs | 2 +- .../movie/interfaces/IMovieSession.cs | 2 +- .../movie/interfaces/ITasMovie.cs | 4 ++-- .../CustomControls/InputRoll/RollColumn.cs | 1 + src/BizHawk.Client.EmuHawk/IMainFormForTools.cs | 4 ++-- src/BizHawk.Client.EmuHawk/UIHelper.cs | 3 +++ .../config/GB/GBPrefControl.cs | 2 +- .../tools/Lua/LuaPictureBox.cs | 2 +- src/BizHawk.Client.EmuHawk/tools/ToolFormBase.cs | 12 ++++++------ .../controls/components/AnalogStickPanel.cs | 4 ++-- src/BizHawk.Emulation.Cores/Calculators/TI83/TI83.cs | 4 ++-- 14 files changed, 26 insertions(+), 22 deletions(-) diff --git a/Common.ruleset b/Common.ruleset index 0cff701a6d..91d686381d 100644 --- a/Common.ruleset +++ b/Common.ruleset @@ -113,7 +113,7 @@ - + diff --git a/src/BizHawk.Client.Common/IMainFormForApi.cs b/src/BizHawk.Client.Common/IMainFormForApi.cs index 649f2c2c13..ff6f4286ad 100644 --- a/src/BizHawk.Client.Common/IMainFormForApi.cs +++ b/src/BizHawk.Client.Common/IMainFormForApi.cs @@ -18,7 +18,7 @@ namespace BizHawk.Client.Common bool EmulatorPaused { get; } /// only referenced from EmuClientApi - bool InvisibleEmulation { set; } + bool InvisibleEmulation { get; set; } /// only referenced from EmuClientApi bool IsSeeking { get; } @@ -30,7 +30,7 @@ namespace BizHawk.Client.Common (HttpCommunication HTTP, MemoryMappedFiles MMF, SocketServer Sockets) NetworkingHelpers { get; } /// only referenced from EmuClientApi - bool PauseAvi { set; } + bool PauseAvi { get; set; } /// only referenced from EmuClientApi void ClearHolds(); diff --git a/src/BizHawk.Client.Common/lua/LuaLibraryBase.cs b/src/BizHawk.Client.Common/lua/LuaLibraryBase.cs index b44d2e2708..f57af25f7b 100644 --- a/src/BizHawk.Client.Common/lua/LuaLibraryBase.cs +++ b/src/BizHawk.Client.Common/lua/LuaLibraryBase.cs @@ -25,7 +25,7 @@ namespace BizHawk.Client.Common public abstract string Name { get; } - public ApiContainer APIs { protected get; set; } + public ApiContainer APIs { get; set; } protected readonly Action LogOutputCallback; diff --git a/src/BizHawk.Client.Common/movie/MovieSession.cs b/src/BizHawk.Client.Common/movie/MovieSession.cs index 5ae91ff745..7292e11736 100644 --- a/src/BizHawk.Client.Common/movie/MovieSession.cs +++ b/src/BizHawk.Client.Common/movie/MovieSession.cs @@ -50,7 +50,7 @@ namespace BizHawk.Client.Common public IDictionary UserBag { get; set; } = new Dictionary(); - public IInputAdapter MovieIn { private get; set; } + public IInputAdapter MovieIn { get; set; } public IInputAdapter MovieOut { get; } = new CopyControllerAdapter(); public IStickyAdapter StickySource { get; set; } diff --git a/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs b/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs index 2f7a4a45cb..7b375733fc 100644 --- a/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs +++ b/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs @@ -37,7 +37,7 @@ namespace BizHawk.Client.Common /// the movie for the purpose of recording, if active, /// or to simply pass through if inactive /// - IInputAdapter MovieIn { set; } + IInputAdapter MovieIn { get; set; } /// /// Represents the movie input in the input chain diff --git a/src/BizHawk.Client.Common/movie/interfaces/ITasMovie.cs b/src/BizHawk.Client.Common/movie/interfaces/ITasMovie.cs index 33bfb4da11..d538d1d11b 100644 --- a/src/BizHawk.Client.Common/movie/interfaces/ITasMovie.cs +++ b/src/BizHawk.Client.Common/movie/interfaces/ITasMovie.cs @@ -13,8 +13,8 @@ namespace BizHawk.Client.Common IMovieChangeLog ChangeLog { get; } IStateManager TasStateManager { get; } - Func ClientSettingsForSave { set; } - Action GetClientSettingsOnLoad { set; } + Func ClientSettingsForSave { get; set; } + Action GetClientSettingsOnLoad { get; set; } ITasMovieRecord this[int index] { get; } ITasSession TasSession { get; } TasMovieMarkerList Markers { get; } diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs index dc188e626d..51ebb632b8 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs @@ -34,6 +34,7 @@ /// public int UnscaledWidth { + get => UIHelper.UnscaleX(Width); set => Width = UIHelper.ScaleX(value); } } diff --git a/src/BizHawk.Client.EmuHawk/IMainFormForTools.cs b/src/BizHawk.Client.EmuHawk/IMainFormForTools.cs index dd42faad08..3a6ee50dfd 100644 --- a/src/BizHawk.Client.EmuHawk/IMainFormForTools.cs +++ b/src/BizHawk.Client.EmuHawk/IMainFormForTools.cs @@ -25,7 +25,7 @@ namespace BizHawk.Client.EmuHawk bool GameIsClosing { get; } /// only referenced from - bool HoldFrameAdvance { set; } + bool HoldFrameAdvance { get; set; } /// only referenced from bool InvisibleEmulation { get; set; } @@ -39,7 +39,7 @@ namespace BizHawk.Client.EmuHawk int? PauseOnFrame { get; set; } /// only referenced from - bool PressRewind { set; } + bool PressRewind { get; set; } /// only referenced from IQuickBmpFile QuickBmpFile { get; } diff --git a/src/BizHawk.Client.EmuHawk/UIHelper.cs b/src/BizHawk.Client.EmuHawk/UIHelper.cs index c2e8f45f0d..72e851b3fd 100644 --- a/src/BizHawk.Client.EmuHawk/UIHelper.cs +++ b/src/BizHawk.Client.EmuHawk/UIHelper.cs @@ -43,5 +43,8 @@ namespace BizHawk.Client.EmuHawk using var form = new Form { AutoScaleMode = autoScaleMode }; return form.CurrentAutoScaleDimensions; } + + public static int UnscaleX(int size) + => (int) Math.Round(size / AutoScaleFactorX); } } diff --git a/src/BizHawk.Client.EmuHawk/config/GB/GBPrefControl.cs b/src/BizHawk.Client.EmuHawk/config/GB/GBPrefControl.cs index cfafd88dff..206a86aba9 100644 --- a/src/BizHawk.Client.EmuHawk/config/GB/GBPrefControl.cs +++ b/src/BizHawk.Client.EmuHawk/config/GB/GBPrefControl.cs @@ -24,7 +24,7 @@ namespace BizHawk.Client.EmuHawk /// TODO UserControls can be IDialogParents too, the modal should still be tied to the parent if used that way [Browsable(false)] - public IDialogParent DialogParent { private get; set; } + public IDialogParent DialogParent { get; set; } [Browsable(false)] public bool SyncSettingsChanged { get; private set; } diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaPictureBox.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaPictureBox.cs index fb9eab4400..2148c44e0e 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaPictureBox.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaPictureBox.cs @@ -17,7 +17,7 @@ namespace BizHawk.Client.EmuHawk private readonly Dictionary _solidBrushes = new Dictionary(); private readonly Dictionary _pens = new Dictionary(); - internal NLuaTableHelper TableHelper { private get; set; } + internal NLuaTableHelper TableHelper { get; set; } private SolidBrush GetBrush([LuaColorParam] object color) { diff --git a/src/BizHawk.Client.EmuHawk/tools/ToolFormBase.cs b/src/BizHawk.Client.EmuHawk/tools/ToolFormBase.cs index 0f1ae3c230..db86533938 100644 --- a/src/BizHawk.Client.EmuHawk/tools/ToolFormBase.cs +++ b/src/BizHawk.Client.EmuHawk/tools/ToolFormBase.cs @@ -11,17 +11,17 @@ namespace BizHawk.Client.EmuHawk { public class ToolFormBase : FormBase, IToolForm, IDialogParent { - public ToolManager Tools { protected get; set; } + public ToolManager Tools { get; set; } - public DisplayManager DisplayManager { protected get; set; } + public DisplayManager DisplayManager { get; set; } - public InputManager InputManager { protected get; set; } + public InputManager InputManager { get; set; } - public IMainFormForTools MainForm { protected get; set; } + public IMainFormForTools MainForm { get; set; } - public IMovieSession MovieSession { protected get; set; } + public IMovieSession MovieSession { get; set; } - public IGameInfo Game { protected get; set; } + public IGameInfo Game { get; set; } public IDialogController DialogController => MainForm; diff --git a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogStickPanel.cs b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogStickPanel.cs index 1203902293..8b365c2b40 100644 --- a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogStickPanel.cs +++ b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogStickPanel.cs @@ -41,7 +41,7 @@ namespace BizHawk.Client.EmuHawk public bool HasValue { get; set; } [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool ReadOnly { private get; set; } + public bool ReadOnly { get; set; } public string XName { get; private set; } = string.Empty; public string YName { get; private set; } = string.Empty; @@ -140,7 +140,7 @@ namespace BizHawk.Client.EmuHawk private readonly Bitmap _grayDot = new Bitmap(7, 7); [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public Action ClearCallback { private get; set; } + public Action ClearCallback { get; set; } public AnalogStickPanel() { diff --git a/src/BizHawk.Emulation.Cores/Calculators/TI83/TI83.cs b/src/BizHawk.Emulation.Cores/Calculators/TI83/TI83.cs index f06bdfd0c9..8b3a5fac22 100644 --- a/src/BizHawk.Emulation.Cores/Calculators/TI83/TI83.cs +++ b/src/BizHawk.Emulation.Cores/Calculators/TI83/TI83.cs @@ -72,8 +72,8 @@ namespace BizHawk.Emulation.Cores.Calculators.TI83 private int _linkOutput; internal int LinkOutput => _linkOutput; - internal bool LinkActive { private get; set; } - internal int LinkInput { private get; set; } + internal bool LinkActive { get; set; } + internal int LinkInput { get; set; } internal int LinkState => (_linkOutput | LinkInput) ^ 3;