From 67edf3f047d1b919d773c6acf9beeb2019f4b2db Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Wed, 3 Jul 2024 23:10:19 +1000 Subject: [PATCH] Enable MA0070 and fix noncompliance "Obsolete attributes should include explanations" --- .global.editorconfig.ini | 2 +- src/BizHawk.Client.Common/Api/Interfaces/IInputApi.cs | 2 +- src/BizHawk.Client.Common/lua/CommonLibs/InputLuaLibrary.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.global.editorconfig.ini b/.global.editorconfig.ini index 7ce3194c50..dd63746838 100644 --- a/.global.editorconfig.ini +++ b/.global.editorconfig.ini @@ -239,7 +239,7 @@ dotnet_diagnostic.MA0068.severity = error # Non-constant static fields should not be visible dotnet_diagnostic.MA0069.severity = silent # Obsolete attributes should include explanations -dotnet_diagnostic.MA0070.severity = silent +dotnet_diagnostic.MA0070.severity = warning # Avoid using redundant else dotnet_diagnostic.MA0071.severity = silent # Do not throw from a finally block diff --git a/src/BizHawk.Client.Common/Api/Interfaces/IInputApi.cs b/src/BizHawk.Client.Common/Api/Interfaces/IInputApi.cs index d30d5f8faf..442bfa8f4f 100644 --- a/src/BizHawk.Client.Common/Api/Interfaces/IInputApi.cs +++ b/src/BizHawk.Client.Common/Api/Interfaces/IInputApi.cs @@ -17,7 +17,7 @@ namespace BizHawk.Client.Common /// See for keyboard key names, though some are overridden by (check the source). /// /// - [Obsolete] + [Obsolete($"consider using {nameof(GetPressedButtons)}/{nameof(GetPressedAxes)}/{nameof(GetMouse)}")] Dictionary Get(); /// diff --git a/src/BizHawk.Client.Common/lua/CommonLibs/InputLuaLibrary.cs b/src/BizHawk.Client.Common/lua/CommonLibs/InputLuaLibrary.cs index 933b71bfd6..b6d016f66f 100644 --- a/src/BizHawk.Client.Common/lua/CommonLibs/InputLuaLibrary.cs +++ b/src/BizHawk.Client.Common/lua/CommonLibs/InputLuaLibrary.cs @@ -9,12 +9,12 @@ namespace BizHawk.Client.Common public override string Name => "input"; -#pragma warning disable CS0612 [LuaMethodExample("local buttons_down = input.get();\nlocal is_b_down = buttons_down[\"B\"];\nif is_b_down and not was_b_down then console.writeline(\"B pressed\"); end\nwas_b_down = is_b_down;")] [LuaMethod("get", "Returns a dict-like table of key/button names (of host). Only pressed buttons will appear (with a value of {{true}}); unpressed buttons are omitted. Includes gamepad axes ({{!axis.isNeutral}}, with sticks as 4 \"buttons\" suffixed {{\"Up\"}}/{{\"Down\"}}/{{\"Left\"}}/{{\"Right\"}}). Includes mouse buttons, but not axes (cursor position and wheel rotation). Unlike {{getmouse}}, these have the names {{\"WMouse L\"}}, {{\"WMouse R\"}}, {{\"WMouse C\"}}, {{\"WMouse 1\"}}, and {{\"WMouse 2\"}} for LMB, RMB, MMB, Mouse4, and Mouse5, respectively.")] public LuaTable Get() +#pragma warning disable CS0618 // the ApiHawk equivalent of this function is warn-level deprecated; Lua can't and shouldn't make that distinction => _th.DictToTable(APIs.Input.Get()); -#pragma warning restore CS0612 +#pragma warning restore CS0618 [LuaMethodExample("local mouse_buttons_down = input.getmouse();\nlocal is_m3_down = mouse_buttons_down[\"Middle\"];\nif is_m3_down and not was_m3_down then console.writeline(\"M3 pressed\"); end\nwas_m3_down = is_m3_down;")] [LuaMethod("getmouse", "Returns a lua table of the mouse X/Y coordinates and button states. Table keys are X, Y, Left, Middle, Right, XButton1, XButton2, Wheel.")]