diff --git a/PKHeX.Core/Editing/Saves/Slots/Extensions.cs b/PKHeX.Core/Editing/Saves/Slots/Extensions.cs index bde4bbb31..d1206cac3 100644 --- a/PKHeX.Core/Editing/Saves/Slots/Extensions.cs +++ b/PKHeX.Core/Editing/Saves/Slots/Extensions.cs @@ -22,7 +22,6 @@ namespace PKHeX.Core public static PKM[] GetExtraPKM(this SaveFile sav, IList slots) { - slots ??= sav.GetExtraSlots(); var arr = new PKM[slots.Count]; for (int i = 0; i < slots.Count; i++) arr[i] = slots[i].Read(sav); diff --git a/PKHeX.Core/Game/GameStrings/GeoLocation.cs b/PKHeX.Core/Game/GameStrings/GeoLocation.cs index 485ce46a6..858ba79f8 100644 --- a/PKHeX.Core/Game/GameStrings/GeoLocation.cs +++ b/PKHeX.Core/Game/GameStrings/GeoLocation.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core { private static readonly string[][] CountryList = GetCountryList(); private static readonly string[] lang_geo = { "ja", "en", "fr", "de", "it", "es", "zh", "ko" }; - private static readonly string[][][] RegionList = new string[CountryList.Length][][]; + private static readonly string[][]?[] RegionList = new string[CountryList.Length][][]; private const string INVALID = nameof(INVALID); diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs index 3cf2bb38b..6497dfafe 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs @@ -64,7 +64,7 @@ namespace PKHeX.Core #region Dream Radar Tables - private static readonly EncounterStatic5DR[] Encounter_DreamRadar = + private static readonly EncounterStatic5[] Encounter_DreamRadar = { new EncounterStatic5DR(120, 0), // Staryu new EncounterStatic5DR(137, 0), // Porygon diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters8.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters8.cs index 1373dc406..b1ff55237 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters8.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters8.cs @@ -602,7 +602,7 @@ namespace PKHeX.Core internal static readonly EncounterTrade[] TradeGift_SWSH = TradeGift_Regular.Concat(TradeGift_R1).ToArray(); - internal static readonly EncounterStatic[] StaticSW = ArrayUtil.ConcatAll(Nest_Common, Nest_SW, Nest_SH, Dist_Common, Dist_SW, Dist_SH, GetEncounters(Crystal_SWSH, SW), GetEncounters(Encounter_SWSH, SW)); - internal static readonly EncounterStatic[] StaticSH = ArrayUtil.ConcatAll(Nest_Common, Nest_SW, Nest_SH, Dist_Common, Dist_SW, Dist_SH, GetEncounters(Crystal_SWSH, SH), GetEncounters(Encounter_SWSH, SH)); + internal static readonly EncounterStatic[] StaticSW = ArrayUtil.ConcatAll(Nest_Common, Nest_SW, Nest_SH, Dist_Common, Dist_SW, Dist_SH, GetEncounters(Crystal_SWSH, SW), GetEncounters(Encounter_SWSH, SW)); + internal static readonly EncounterStatic[] StaticSH = ArrayUtil.ConcatAll(Nest_Common, Nest_SW, Nest_SH, Dist_Common, Dist_SW, Dist_SH, GetEncounters(Crystal_SWSH, SH), GetEncounters(Encounter_SWSH, SH)); } } diff --git a/PKHeX.Core/Legality/Encounters/Generator/PeekEnumerator.cs b/PKHeX.Core/Legality/Encounters/Generator/PeekEnumerator.cs index 4085025c0..fd2ada9d3 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/PeekEnumerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/PeekEnumerator.cs @@ -38,7 +38,7 @@ namespace PKHeX.Core didPeek = false; } - object? IEnumerator.Current => Current; + object IEnumerator.Current => Current; public void Dispose() => Enumerator.Dispose(); public T Current => didPeek ? peek! : Enumerator.Current; diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs index fdd640a9e..dc4fd71cf 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs @@ -292,6 +292,7 @@ namespace PKHeX.Core for (int m = 0; m < 4; m++) { + // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (res[m] == null) res[m] = new CheckMoveResult(Unknown, info.Generation, Invalid, LMoveSourceInvalid, Move); } @@ -714,8 +715,8 @@ namespace PKHeX.Core } private static bool IsDefogWhirl(int move) => move == 250 || move == 432; - private static bool IsCheckInvalid(CheckResult chk) => !(chk?.Valid ?? false); - private static bool IsCheckValid(CheckResult chk) => chk?.Valid ?? false; + private static bool IsCheckInvalid(CheckResult? chk) => !(chk?.Valid ?? false); + private static bool IsCheckValid(CheckResult? chk) => chk?.Valid ?? false; private static void FlagIncompatibleTransferHMs45(CheckMoveResult[] res, IReadOnlyList currentMoves, int gen, IReadOnlyList HMLearned, bool KnowDefogWhirlpool) { diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyRelearnMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyRelearnMoves.cs index 10fa087dd..3bed8c833 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyRelearnMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyRelearnMoves.cs @@ -172,6 +172,7 @@ namespace PKHeX.Core var other = x.OtherSpecies; for (int i = required; i < 4; i++) { + // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (res[i] != null) continue; diff --git a/PKHeX.Core/Legality/RNG/Frame/SlotRange.cs b/PKHeX.Core/Legality/RNG/Frame/SlotRange.cs index 2d4fc11f8..3934fd34e 100644 --- a/PKHeX.Core/Legality/RNG/Frame/SlotRange.cs +++ b/PKHeX.Core/Legality/RNG/Frame/SlotRange.cs @@ -158,7 +158,7 @@ namespace PKHeX.Core { if (proc < 50) return true; - if (proc < 75 && lead == LeadRequired.None) + if (proc < 75) return lead == LeadRequired.None; } else if (stype == SlotType.Super_Rod) diff --git a/PKHeX.Core/MysteryGifts/MysteryGift.cs b/PKHeX.Core/MysteryGifts/MysteryGift.cs index 21d77bfb2..e14dc269d 100644 --- a/PKHeX.Core/MysteryGifts/MysteryGift.cs +++ b/PKHeX.Core/MysteryGifts/MysteryGift.cs @@ -62,9 +62,6 @@ namespace PKHeX.Core /// This overload differs from by checking the / combo for validity. If either is invalid, a null reference is returned. public static DataMysteryGift? GetMysteryGift(byte[] data, string ext) { - if (ext == null) - return GetMysteryGift(data); - switch (data.Length) { case WC8.Size when ext == ".wc8": diff --git a/PKHeX.Core/PKM/Searching/SearchSettings.cs b/PKHeX.Core/PKM/Searching/SearchSettings.cs index 069718172..40feb5014 100644 --- a/PKHeX.Core/PKM/Searching/SearchSettings.cs +++ b/PKHeX.Core/PKM/Searching/SearchSettings.cs @@ -120,7 +120,7 @@ namespace PKHeX.Core.Searching if (SearchLegal != null) res = res.Where(pk => new LegalityAnalysis(pk).Valid == SearchLegal); - if (BatchInstructions != null) + if (BatchInstructions.Count != 0) res = SearchUtil.FilterByBatchInstruction(res, BatchInstructions); return res; diff --git a/PKHeX.Core/PKM/Util/PKMConverter.cs b/PKHeX.Core/PKM/Util/PKMConverter.cs index 38cee294a..869ae60fc 100644 --- a/PKHeX.Core/PKM/Util/PKMConverter.cs +++ b/PKHeX.Core/PKM/Util/PKMConverter.cs @@ -261,7 +261,7 @@ namespace PKHeX.Core var pkm = ConvertPKM(pk, destType, destGeneration, ref comment); var msg = pkm == null ? MsgPKMConvertFailFormat : MsgPKMConvertSuccess; var formatted = string.Format(msg, srcName, destName); - comment = comment == null ? formatted : string.Concat(formatted, Environment.NewLine, comment); + comment = comment.Length != 0 ? formatted : string.Concat(formatted, Environment.NewLine, comment); return pkm; } diff --git a/PKHeX.Core/Saves/Util/SaveFinder.cs b/PKHeX.Core/Saves/Util/SaveFinder.cs index da5bbc415..1942e7eb3 100644 --- a/PKHeX.Core/Saves/Util/SaveFinder.cs +++ b/PKHeX.Core/Saves/Util/SaveFinder.cs @@ -154,8 +154,7 @@ namespace PKHeX.Core possible = msg; return false; } - if (files != null) - possiblePaths.AddRange(files); + possiblePaths.AddRange(files); } possible = possiblePaths; return true; diff --git a/PKHeX.Core/Saves/Util/SaveUtil.cs b/PKHeX.Core/Saves/Util/SaveUtil.cs index 2fa37adfb..e14b376ac 100644 --- a/PKHeX.Core/Saves/Util/SaveUtil.cs +++ b/PKHeX.Core/Saves/Util/SaveUtil.cs @@ -678,7 +678,7 @@ namespace PKHeX.Core { if (!Directory.Exists(folderPath)) { - result = Enumerable.Empty(); + result = Array.Empty(); return false; } try diff --git a/PKHeX.Core/Util/ReflectUtil.cs b/PKHeX.Core/Util/ReflectUtil.cs index 472563df4..601c3e6a6 100644 --- a/PKHeX.Core/Util/ReflectUtil.cs +++ b/PKHeX.Core/Util/ReflectUtil.cs @@ -125,14 +125,14 @@ namespace PKHeX.Core return GetAllTypeInfo(typeInfo).SelectMany(_ => accessor(typeInfo)); } - public static Dictionary GetAllConstantsOfType(this Type type) + public static Dictionary GetAllConstantsOfType(this Type type) where T : struct { var fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy); var consts = fields.Where(fi => fi.IsLiteral && !fi.IsInitOnly && fi.FieldType == typeof(T)); return consts.ToDictionary(x => (T)x.GetRawConstantValue(), z => z.Name); } - public static Dictionary GetAllPropertiesOfType(this Type type, object obj) + public static Dictionary GetAllPropertiesOfType(this Type type, object obj) where T : class { var props = type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly); var ofType = props.Where(fi => typeof(T).IsAssignableFrom(fi.PropertyType)); diff --git a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs index a2eab7f33..a799ab906 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs @@ -258,7 +258,7 @@ namespace PKHeX.WinForms if (mem == 0) { string nn = pkm.Nickname; - result = string.Format(GameInfo.Strings.memories[mem + 38], nn); + result = string.Format(GameInfo.Strings.memories[38], nn); enabled = false; } else