Fix Some Missed Conversions To Collection Expressions (#4096)

This commit is contained in:
Jonathan Herbert 2023-12-17 20:38:53 -04:00 committed by GitHub
parent 59e409bbd7
commit 07cd05d1c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 32 additions and 34 deletions

View file

@ -140,18 +140,18 @@ public static partial class Extensions
};
if (sav is SAV7USUM uu)
{
list.AddRange(new[]
{
list.AddRange(
[
new SlotInfoMisc(uu.Data, 1, uu.GetFusedSlotOffset(1)) {Type = StorageSlotType.Fused},
new SlotInfoMisc(uu.Data, 2, uu.GetFusedSlotOffset(2)) {Type = StorageSlotType.Fused},
});
]);
var ba = uu.BattleAgency;
list.AddRange(new[]
{
list.AddRange(
[
new SlotInfoMisc(uu.Data, 0, ba.GetSlotOffset(0)) {Type = StorageSlotType.Misc},
new SlotInfoMisc(uu.Data, 1, ba.GetSlotOffset(1)) {Type = StorageSlotType.Misc},
new SlotInfoMisc(uu.Data, 2, ba.GetSlotOffset(2)) {Type = StorageSlotType.Misc},
});
]);
}
if (!all)

View file

@ -10,8 +10,8 @@ public static class GameInfo
private static readonly GameStrings?[] Languages = new GameStrings[GameLanguage.LanguageCount];
public static string CurrentLanguage { get; set; } = GameLanguage.DefaultLanguage;
public static readonly IReadOnlyList<string> GenderSymbolUnicode = new[] {"♂", "♀", "-"};
public static readonly IReadOnlyList<string> GenderSymbolASCII = new[] {"M", "F", "-"};
public static readonly IReadOnlyList<string> GenderSymbolUnicode = ["♂", "♀", "-"];
public static readonly IReadOnlyList<string> GenderSymbolASCII = ["M", "F", "-"];
private static GameStrings _strings = GetStrings(CurrentLanguage);
public static GameStrings GetStrings(string lang)

View file

@ -18,7 +18,7 @@ public sealed class MemoryStrings
{
s = strings;
memories = new Lazy<List<ComboItem>>(GetMemories);
none = new Lazy<List<ComboItem>>(() => Util.GetCBList(new[] {string.Empty}));
none = new Lazy<List<ComboItem>>(() => Util.GetCBList([string.Empty]));
species = new Lazy<List<ComboItem>>(() => Util.GetCBList(s.specieslist));
item6 = new Lazy<List<ComboItem>>(() => GetItems(EntityContext.Gen6));
item8 = new Lazy<List<ComboItem>>(() => GetItems(EntityContext.Gen8));

View file

@ -237,7 +237,7 @@ public static class GameUtil
{
var max = obj.MaxGameID;
if (max == Legal.MaxGameID_7b) // edge case
return new[] {GO, GP, GE};
return [GO, GP, GE];
var versions = GameVersions
.Where(version => (GameVersion)obj.MinGameID <= version && version <= (GameVersion)max);
if (generation < 0)

View file

@ -18,7 +18,7 @@ public readonly ref struct BinLinkerAccessor
public int Length => ReadUInt16LittleEndian(Data[2..]);
/// <summary> Magic identifier for the file. </summary>
public string Identifier => new(new[] {(char)Data[0], (char)Data[1]});
public string Identifier => new([(char)Data[0], (char)Data[1]]);
/// <summary>
/// Retrieves a view of the entry at the requested <see cref="index"/>.

View file

@ -46,7 +46,7 @@ public static class MysteryUtil
public static IEnumerable<string> GetDescription(this MysteryGift gift, IBasicStrings strings)
{
if (gift.Empty)
return new[] { MsgMysteryGiftSlotEmpty };
return [MsgMysteryGiftSlotEmpty];
var result = new List<string> { gift.CardHeader };
if (gift.IsItem)

View file

@ -209,7 +209,7 @@ public sealed class SearchSettings
public IReadOnlyList<GameVersion> GetVersions(SaveFile sav, GameVersion fallback)
{
if (Version > 0)
return new[] {(GameVersion) Version};
return [(GameVersion) Version];
return Generation switch
{

View file

@ -13,8 +13,8 @@ public static class SpeciesName
/// <summary>
/// Species name lists indexed by the <see cref="LanguageID"/> value.
/// </summary>
private static readonly IReadOnlyList<IReadOnlyList<string>> SpeciesLang = new[]
{
private static readonly IReadOnlyList<IReadOnlyList<string>> SpeciesLang =
[
Util.GetSpeciesList("ja"), // 0 (unused, invalid)
Util.GetSpeciesList("ja"), // 1
Util.GetSpeciesList("en"), // 2
@ -26,7 +26,7 @@ public static class SpeciesName
Util.GetSpeciesList("ko"), // 8
Util.GetSpeciesList("zh"), // 9 Simplified
Util.GetSpeciesList("zh2"), // 10 Traditional
};
];
/// <summary>
/// Gets the maximum valid species ID stored in the <see cref="SpeciesLang"/> list.

View file

@ -915,7 +915,7 @@ public partial class Main : Form
string fr = GameInfo.GetVersionName(GameVersion.FR);
string lg = GameInfo.GetVersionName(GameVersion.LG);
string dual = "{1}/{2} " + MsgFileLoadVersionDetect;
var g = new[] { GameVersion.FR, GameVersion.LG };
GameVersion[] g = [GameVersion.FR, GameVersion.LG];
var games = g.Select(z => GameInfo.VersionDataSource.First(v => v.Value == (int)z));
var msg = string.Format(dual, "3", fr, lg);
using var dialog = new SAV_GameSelect(games, msg, MsgFileLoadSaveSelectVersion);

View file

@ -250,7 +250,7 @@ public partial class SAV_Encounters : Form
var moves = settings.Moves.ToArray();
var versions = settings.GetVersions(SAV);
var species = settings.Species == 0 ? GetFullRange(SAV.MaxSpeciesID) : new[] { settings.Species };
var species = settings.Species == 0 ? GetFullRange(SAV.MaxSpeciesID) : [settings.Species];
var results = GetAllSpeciesFormEncounters(species, SAV.Personal, versions, moves, pk, token);
if (settings.SearchEgg != null)
results = results.Where(z => z.EggEncounter == settings.SearchEgg);

View file

@ -329,7 +329,7 @@ public partial class SAV_Misc5 : Form
LB_FunfestMissions.Items.AddRange(FMTitles);
CB_FMLevel.Items.Clear();
CB_FMLevel.Items.AddRange(new[] { "Lv.1", "Lv.2 +", "Lv.3 ++", "Lv.3 +++" });
CB_FMLevel.Items.AddRange(["Lv.1", "Lv.2 +", "Lv.3 ++", "Lv.3 +++"]);
SetNudMax();
SetEntreeExpTooltip();
LB_FunfestMissions.SelectedIndex = 0;
@ -809,7 +809,7 @@ public partial class SAV_Misc5 : Form
if (SAV is SAV5B2W2)
{
CB_CurrentMedal.Items.AddRange(MedalNames);
CB_MedalState.Items.AddRange(new[] { "Unobtained", "Can Obtain Hint Medal", "Hint Medal Obtained", "Can Obtain Medal", "Medal Obtained" });
CB_MedalState.Items.AddRange(["Unobtained", "Can Obtain Hint Medal", "Hint Medal Obtained", "Can Obtain Medal", "Medal Obtained"]);
CB_CurrentMedal.SelectedIndex = 0;
}
}
@ -906,4 +906,4 @@ public partial class SAV_Misc5 : Form
SAV.Musical.UnlockAllMusicalProps();
System.Media.SystemSounds.Asterisk.Play();
}
}
}

View file

@ -20,10 +20,8 @@ public partial class SAV_Roamer6 : Form
roamer = SAV.Encount.Roamer;
var species = GameInfo.Strings.specieslist;
var entries = new[] { species[(int)Species.Articuno], species[(int)Species.Zapdos], species[(int)Species.Moltres] };
var states = new[] { "Inactive", "Roaming", "Stationary", "Defeated", "Captured" };
CB_Species.Items.AddRange(entries);
CB_RoamState.Items.AddRange(states);
CB_Species.Items.AddRange([species[(int)Species.Articuno], species[(int)Species.Zapdos], species[(int)Species.Moltres]]);
CB_RoamState.Items.AddRange(["Inactive", "Roaming", "Stationary", "Defeated", "Captured"]);
CB_Species.SelectedIndex = GetInitialIndex(sav);
NUD_TimesEncountered.Value = roamer.TimesEncountered;

View file

@ -301,14 +301,14 @@ public partial class SAV_Trainer9 : Form
private void B_UnlockBikeUpgrades_Click(object sender, EventArgs e)
{
var blocks = new[]
{
string[] blocks =
[
"FSYS_RIDE_DASH_ENABLE",
"FSYS_RIDE_SWIM_ENABLE",
"FSYS_RIDE_HIJUMP_ENABLE",
"FSYS_RIDE_GLIDE_ENABLE",
"FSYS_RIDE_CLIMB_ENABLE",
};
];
var accessor = SAV.Accessor;
foreach (var block in blocks)

View file

@ -56,9 +56,9 @@ public partial class SAV_SimpleTrainer : Form
CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
GB_Map.Visible = false;
GB_Options.Visible = true;
CB_BattleStyle.Items.AddRange(new[] { "Switch", "Set" });
CB_SoundType.Items.AddRange(new[] { "Mono", "Stereo", "Left", "Right" });
CB_TextSpeed.Items.AddRange(new[] { "0 (Instant)", "1 (Fast)", "2", "3 (Normal)", "4", "5 (Slow)", "6", "7" });
CB_BattleStyle.Items.AddRange(["Switch", "Set"]);
CB_SoundType.Items.AddRange(["Mono", "Stereo", "Left", "Right"]);
CB_TextSpeed.Items.AddRange(["0 (Instant)", "1 (Fast)", "2", "3 (Normal)", "4", "5 (Slow)", "6", "7"]);
CHK_BattleEffects.Checked = sav1.BattleEffects;
CB_BattleStyle.SelectedIndex = sav1.BattleStyleSwitch ? 0 : 1;
@ -84,9 +84,9 @@ public partial class SAV_SimpleTrainer : Form
CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
GB_Map.Visible = false;
GB_Options.Visible = true;
CB_BattleStyle.Items.AddRange(new[] { "Switch", "Set" });
CB_SoundType.Items.AddRange(new[] { "Mono", "Stereo" });
CB_TextSpeed.Items.AddRange(new[] { "0 (Instant)", "1 (Fast)", "2", "3 (Normal)", "4", "5 (Slow)", "6", "7" });
CB_BattleStyle.Items.AddRange(["Switch", "Set"]);
CB_SoundType.Items.AddRange(["Mono", "Stereo"]);
CB_TextSpeed.Items.AddRange(["0 (Instant)", "1 (Fast)", "2", "3 (Normal)", "4", "5 (Slow)", "6", "7"]);
CHK_BattleEffects.Checked = sav2.BattleEffects;
CB_BattleStyle.SelectedIndex = sav2.BattleStyleSwitch ? 0 : 1;