From deb1d65e8a4ce5450dabf4c5ef4f7edc21258de8 Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Tue, 3 Nov 2026 02:10:24 -0500 Subject: [PATCH] analyser updates and more warning fixes --- .editorconfig | 6 ++++++ Directory.Build.props | 12 +++++++----- MiraAPI/Events/Vanilla/Meeting/EndMeetingEvent.cs | 1 + MiraAPI/GameModes/HideAndSeekMode.cs | 2 +- MiraAPI/GameOptions/ISummarizedOptions.cs | 1 + MiraAPI/GameOptions/MiraNumberOptionComponent.cs | 1 + MiraAPI/GameOptions/OptionTypes/ModdedOption.cs | 5 ++++- MiraAPI/Hud/CustomPaginableMenu.cs | 2 +- MiraAPI/Hud/CustomPhoneMenu.cs | 1 + MiraAPI/Hud/MultiTargetButton.cs | 2 +- MiraAPI/LocalSettings/LocalSettingsButton.cs | 2 ++ MiraAPI/LocalSettings/LocalSettingsTab.cs | 1 + .../LocalSettings/SettingTypes/LocalEnumSetting.cs | 2 +- .../LocalSettings/SettingTypes/LocalNumberSetting.cs | 2 +- .../LocalSettings/SettingTypes/LocalSliderSetting.cs | 2 +- MiraAPI/MiraApiSettings.cs | 1 + MiraAPI/Modifiers/ModifierComponent.cs | 1 + .../ModifierDisplay/ModifierDisplayComponent.cs | 1 + .../Modifiers/ModifierDisplay/ModifierUiComponent.cs | 1 + MiraAPI/Networking/Modifiers/AddModifierRpc.cs | 4 ++-- MiraAPI/Networking/SyncOptionsRpc.cs | 4 ++-- MiraAPI/Networking/SyncRoleOptionsRpc.cs | 4 ++-- MiraAPI/Patches/RoleGuidePatches.cs | 2 +- MiraAPI/Patches/Roles/SelectRolesPatch.cs | 2 +- MiraAPI/Patches/Voting/MeetingHudPatches.cs | 2 +- .../Utilities/Assets/LoadableAddressableAssets.cs | 1 + MiraAPI/Utilities/Components/LoadingRing.cs | 1 + MiraAPI/Utilities/GuideOptionsPatches.cs | 4 ++-- MiraAPI/Utilities/Helpers.cs | 6 +++--- MiraAPI/Voting/PlayerVoteData.cs | 1 + MiraAPI/Voting/VotingUtils.cs | 2 +- 31 files changed, 52 insertions(+), 27 deletions(-) diff --git a/.editorconfig b/.editorconfig index 2847fc22..1f8ecc2c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -107,3 +107,9 @@ dotnet_diagnostic.S2325.severity = none # IDE0005: Using directive is unnecessary. dotnet_diagnostic.IDE0005.severity = warning + +# SA1114: Parameter list should follow declaration +dotnet_diagnostic.SA1114.severity = none + +# SA1143: Conditional expressions must be formatted consistently +dotnet_diagnostic.SA1143.severity = none diff --git a/Directory.Build.props b/Directory.Build.props index 8e2a2e36..ef895f88 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,6 +5,8 @@ embedded enable true + false + $(MSBuildProjectDirectory)=. true @@ -32,11 +34,11 @@ - - - - - + + + + + diff --git a/MiraAPI/Events/Vanilla/Meeting/EndMeetingEvent.cs b/MiraAPI/Events/Vanilla/Meeting/EndMeetingEvent.cs index 98ccaa17..da6642fc 100644 --- a/MiraAPI/Events/Vanilla/Meeting/EndMeetingEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/EndMeetingEvent.cs @@ -3,6 +3,7 @@ /// /// The event that is invoked when the meeting has ended. /// +/// The meeting hud of the meeting that invoked the event. public class EndMeetingEvent(MeetingHud meetingHud) : MiraEvent { /// diff --git a/MiraAPI/GameModes/HideAndSeekMode.cs b/MiraAPI/GameModes/HideAndSeekMode.cs index ec99ce93..71146fe6 100644 --- a/MiraAPI/GameModes/HideAndSeekMode.cs +++ b/MiraAPI/GameModes/HideAndSeekMode.cs @@ -94,7 +94,7 @@ public class HideAndSeekMode : AbstractGameMode AmongUsClient.Instance.GetAllClients(list); List list2 = [.. list.ToArray() .Where(c => c.Character != null && c.Character.Data != null && !c.Character.Data.Disconnected && - !c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data)]; + !c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data),]; foreach (var networkedPlayerInfo in GameData.Instance.AllPlayers) { diff --git a/MiraAPI/GameOptions/ISummarizedOptions.cs b/MiraAPI/GameOptions/ISummarizedOptions.cs index 7873902a..0ee63e17 100644 --- a/MiraAPI/GameOptions/ISummarizedOptions.cs +++ b/MiraAPI/GameOptions/ISummarizedOptions.cs @@ -17,5 +17,6 @@ public interface ISummarizedOptions /// Gets summary lines to insert when the first hidden option would have appeared. /// Lines should already be formatted as "Title: Value". /// + /// The summarisation of the hidden options. IEnumerable GetWikiOptionSummaryLines(); } diff --git a/MiraAPI/GameOptions/MiraNumberOptionComponent.cs b/MiraAPI/GameOptions/MiraNumberOptionComponent.cs index 8cfa4562..297982a4 100644 --- a/MiraAPI/GameOptions/MiraNumberOptionComponent.cs +++ b/MiraAPI/GameOptions/MiraNumberOptionComponent.cs @@ -9,6 +9,7 @@ namespace MiraAPI.GameOptions; /// /// Component added onto options generated via MiraAPI. This allows developers to hook patches onto options in general, without using a list. /// +/// The pointer to the C++ object. [RegisterInIl2Cpp] public class MiraNumberOptionComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr) { diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs b/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs index 88b73642..b8959420 100644 --- a/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs +++ b/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs @@ -47,7 +47,10 @@ public abstract class ModdedOption : IModdedOption /// public T Value { - get => Getter != null ? Getter(_value) : _value; + get + { + return Getter != null ? Getter(_value) : _value; + } protected set { if (Setter != null) diff --git a/MiraAPI/Hud/CustomPaginableMenu.cs b/MiraAPI/Hud/CustomPaginableMenu.cs index 14f573bd..0654c9d0 100644 --- a/MiraAPI/Hud/CustomPaginableMenu.cs +++ b/MiraAPI/Hud/CustomPaginableMenu.cs @@ -113,7 +113,7 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu e.SortKey.Equals(query, StringComparison.OrdinalIgnoreCase)) .ThenByDescending(e => e.SortKey.StartsWith(query, StringComparison.OrdinalIgnoreCase)) .ThenByDescending(e => e.SortKey.Contains(query, StringComparison.OrdinalIgnoreCase)) - .ThenBy(e => e.SortKey, StringComparer.OrdinalIgnoreCase)]; + .ThenBy(e => e.SortKey, StringComparer.OrdinalIgnoreCase),]; } private static int GetTotalPages(int itemCount) diff --git a/MiraAPI/Hud/CustomPhoneMenu.cs b/MiraAPI/Hud/CustomPhoneMenu.cs index 79f1f7cc..3b3c7c28 100644 --- a/MiraAPI/Hud/CustomPhoneMenu.cs +++ b/MiraAPI/Hud/CustomPhoneMenu.cs @@ -15,6 +15,7 @@ namespace MiraAPI.Hud; /// /// Component registered in Il2Cpp domain to handle Unity events for custom menus. /// +/// The pointer to the C++ object. [RegisterInIl2Cpp] public class CustomPhoneMenuComponent(IntPtr cppPtr) : Minigame(cppPtr) { diff --git a/MiraAPI/Hud/MultiTargetButton.cs b/MiraAPI/Hud/MultiTargetButton.cs index 9d44b4d7..83c28000 100644 --- a/MiraAPI/Hud/MultiTargetButton.cs +++ b/MiraAPI/Hud/MultiTargetButton.cs @@ -57,7 +57,7 @@ public abstract class MultiTargetButton : CustomActionButton Targets = [.. newTargets .Where(IsTargetValid) - .Take(MaxTargets)]; + .Take(MaxTargets),]; Targets.Do(t => SetOutline(t, true)); return base.CanUse() && Targets.Length > 0; diff --git a/MiraAPI/LocalSettings/LocalSettingsButton.cs b/MiraAPI/LocalSettings/LocalSettingsButton.cs index e35617f7..2443e0c1 100644 --- a/MiraAPI/LocalSettings/LocalSettingsButton.cs +++ b/MiraAPI/LocalSettings/LocalSettingsButton.cs @@ -12,6 +12,8 @@ namespace MiraAPI.LocalSettings; /// /// Represents a button. /// +/// The text on the button. +/// The event that is invoked when the button is clicked. public class LocalSettingsButton(string text, Action onClick) { /// diff --git a/MiraAPI/LocalSettings/LocalSettingsTab.cs b/MiraAPI/LocalSettings/LocalSettingsTab.cs index ebc5c030..e92f2cf4 100644 --- a/MiraAPI/LocalSettings/LocalSettingsTab.cs +++ b/MiraAPI/LocalSettings/LocalSettingsTab.cs @@ -16,6 +16,7 @@ namespace MiraAPI.LocalSettings; /// /// Represents a local settings tab. Gets a button by default. /// +/// The config file that this settings tab wraps around. public abstract class LocalSettingsTab(ConfigFile config) { /// diff --git a/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs b/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs index 7eeeeccf..91d2eeb1 100644 --- a/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs +++ b/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs @@ -39,7 +39,7 @@ public class LocalEnumSetting( public string[] Values { get; } = values ?? [.. Enum .GetValues(configEntry.SettingType) .Cast() - .Select(x => x.ToDisplayString())]; + .Select(x => x.ToDisplayString()),]; private SpriteRenderer _highlight; private TextMeshPro _btnText; diff --git a/MiraAPI/LocalSettings/SettingTypes/LocalNumberSetting.cs b/MiraAPI/LocalSettings/SettingTypes/LocalNumberSetting.cs index 83e96dc3..2398be55 100644 --- a/MiraAPI/LocalSettings/SettingTypes/LocalNumberSetting.cs +++ b/MiraAPI/LocalSettings/SettingTypes/LocalNumberSetting.cs @@ -15,9 +15,9 @@ namespace MiraAPI.LocalSettings.SettingTypes; /// /// The tab to create the setting in. /// The config entry. -/// The value range. /// The name of the setting. /// The description of the setting. +/// The value range. /// The increment per click. /// The suffix used for formatting. /// The format string used for formatting. diff --git a/MiraAPI/LocalSettings/SettingTypes/LocalSliderSetting.cs b/MiraAPI/LocalSettings/SettingTypes/LocalSliderSetting.cs index a84b95bc..14f1ffe9 100644 --- a/MiraAPI/LocalSettings/SettingTypes/LocalSliderSetting.cs +++ b/MiraAPI/LocalSettings/SettingTypes/LocalSliderSetting.cs @@ -18,10 +18,10 @@ namespace MiraAPI.LocalSettings.SettingTypes; /// The name of the setting. /// The description of the setting. /// The value range. +/// Should display the value next to the name. /// The suffix used for formatting. /// The format string used for formatting. /// Should the value be rounded. -/// Should display the value next to the name. public class LocalSliderSetting( Type tab, ConfigEntryBase configEntry, diff --git a/MiraAPI/MiraApiSettings.cs b/MiraAPI/MiraApiSettings.cs index 1afca88e..2240d0c1 100644 --- a/MiraAPI/MiraApiSettings.cs +++ b/MiraAPI/MiraApiSettings.cs @@ -15,6 +15,7 @@ namespace MiraAPI; /// /// Mira API Handler. /// +/// The config file that the tab wraps around. public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config) { /// diff --git a/MiraAPI/Modifiers/ModifierComponent.cs b/MiraAPI/Modifiers/ModifierComponent.cs index 99538929..9ebfc827 100644 --- a/MiraAPI/Modifiers/ModifierComponent.cs +++ b/MiraAPI/Modifiers/ModifierComponent.cs @@ -16,6 +16,7 @@ namespace MiraAPI.Modifiers; /// /// The component for handling s. /// +/// The pointer to the C++ object. [RegisterInIl2Cpp] [SuppressMessage("Style", "IDE0051:Remove unused private members", Justification = "Unity Convention.")] public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr) diff --git a/MiraAPI/Modifiers/ModifierDisplay/ModifierDisplayComponent.cs b/MiraAPI/Modifiers/ModifierDisplay/ModifierDisplayComponent.cs index 84defb8e..2760ddbb 100644 --- a/MiraAPI/Modifiers/ModifierDisplay/ModifierDisplayComponent.cs +++ b/MiraAPI/Modifiers/ModifierDisplay/ModifierDisplayComponent.cs @@ -19,6 +19,7 @@ namespace MiraAPI.Modifiers.ModifierDisplay; /// /// The code used to display s. /// +/// The pointer to the C++ object. [RegisterInIl2Cpp] [SuppressMessage("Style", "IDE0051:Remove unused private members", Justification = "Unity Convention.")] public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr) diff --git a/MiraAPI/Modifiers/ModifierDisplay/ModifierUiComponent.cs b/MiraAPI/Modifiers/ModifierDisplay/ModifierUiComponent.cs index cfe63198..3c66358b 100644 --- a/MiraAPI/Modifiers/ModifierDisplay/ModifierUiComponent.cs +++ b/MiraAPI/Modifiers/ModifierDisplay/ModifierUiComponent.cs @@ -9,6 +9,7 @@ namespace MiraAPI.Modifiers.ModifierDisplay; /// /// The code placed on every HUD object. Used to handle updating. /// +/// The pointer to the C++ object. [RegisterInIl2Cpp] [SuppressMessage("Style", "IDE0051:Remove unused private members", Justification = "Unity Convention.")] public class ModifierUiComponent(nint cppPtr) : MonoBehaviour(cppPtr) diff --git a/MiraAPI/Networking/Modifiers/AddModifierRpc.cs b/MiraAPI/Networking/Modifiers/AddModifierRpc.cs index 5b292821..905a8cc2 100644 --- a/MiraAPI/Networking/Modifiers/AddModifierRpc.cs +++ b/MiraAPI/Networking/Modifiers/AddModifierRpc.cs @@ -57,7 +57,7 @@ public class AddModifierRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc - public override void Handle(PlayerControl player, ModifierData data) + public override void Handle(PlayerControl innerNetObject, ModifierData data) { var type = ModifierManager.GetModifierType(data.TypeId) ?? throw new InvalidOperationException($"Modifier type not found for ID {data.TypeId}."); var modifier = data.Args.Length > 0 @@ -65,6 +65,6 @@ public class AddModifierRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc p.GetSortKey(_sortGrouping)) - : sorted.ThenByDescending(p => p.GetSortKey(_sortGrouping)) + : sorted.ThenByDescending(p => p.GetSortKey(_sortGrouping)), ]; } diff --git a/MiraAPI/Patches/Roles/SelectRolesPatch.cs b/MiraAPI/Patches/Roles/SelectRolesPatch.cs index 993454ab..204e1f9e 100644 --- a/MiraAPI/Patches/Roles/SelectRolesPatch.cs +++ b/MiraAPI/Patches/Roles/SelectRolesPatch.cs @@ -47,7 +47,7 @@ public static class SelectRolesPatch AmongUsClient.Instance.GetAllClients(list); List list2 = [.. list.ToArray() .Where(c => c.Character != null && c.Character.Data != null && !c.Character.Data.Disconnected && - !c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data)]; + !c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data),]; foreach (var networkedPlayerInfo in GameData.Instance.AllPlayers) { diff --git a/MiraAPI/Patches/Voting/MeetingHudPatches.cs b/MiraAPI/Patches/Voting/MeetingHudPatches.cs index 1239ac7c..d0f02fbb 100644 --- a/MiraAPI/Patches/Voting/MeetingHudPatches.cs +++ b/MiraAPI/Patches/Voting/MeetingHudPatches.cs @@ -260,7 +260,7 @@ internal static class MeetingHudPatches { VoterId = v.Voter, VotedForId = v.Suspect, - }) + }), ]); __instance.RpcVotingComplete(voterStates, exiled, isTie, @event.OverruledVote, @event.OverruledNonce); diff --git a/MiraAPI/Utilities/Assets/LoadableAddressableAssets.cs b/MiraAPI/Utilities/Assets/LoadableAddressableAssets.cs index 9e131bf8..ab20265c 100644 --- a/MiraAPI/Utilities/Assets/LoadableAddressableAssets.cs +++ b/MiraAPI/Utilities/Assets/LoadableAddressableAssets.cs @@ -10,6 +10,7 @@ namespace MiraAPI.Utilities.Assets; /// A utility class for loading groups of assets from ALL addressable locations. /// /// The type of the asset to be loaded. +/// The asset key. public class LoadableAddressableAssets(string key) where T : UnityEngine.Object { diff --git a/MiraAPI/Utilities/Components/LoadingRing.cs b/MiraAPI/Utilities/Components/LoadingRing.cs index f871f59b..b0ba1285 100644 --- a/MiraAPI/Utilities/Components/LoadingRing.cs +++ b/MiraAPI/Utilities/Components/LoadingRing.cs @@ -7,6 +7,7 @@ namespace MiraAPI.Utilities.Components; /// /// A spinning ring used to indicate that content is loading. /// +/// The pointer to the C++ object. [RegisterInIl2Cpp] public class LoadingRing(IntPtr cppPtr) : MonoBehaviour(cppPtr) { diff --git a/MiraAPI/Utilities/GuideOptionsPatches.cs b/MiraAPI/Utilities/GuideOptionsPatches.cs index a86472ac..4d4b046d 100644 --- a/MiraAPI/Utilities/GuideOptionsPatches.cs +++ b/MiraAPI/Utilities/GuideOptionsPatches.cs @@ -147,7 +147,7 @@ internal static class GuideOptionPages .ThenBy(page => page.GroupPriority) .ThenBy(page => page.Order) .ThenBy(page => page.Group.GroupName, StringComparer.OrdinalIgnoreCase) - .ThenBy(page => page.ModAbbreviation, StringComparer.OrdinalIgnoreCase)]; + .ThenBy(page => page.ModAbbreviation, StringComparer.OrdinalIgnoreCase),]; } private static int GetMenuOrder(MenuCategory menu) @@ -189,7 +189,7 @@ internal static class GuideOptionPages .Select(entry => (Entry: entry, Rank: Rank(entry, query, cmp))) .Where(result => result.Rank < int.MaxValue) .OrderBy(result => result.Rank) - .Select(result => result.Entry))]; + .Select(result => result.Entry)),]; } private static string[] GetModSearchTerms(MiraPluginInfo plugin, AbstractOptionGroup group) diff --git a/MiraAPI/Utilities/Helpers.cs b/MiraAPI/Utilities/Helpers.cs index 94fea9f2..fe3b5020 100644 --- a/MiraAPI/Utilities/Helpers.cs +++ b/MiraAPI/Utilities/Helpers.cs @@ -428,7 +428,7 @@ public static class Helpers [ .. results.ToArray() .Where(collider2D => collider2D.CompareTag("DeadBody")) - .Select(collider2D => collider2D.GetComponent()) + .Select(collider2D => collider2D.GetComponent()), ]; } @@ -450,7 +450,7 @@ public static class Helpers [ .. results.ToArray() .Where(collider2D => colliderTag == null || collider2D.CompareTag(colliderTag)) - .Select(collider2D => collider2D.GetComponent()) + .Select(collider2D => collider2D.GetComponent()), ]; } @@ -480,7 +480,7 @@ public static class Helpers vector.normalized, magnitude, Constants.ShipAndObjectsMask) - select player + select player, ]; } diff --git a/MiraAPI/Voting/PlayerVoteData.cs b/MiraAPI/Voting/PlayerVoteData.cs index 45ab8b7d..5fe32ee7 100644 --- a/MiraAPI/Voting/PlayerVoteData.cs +++ b/MiraAPI/Voting/PlayerVoteData.cs @@ -10,6 +10,7 @@ namespace MiraAPI.Voting; /// /// Handles player votes, and removing/adding additional votes. /// +/// The pointer to the C++ object. [RegisterInIl2Cpp] public class PlayerVoteData(nint cppPtr) : MonoBehaviour(cppPtr) { diff --git a/MiraAPI/Voting/VotingUtils.cs b/MiraAPI/Voting/VotingUtils.cs index ad9e32ce..ec62225c 100644 --- a/MiraAPI/Voting/VotingUtils.cs +++ b/MiraAPI/Voting/VotingUtils.cs @@ -279,7 +279,7 @@ public static class VotingUtils return [ .. Helpers.GetAlivePlayers() - .SelectMany(player => player.GetVoteData().Votes) + .SelectMany(player => player.GetVoteData().Votes), ]; }