diff --git a/BizHawk.Client.Common/RecentFiles.cs b/BizHawk.Client.Common/RecentFiles.cs index ebf6447744..1ecedee4a1 100644 --- a/BizHawk.Client.Common/RecentFiles.cs +++ b/BizHawk.Client.Common/RecentFiles.cs @@ -90,7 +90,7 @@ namespace BizHawk.Client.Common if (!Frozen) { var removed = false; - foreach (var recent in recentlist.ToList()) + foreach (var recent in recentlist) { if (string.Compare(newFile, recent, StringComparison.CurrentCultureIgnoreCase) == 0) { diff --git a/BizHawk.Client.Common/config/PathEntry.cs b/BizHawk.Client.Common/config/PathEntry.cs index 9b6b710212..aa345690bd 100644 --- a/BizHawk.Client.Common/config/PathEntry.cs +++ b/BizHawk.Client.Common/config/PathEntry.cs @@ -119,8 +119,7 @@ namespace BizHawk.Client.Common } // Add missing displaynames - var missingDisplayPaths = Paths.Where(p => p.SystemDisplayName == null).ToList(); - foreach (PathEntry path in missingDisplayPaths) + foreach (var path in Paths.Where(p => p.SystemDisplayName == null)) { path.SystemDisplayName = DefaultValues.First(p => p.System == path.System).SystemDisplayName; } diff --git a/BizHawk.Client.EmuHawk/BizBox.cs b/BizHawk.Client.EmuHawk/BizBox.cs index 14da9178bf..5f9e509e82 100644 --- a/BizHawk.Client.EmuHawk/BizBox.cs +++ b/BizHawk.Client.EmuHawk/BizBox.cs @@ -41,17 +41,12 @@ namespace BizHawk.Client.EmuHawk VersionLabel.Text = "Version " + mainversion; DateLabel.Text = VersionInfo.RELEASEDATE; - var cores = Assembly - .Load("BizHawk.Emulation.Cores") - .GetTypes() + foreach (var core in Assembly.Load("BizHawk.Emulation.Cores").GetTypes() .Where(t => typeof(IEmulator).IsAssignableFrom(t)) .Select(t => t.GetCustomAttributes(false).OfType().FirstOrDefault()) .Where(a => a != null) .Where(a => a.Released) - .OrderByDescending(a => a.CoreName.ToLower()) - .ToList(); - - foreach (var core in cores) + .OrderByDescending(a => a.CoreName.ToLower())) { CoreInfoPanel.Controls.Add(new BizBoxInfoControl(core) { diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs index 3226c99e94..96ef08562f 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs @@ -1374,7 +1374,7 @@ namespace BizHawk.Client.EmuHawk { if (SelectedRows.Any() && LetKeysModifySelection && SelectedRows.First() > 0) { - foreach (var row in SelectedRows.ToList()) + foreach (var row in SelectedRows) { SelectRow(row - 1, true); SelectRow(row, false); @@ -1385,7 +1385,7 @@ namespace BizHawk.Client.EmuHawk { if (SelectedRows.Any() && LetKeysModifySelection) { - foreach (var row in SelectedRows.Reverse().ToList()) + foreach (var row in SelectedRows.Reverse()) { SelectRow(row + 1, true); SelectRow(row, false); diff --git a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs index 7732f31930..a64a24e3db 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs @@ -347,7 +347,7 @@ namespace BizHawk.Client.EmuHawk type = " (on)"; } - Global.CheatList.ToList().ForEach(x => x.Toggle()); + foreach (var x in Global.CheatList) x.Toggle(); GlobalWin.OSD.AddMessage("Cheats toggled" + type); } diff --git a/BizHawk.Client.EmuHawk/Sound/Output/DirectSoundSoundOutput.cs b/BizHawk.Client.EmuHawk/Sound/Output/DirectSoundSoundOutput.cs index df362aa7aa..8a3045e516 100644 --- a/BizHawk.Client.EmuHawk/Sound/Output/DirectSoundSoundOutput.cs +++ b/BizHawk.Client.EmuHawk/Sound/Output/DirectSoundSoundOutput.cs @@ -43,7 +43,7 @@ namespace BizHawk.Client.EmuHawk public static IEnumerable GetDeviceNames() { - return DirectSound.GetDevices().Select(d => d.Description).ToList(); + return DirectSound.GetDevices().Select(d => d.Description); } private int BufferSizeSamples { get; set; } diff --git a/BizHawk.Client.EmuHawk/Sound/Output/XAudio2SoundOutput.cs b/BizHawk.Client.EmuHawk/Sound/Output/XAudio2SoundOutput.cs index 913fb91c94..1fe3510921 100644 --- a/BizHawk.Client.EmuHawk/Sound/Output/XAudio2SoundOutput.cs +++ b/BizHawk.Client.EmuHawk/Sound/Output/XAudio2SoundOutput.cs @@ -50,7 +50,7 @@ namespace BizHawk.Client.EmuHawk { using (XAudio2 device = new XAudio2()) { - return Enumerable.Range(0, device.DeviceCount).Select(n => device.GetDeviceDetails(n).DisplayName).ToList(); + return Enumerable.Range(0, device.DeviceCount).Select(n => device.GetDeviceDetails(n).DisplayName); } } diff --git a/BizHawk.Client.EmuHawk/config/HotkeyConfig.cs b/BizHawk.Client.EmuHawk/config/HotkeyConfig.cs index 24adc44d21..e29f028f5d 100644 --- a/BizHawk.Client.EmuHawk/config/HotkeyConfig.cs +++ b/BizHawk.Client.EmuHawk/config/HotkeyConfig.cs @@ -101,21 +101,20 @@ namespace BizHawk.Client.EmuHawk HotkeyTabControl.TabPages.Clear(); // Buckets - var tabs = Global.Config.HotkeyBindings.Select(x => x.TabGroup).Distinct().ToList(); - foreach (var tab in tabs) + foreach (var tab in Global.Config.HotkeyBindings.Select(x => x.TabGroup).Distinct()) { var _y = UIHelper.ScaleY(14); var _x = UIHelper.ScaleX(6); var tb = new TabPage {Name = tab, Text = tab}; - var bindings = Global.Config.HotkeyBindings.Where(x => x.TabGroup == tab).OrderBy(x => x.Ordinal).ThenBy(x => x.DisplayName).ToList(); - int iwOffsetX = UIHelper.ScaleX(110); int iwOffsetY = UIHelper.ScaleY(-4); int iwWidth = UIHelper.ScaleX(120); - foreach (var b in bindings) + foreach (var b in Global.Config.HotkeyBindings.Where(x => x.TabGroup == tab) + .OrderBy(x => x.Ordinal) + .ThenBy(x => x.DisplayName)) { var l = new Label { diff --git a/BizHawk.Client.EmuHawk/config/NES/NESSyncSettingsForm.cs b/BizHawk.Client.EmuHawk/config/NES/NESSyncSettingsForm.cs index a8aeb3d815..cc14be63fc 100644 --- a/BizHawk.Client.EmuHawk/config/NES/NESSyncSettingsForm.cs +++ b/BizHawk.Client.EmuHawk/config/NES/NESSyncSettingsForm.cs @@ -64,7 +64,7 @@ namespace BizHawk.Client.EmuHawk typeof(NES.NESSyncSettings.Region), (string)RegionComboBox.SelectedItem); - List oldRam = _syncSettings.InitialWRamStatePattern?.ToList() ?? new List(); + var oldRam = _syncSettings.InitialWRamStatePattern ?? Enumerable.Empty(); if (!string.IsNullOrWhiteSpace(RamPatternOverrideBox.Text)) { diff --git a/BizHawk.Client.EmuHawk/config/PathConfig.cs b/BizHawk.Client.EmuHawk/config/PathConfig.cs index 6c7ef17e6b..16198f7b72 100644 --- a/BizHawk.Client.EmuHawk/config/PathConfig.cs +++ b/BizHawk.Client.EmuHawk/config/PathConfig.cs @@ -111,14 +111,11 @@ namespace BizHawk.Client.EmuHawk Width = UIHelper.ScaleX(200), // Initial Left/Width of child controls are based on this size. AutoScroll = true }; - var paths = pathCollection - .Where(p => p.System == systemId) - .OrderBy(p => p.Ordinal) - .ThenBy(p => p.Type) - .ToList(); var y = UIHelper.ScaleY(14); - foreach (var path in paths) + foreach (var path in pathCollection.Where(p => p.System == systemId) + .OrderBy(p => p.Ordinal) + .ThenBy(p => p.Type)) { var box = new TextBox { @@ -243,10 +240,8 @@ namespace BizHawk.Client.EmuHawk private void DoRomToggle() { - AllPathControls - .Where(c => c.Name == "ROM") - .ToList() - .ForEach(control => control.Enabled = !RecentForROMs.Checked); + foreach (var control in AllPathControls.Where(c => c.Name == "ROM")) + control.Enabled = !RecentForROMs.Checked; } private IEnumerable AllPathBoxes diff --git a/BizHawk.Client.EmuHawk/movie/PlayMovie.cs b/BizHawk.Client.EmuHawk/movie/PlayMovie.cs index 058a873c90..c223f39631 100644 --- a/BizHawk.Client.EmuHawk/movie/PlayMovie.cs +++ b/BizHawk.Client.EmuHawk/movie/PlayMovie.cs @@ -306,13 +306,9 @@ namespace BizHawk.Client.EmuHawk private void MovieView_DragDrop(object sender, DragEventArgs e) { - var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); - - filePaths - .Where(path => MovieService.MovieExtensions.Contains(Path.GetExtension(path).Replace(".", ""))) - .ToList() - .ForEach(path => AddMovieToList(path, force: true)); - + foreach (var path in ((string[])e.Data.GetData(DataFormats.FileDrop)) + .Where(path => MovieService.MovieExtensions.Contains(Path.GetExtension(path)?.Replace(".", "")))) + AddMovieToList(path, force: true); RefreshMovieList(); } @@ -470,11 +466,8 @@ namespace BizHawk.Client.EmuHawk private void EditMenuItem_Click(object sender, EventArgs e) { - MovieView.SelectedIndices - .Cast() - .SelectAsIndexOf(_movieList) - .ToList() - .ForEach(movie => System.Diagnostics.Process.Start(movie.Filename)); + foreach (var movie in MovieView.SelectedIndices.Cast().SelectAsIndexOf(_movieList)) + System.Diagnostics.Process.Start(movie.Filename); } #endregion diff --git a/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs b/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs index 5c3e484926..8048967d84 100644 --- a/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs +++ b/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs @@ -438,10 +438,8 @@ namespace BizHawk.Client.EmuHawk CurrentFileName = ""; _bestBotAttempt = null; - ControlProbabilityPanel.Controls - .OfType() - .ToList() - .ForEach(cp => cp.Probability = 0); + foreach (var cp in ControlProbabilityPanel.Controls.OfType()) + cp.Probability = 0; FrameLength = 0; MaximizeAddress = 0; diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs index f1a35cc63c..ee703f3e2a 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs @@ -478,13 +478,8 @@ namespace BizHawk.Client.EmuHawk Global.CheatList.Insert(index - 1, cheat); } - var newindices = indices.Select(t => t - 1).ToList(); - CheatListView.SelectedIndices.Clear(); - foreach (var newi in newindices) - { - CheatListView.SelectItem(newi, true); - } + foreach (var index in indices) CheatListView.SelectItem(index - 1, true); UpdateMessageLabel(); UpdateDialog(); @@ -507,13 +502,8 @@ namespace BizHawk.Client.EmuHawk UpdateMessageLabel(); - var newindices = indices.Select(t => t + 1).ToList(); - CheatListView.SelectedIndices.Clear(); - foreach (var newi in newindices) - { - CheatListView.SelectItem(newi, true); - } + foreach (var index in indices) CheatListView.SelectItem(index + 1, true); UpdateDialog(); } @@ -525,7 +515,7 @@ namespace BizHawk.Client.EmuHawk private void ToggleMenuItem_Click(object sender, EventArgs e) { - SelectedCheats.ToList().ForEach(x => x.Toggle()); + foreach (var x in SelectedCheats) x.Toggle(); CheatListView.Refresh(); } diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/RegisterBoxControl.cs b/BizHawk.Client.EmuHawk/tools/Debugger/RegisterBoxControl.cs index 9f6d273e8f..51ef188277 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/RegisterBoxControl.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/RegisterBoxControl.cs @@ -41,46 +41,40 @@ namespace BizHawk.Client.EmuHawk { if (Controls.OfType().Any(p => p.Name == "FlagPanel")) { - Controls + foreach (var checkbox in Controls .OfType() .First(p => p.Name == "FlagPanel") .Controls - .OfType() - .ToList() - .ForEach(checkbox => + .OfType()) + { + if (checkbox.Name == register.Key) { - if (checkbox.Name == register.Key) - { - checkbox.Checked = register.Value.Value == 1; - } - }); + checkbox.Checked = register.Value.Value == 1; + } + } } if (_canSetCpuRegisters) { - Controls - .OfType() - .ToList() - .ForEach(textbox => + foreach (var textbox in Controls + .OfType()) + { + if (textbox.Name == register.Key) { - if (textbox.Name == register.Key) - { - textbox.Text = register.Value.Value.ToHexString(register.Value.BitSize / 4); - } - }); + textbox.Text = register.Value.Value.ToHexString(register.Value.BitSize / 4); + } + } } else { - Controls - .OfType