diff --git a/BizHawk.Client.Common/RecentFiles.cs b/BizHawk.Client.Common/RecentFiles.cs index 540434083a..889c916f3a 100644 --- a/BizHawk.Client.Common/RecentFiles.cs +++ b/BizHawk.Client.Common/RecentFiles.cs @@ -80,7 +80,7 @@ namespace BizHawk.Client.Common if (recentlist.Count > MAX_RECENT_FILES) { - recentlist.Remove(recentlist.Last()); + recentlist.Remove(recentlist[recentlist.Count - 1]); } } } diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs index 3ee12b74d0..990a981088 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -627,8 +627,8 @@ namespace BizHawk.Client.Common case "GB": case "DGB": // adelikat: remove need for tags to be hardcoded to left and right, we should clean this up, also maybe the DGB core should just take the xml file and handle it itself - var leftBytes = xmlGame.Assets.First().Value; - var rightBytes = xmlGame.Assets.Skip(1).First().Value; + var leftBytes = xmlGame.Assets[0].Value; + var rightBytes = xmlGame.Assets[1].Value; var left = Database.GetGameInfo(leftBytes, "left.gb"); var right = Database.GetGameInfo(rightBytes, "right.gb"); @@ -796,8 +796,8 @@ namespace BizHawk.Client.Common nextEmulator = new GPGX(nextComm, null, genDiscs, GetCoreSettings(), GetCoreSyncSettings()); break; case "Game Gear": - var leftBytesGG = xmlGame.Assets.First().Value; - var rightBytesGG = xmlGame.Assets.Skip(1).First().Value; + var leftBytesGG = xmlGame.Assets[0].Value; + var rightBytesGG = xmlGame.Assets[1].Value; var leftGG = Database.GetGameInfo(leftBytesGG, "left.gg"); var rightGG = Database.GetGameInfo(rightBytesGG, "right.gg"); diff --git a/BizHawk.Client.Common/lua/LuaLibraryBase.cs b/BizHawk.Client.Common/lua/LuaLibraryBase.cs index bcf0a6845e..d72fc54679 100644 --- a/BizHawk.Client.Common/lua/LuaLibraryBase.cs +++ b/BizHawk.Client.Common/lua/LuaLibraryBase.cs @@ -100,7 +100,7 @@ namespace BizHawk.Client.Common foreach (var method in methods) { - var luaMethodAttr = (LuaMethodAttribute)method.GetCustomAttributes(luaAttr, false).First(); + var luaMethodAttr = (LuaMethodAttribute)method.GetCustomAttributes(luaAttr, false)[0]; var luaName = Name + "." + luaMethodAttr.Name; Lua.RegisterFunction(luaName, this, method); diff --git a/BizHawk.Client.Common/movie/import/MovieImport.cs b/BizHawk.Client.Common/movie/import/MovieImport.cs index 9110615a37..34be4e0b03 100644 --- a/BizHawk.Client.Common/movie/import/MovieImport.cs +++ b/BizHawk.Client.Common/movie/import/MovieImport.cs @@ -98,12 +98,12 @@ namespace BizHawk.Client.Common var result = importer.Import(path); if (result.Errors.Count > 0) { - errorMsg = result.Errors.First(); + errorMsg = result.Errors[0]; } if (result.Warnings.Count > 0) { - warningMsg = result.Warnings.First(); + warningMsg = result.Warnings[0]; } movie = result.Movie; diff --git a/BizHawk.Client.Common/movie/tasproj/TasLagLog.cs b/BizHawk.Client.Common/movie/tasproj/TasLagLog.cs index e02b10a009..cc8fd5d351 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasLagLog.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasLagLog.cs @@ -157,7 +157,7 @@ namespace BizHawk.Client.Common { br.ReadInt32(); _lagLog.Add(br.ReadBoolean()); - _wasLag.Add(_lagLog.Last()); + _wasLag.Add(_lagLog[_lagLog.Count - 1]); } } else if (formatVersion == 1) diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs index 30f6182037..5949113ddb 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs @@ -140,7 +140,7 @@ namespace BizHawk.Client.Common } _recordingBatch = false; - List last = _history.Last(); + List last = _history[_history.Count - 1]; if (last.Count == 0) // Remove batch if it's empty. { _history.RemoveAt(_history.Count - 1); @@ -312,8 +312,8 @@ namespace BizHawk.Client.Common if (IsRecording || force) { AddMovieAction(name); - _history.Last().Add(new MovieAction(first, last, _movie)); - _lastGeneral = _history.Last().Count - 1; + _history[_history.Count - 1].Add(new MovieAction(first, last, _movie)); + _lastGeneral = _history[_history.Count - 1].Count - 1; } } @@ -321,7 +321,7 @@ namespace BizHawk.Client.Common { if (IsRecording || force) { - (_history.Last()[_lastGeneral] as MovieAction).SetRedoLog(_movie); + (_history[_history.Count - 1][_lastGeneral] as MovieAction).SetRedoLog(_movie); } } @@ -330,7 +330,7 @@ namespace BizHawk.Client.Common if (IsRecording || force) { AddMovieAction(name); - _history.Last().Add(new MovieActionFrameEdit(frame, button, oldState, !oldState)); + _history[_history.Count - 1].Add(new MovieActionFrameEdit(frame, button, oldState, !oldState)); } } @@ -339,7 +339,7 @@ namespace BizHawk.Client.Common if (IsRecording || force) { AddMovieAction(name); - _history.Last().Add(new MovieActionFrameEdit(frame, button, oldState, newState)); + _history[_history.Count - 1].Add(new MovieActionFrameEdit(frame, button, oldState, newState)); } } @@ -357,7 +357,7 @@ namespace BizHawk.Client.Common } AddMovieAction(name); - _history.Last().Add(new MovieActionMarker(newMarker, oldPosition, oldMessage)); + _history[_history.Count - 1].Add(new MovieActionMarker(newMarker, oldPosition, oldMessage)); } } @@ -366,7 +366,7 @@ namespace BizHawk.Client.Common if (IsRecording || force) { AddMovieAction(name); - _history.Last().Add(new MovieActionBindInput(_movie, frame, isDelete)); + _history[_history.Count - 1].Add(new MovieActionBindInput(_movie, frame, isDelete)); } } diff --git a/BizHawk.Client.EmuHawk/Api/Libraries/ToolApi.cs b/BizHawk.Client.EmuHawk/Api/Libraries/ToolApi.cs index a0a52537e5..39f87351f6 100644 --- a/BizHawk.Client.EmuHawk/Api/Libraries/ToolApi.cs +++ b/BizHawk.Client.EmuHawk/Api/Libraries/ToolApi.cs @@ -40,7 +40,7 @@ namespace BizHawk.Client.EmuHawk if (possibleTypes.Length > 0) { - return Activator.CreateInstance(possibleTypes.First()); + return Activator.CreateInstance(possibleTypes[0]); } return null; @@ -118,7 +118,7 @@ namespace BizHawk.Client.EmuHawk if (possibleTypes.Length > 0) { - return Activator.CreateInstance(possibleTypes.First()); + return Activator.CreateInstance(possibleTypes[0]); } return null; diff --git a/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs b/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs index 2787e74bf9..0704cf4b9a 100644 --- a/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs +++ b/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs @@ -223,7 +223,7 @@ namespace BizHawk.Client.EmuHawk .Select(t => new { Type = t, - CoreAttributes = (CoreAttribute)t.GetCustomAttributes(typeof(CoreAttribute), false).First() + CoreAttributes = (CoreAttribute)t.GetCustomAttributes(typeof(CoreAttribute), false)[0] }) .OrderByDescending(t => t.CoreAttributes.Released) .ThenBy(t => t.CoreAttributes.CoreName) diff --git a/BizHawk.Client.EmuHawk/FileLoader.cs b/BizHawk.Client.EmuHawk/FileLoader.cs index 3d49dd87a1..c994d977ee 100644 --- a/BizHawk.Client.EmuHawk/FileLoader.cs +++ b/BizHawk.Client.EmuHawk/FileLoader.cs @@ -318,7 +318,7 @@ namespace BizHawk.Client.EmuHawk case 0: break; case 1: - FileInformation fileInformation = sortedFiles[value].First(); + FileInformation fileInformation = sortedFiles[value][0]; string filename = Path.Combine(new string[] { fileInformation.DirectoryName, fileInformation.FileName }); switch (value) diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs index fc151c843c..a38087eb22 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs @@ -50,46 +50,46 @@ namespace BizHawk.Client.EmuHawk bool selectionValid = true; var j1 = Port1ComboBox.SelectedItem.ToString(); - if (j1 != possibleControllers.First()) + if (j1 != possibleControllers[0]) { if (j1 == Port2ComboBox.SelectedItem.ToString()) { - Port2ComboBox.SelectedItem = possibleControllers.First(); + Port2ComboBox.SelectedItem = possibleControllers[0]; selectionValid = false; } if (j1 == Port3ComboBox.SelectedItem.ToString()) { - Port3ComboBox.SelectedItem = possibleControllers.First(); + Port3ComboBox.SelectedItem = possibleControllers[0]; selectionValid = false; } } var j2 = Port2ComboBox.SelectedItem.ToString(); - if (j2 != possibleControllers.First()) + if (j2 != possibleControllers[0]) { if (j2 == Port1ComboBox.SelectedItem.ToString()) { - Port1ComboBox.SelectedItem = possibleControllers.First(); + Port1ComboBox.SelectedItem = possibleControllers[0]; selectionValid = false; } if (j2 == Port3ComboBox.SelectedItem.ToString()) { - Port3ComboBox.SelectedItem = possibleControllers.First(); + Port3ComboBox.SelectedItem = possibleControllers[0]; selectionValid = false; } } var j3 = Port3ComboBox.SelectedItem.ToString(); - if (j3 != possibleControllers.First()) + if (j3 != possibleControllers[0]) { if (j3 == Port1ComboBox.SelectedItem.ToString()) { - Port1ComboBox.SelectedItem = possibleControllers.First(); + Port1ComboBox.SelectedItem = possibleControllers[0]; selectionValid = false; } if (j3 == Port2ComboBox.SelectedItem.ToString()) { - Port2ComboBox.SelectedItem = possibleControllers.First(); + Port2ComboBox.SelectedItem = possibleControllers[0]; selectionValid = false; } } diff --git a/BizHawk.Client.EmuHawk/movie/PlayMovie.cs b/BizHawk.Client.EmuHawk/movie/PlayMovie.cs index 6fe6cb6fed..058a873c90 100644 --- a/BizHawk.Client.EmuHawk/movie/PlayMovie.cs +++ b/BizHawk.Client.EmuHawk/movie/PlayMovie.cs @@ -215,7 +215,7 @@ namespace BizHawk.Client.EmuHawk // Final tie breaker - Last used file var file = new FileInfo(_movieList[indices[0]].Filename); var time = file.LastAccessTime; - var mostRecent = indices.First(); + var mostRecent = indices[0]; for (var i = 1; i < indices.Count; i++) { file = new FileInfo(_movieList[indices[0]].Filename); diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs index 2908334e17..d4cead7ddb 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs @@ -501,7 +501,7 @@ namespace BizHawk.Client.EmuHawk private void MoveDownMenuItem_Click(object sender, EventArgs e) { var indices = SelectedIndices.ToList(); - if (indices.Count == 0 || indices.Last() == Global.CheatList.Count - 1) + if (indices.Count == 0 || indices[indices.Count - 1] == Global.CheatList.Count - 1) { return; } @@ -697,11 +697,11 @@ namespace BizHawk.Client.EmuHawk if (selected.Select(x => x.Domain).Distinct().Count() > 1) { - ViewInHexEditor(selected[0].Domain, new List { selected.First().Address ?? 0 }, selected.First().Size); + ViewInHexEditor(selected[0].Domain, new List { selected[0].Address ?? 0 }, selected[0].Size); } else { - ViewInHexEditor(selected.First().Domain, selected.Select(x => x.Address ?? 0), selected.First().Size); + ViewInHexEditor(selected[0].Domain, selected.Select(x => x.Address ?? 0), selected[0].Size); } } } diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs index cf5c326ce0..669b5fc519 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs @@ -130,7 +130,7 @@ namespace BizHawk.Client.EmuHawk private void IncrementCurrentAddress() { - _currentDisassemblerAddress += (uint)_disassemblyLines.First().Size; + _currentDisassemblerAddress += (uint)_disassemblyLines[0].Size; if (_currentDisassemblerAddress >= BusMaxValue) { _currentDisassemblerAddress = (uint)(BusMaxValue - 1); diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs index 47882493c4..31e4f0386a 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs @@ -1300,7 +1300,7 @@ namespace BizHawk.Client.EmuHawk var parts = line.Split('='); _textTable.Add( int.Parse(parts[0], - NumberStyles.HexNumber), parts[1].First()); + NumberStyles.HexNumber), parts[1][0]); } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs index 5c16b66bb1..3fdb7ece21 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs @@ -51,7 +51,7 @@ namespace BizHawk.Client.EmuHawk var attributes = lib.GetCustomAttributes(typeof(LuaLibraryAttribute), false); if (attributes.Length > 0) { - addLibrary = VersionInfo.DeveloperBuild || (attributes.First() as LuaLibraryAttribute).Released; + addLibrary = VersionInfo.DeveloperBuild || (attributes[0] as LuaLibraryAttribute).Released; } if (addLibrary) diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 059d344244..04a6ead8e0 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -992,7 +992,7 @@ namespace BizHawk.Client.EmuHawk var indices = LuaListView.SelectedIndices().ToList(); if (indices.Count > 0 && indices[indices.Count - 1] < LuaImp.ScriptList.Count) { - LuaImp.ScriptList.Insert(indices.Last(), LuaFile.SeparatorInstance); + LuaImp.ScriptList.Insert(indices[indices.Count - 1], LuaFile.SeparatorInstance); } else { @@ -1031,7 +1031,7 @@ namespace BizHawk.Client.EmuHawk private void MoveDownMenuItem_Click(object sender, EventArgs e) { var indices = LuaListView.SelectedIndices().ToList(); - if (indices.Count == 0 || indices.Last() == LuaImp.ScriptList.Count - 1) + if (indices.Count == 0 || indices[indices.Count - 1] == LuaImp.ScriptList.Count - 1) { return; } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs index 46f9341bf4..50e1622ae6 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs @@ -274,7 +274,7 @@ namespace BizHawk.Client.EmuHawk private void MarkerView_ItemActivate(object sender, EventArgs e) { - Tastudio.GoToMarker(SelectedMarkers.First()); + Tastudio.GoToMarker(SelectedMarkers[0]); } // SuuperW: Marker renaming can be done with a right-click. diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index 69e22ade62..8b49c7bc37 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -929,7 +929,7 @@ namespace BizHawk.Client.EmuHawk private void MoveDownMenuItem_Click(object sender, EventArgs e) { var indices = SelectedIndices.ToList(); - if (indices.Count == 0 || indices.Last() == _watches.Count - 1) + if (indices.Count == 0 || indices[indices.Count - 1] == _watches.Count - 1) { return; } @@ -1214,11 +1214,11 @@ namespace BizHawk.Client.EmuHawk if (selected.Select(x => x.Domain).Distinct().Count() > 1) { - ViewInHexEditor(selected[0].Domain, new List { selected.First().Address }, selected.First().Size); + ViewInHexEditor(selected[0].Domain, new List { selected[0].Address }, selected[0].Size); } else { - ViewInHexEditor(selected.First().Domain, selected.Select(x => x.Address), selected.First().Size); + ViewInHexEditor(selected[0].Domain, selected.Select(x => x.Address), selected[0].Size); } } } diff --git a/BizHawk.Client.MultiHawk/EmulatorWindow.cs b/BizHawk.Client.MultiHawk/EmulatorWindow.cs index 0ea193c46c..e72a81e87f 100644 --- a/BizHawk.Client.MultiHawk/EmulatorWindow.cs +++ b/BizHawk.Client.MultiHawk/EmulatorWindow.cs @@ -300,13 +300,7 @@ namespace BizHawk.Client.MultiHawk } } - public bool IAmMaster - { - get - { - return MainForm.EmulatorWindows.First() == this; - } - } + public bool IAmMaster => MainForm.EmulatorWindows[0] == this; public void FrameBufferResized() { diff --git a/BizHawk.Client.MultiHawk/EmulatorWindowList.cs b/BizHawk.Client.MultiHawk/EmulatorWindowList.cs index 2c3576c20d..4e70b16bdc 100644 --- a/BizHawk.Client.MultiHawk/EmulatorWindowList.cs +++ b/BizHawk.Client.MultiHawk/EmulatorWindowList.cs @@ -11,18 +11,7 @@ namespace BizHawk.Client.MultiHawk { public string SessionName { get; set; } - public EmulatorWindow Master - { - get - { - if (this.Count > 0) - { - return this.First(); - } - - return null; - } - } + public EmulatorWindow Master => this.Count == 0 ? null : this[0]; public IEnumerable Session { diff --git a/BizHawk.Client.MultiHawk/InputManager.cs b/BizHawk.Client.MultiHawk/InputManager.cs index a1e7470727..2855abe8ff 100644 --- a/BizHawk.Client.MultiHawk/InputManager.cs +++ b/BizHawk.Client.MultiHawk/InputManager.cs @@ -53,7 +53,7 @@ namespace BizHawk.Client.MultiHawk public void SyncControls() { - var def = _mainForm.EmulatorWindows.First().Emulator.ControllerDefinition; + var def = _mainForm.EmulatorWindows[0].Emulator.ControllerDefinition; Global.ActiveController = BindToDefinition(def, Global.Config.AllTrollers, Global.Config.AllTrollersAnalog); // TODO? diff --git a/BizHawk.Client.MultiHawk/Mainform.cs b/BizHawk.Client.MultiHawk/Mainform.cs index 00638feffc..86654f0b44 100644 --- a/BizHawk.Client.MultiHawk/Mainform.cs +++ b/BizHawk.Client.MultiHawk/Mainform.cs @@ -278,7 +278,7 @@ namespace BizHawk.Client.MultiHawk _inputManager.SyncControls(); - if (EmulatorWindows.First() == ew) + if (EmulatorWindows[0] == ew) { Emulator = ew.Emulator; } @@ -348,14 +348,14 @@ namespace BizHawk.Client.MultiHawk if (EmulatorWindows.Count > 0) { // Attempt to open the window is a smart location - var last = EmulatorWindows.Last(); + var last = EmulatorWindows[EmulatorWindows.Count - 1]; int x = last.Location.X + last.Width + 5; int y = last.Location.Y; if (x + (last.Width / 2) > Width) // If it will go too far off screen { y += last.Height + 5; - x = EmulatorWindows.First().Location.X; + x = EmulatorWindows[0].Location.X; } ew.Location = new Point(x, y); @@ -1445,7 +1445,7 @@ namespace BizHawk.Client.MultiHawk foreach (var entry in entries) { LoadRom(entry.RomName); - EmulatorWindows.Last().Location = new Point(entry.Wndx, entry.Wndy); + EmulatorWindows[EmulatorWindows.Count - 1].Location = new Point(entry.Wndx, entry.Wndy); UpdateMainText(); } } diff --git a/BizHawk.Client.MultiHawk/movie/PlayMovie.cs b/BizHawk.Client.MultiHawk/movie/PlayMovie.cs index dcc2f12f95..2b28df9ced 100644 --- a/BizHawk.Client.MultiHawk/movie/PlayMovie.cs +++ b/BizHawk.Client.MultiHawk/movie/PlayMovie.cs @@ -214,7 +214,7 @@ namespace BizHawk.Client.MultiHawk // Final tie breaker - Last used file var file = new FileInfo(_movieList[indices[0]].Filename); var time = file.LastAccessTime; - var mostRecent = indices.First(); + var mostRecent = indices[0]; for (var i = 1; i < indices.Count; i++) { file = new FileInfo(_movieList[indices[0]].Filename); diff --git a/BizHawk.Client.MultiHawk/movie/RecordMovie.cs b/BizHawk.Client.MultiHawk/movie/RecordMovie.cs index 4c5cdb4e66..b7afa11953 100644 --- a/BizHawk.Client.MultiHawk/movie/RecordMovie.cs +++ b/BizHawk.Client.MultiHawk/movie/RecordMovie.cs @@ -156,7 +156,7 @@ namespace BizHawk.Client.MultiHawk private void RecordMovie_Load(object sender, EventArgs e) { - RecordBox.Text = PathManager.FilesystemSafeName(GlobalWin.MainForm.EmulatorWindows.First().Game); + RecordBox.Text = PathManager.FilesystemSafeName(GlobalWin.MainForm.EmulatorWindows[0].Game); StartFromCombo.SelectedIndex = 0; DefaultAuthorCheckBox.Checked = Global.Config.UseDefaultAuthor; if (Global.Config.UseDefaultAuthor) diff --git a/BizHawk.Emulation.Common/Base Implementations/MemoryDomainList.cs b/BizHawk.Emulation.Common/Base Implementations/MemoryDomainList.cs index dfb67ec775..5d24bf70fa 100644 --- a/BizHawk.Emulation.Common/Base Implementations/MemoryDomainList.cs +++ b/BizHawk.Emulation.Common/Base Implementations/MemoryDomainList.cs @@ -36,12 +36,7 @@ namespace BizHawk.Emulation.Common { get { - if (_mainMemory != null) - { - return _mainMemory; - } - - return this.First(); + return _mainMemory ?? this[0]; } set diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs index 77a39040d9..9d9f262b2a 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs @@ -1059,15 +1059,11 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC var excessR = excessL + (padPos % 2); for (int i = 0; i < excessL; i++) { - var lThing = lCop.First(); - - lCop.Remove(lThing); + lCop.Remove(lCop[0]); } for (int i = 0; i < excessL; i++) { - var lThing = lCop.Last(); - - lCop.Remove(lThing); + lCop.Remove(lCop[lCop.Count - 1]); } } diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs index c7891c5b4f..f61d185042 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs @@ -677,7 +677,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC for (int i = 0; i < size - ActualDataByteLength; i++) { //l.Add(SectorData[i]); - l.Add(SectorData.Last()); + l.Add(SectorData[SectorData.Length - 1]); } return l.ToArray(); diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs index b83d02d32b..0093273c84 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs @@ -384,7 +384,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC _position += blockLen; // generate PAUSE block - CreatePauseBlock(_datacorder.DataBlocks.Last()); + CreatePauseBlock(_datacorder.DataBlocks[_datacorder.DataBlocks.Count - 1]); } #endregion @@ -444,7 +444,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC _position += blockLen; // generate PAUSE block - CreatePauseBlock(_datacorder.DataBlocks.Last()); + CreatePauseBlock(_datacorder.DataBlocks[_datacorder.DataBlocks.Count - 1]); } #endregion @@ -570,7 +570,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC _position += blockLen; // generate PAUSE block - CreatePauseBlock(_datacorder.DataBlocks.Last()); + CreatePauseBlock(_datacorder.DataBlocks[_datacorder.DataBlocks.Count - 1]); } #endregion @@ -676,7 +676,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC _datacorder.DataBlocks.Add(t); // generate PAUSE block - CreatePauseBlock(_datacorder.DataBlocks.Last()); + CreatePauseBlock(_datacorder.DataBlocks[_datacorder.DataBlocks.Count - 1]); } #endregion @@ -747,7 +747,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC _datacorder.DataBlocks.Add(t); // generate PAUSE block - CreatePauseBlock(_datacorder.DataBlocks.Last()); + CreatePauseBlock(_datacorder.DataBlocks[_datacorder.DataBlocks.Count - 1]); } #endregion @@ -900,7 +900,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC _position += 2; // generate PAUSE block - CreatePauseBlock(_datacorder.DataBlocks.Last()); + CreatePauseBlock(_datacorder.DataBlocks[_datacorder.DataBlocks.Count - 1]); } #endregion diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/SoundProviderMixer.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/SoundProviderMixer.cs index 77e30f5fca..9b5c926bc6 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/SoundProviderMixer.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/SoundProviderMixer.cs @@ -152,7 +152,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } // are all the sample lengths the same? - var firstEntry = SoundProviders.First(); + var firstEntry = SoundProviders[0]; bool sameCount = SoundProviders.All(s => s.NSamp == firstEntry.NSamp); if (!sameCount) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index 0e17385256..eddf0be04d 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -63,7 +63,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 if (_board.CartPort.IsConnected) { // There are no multi-cart cart games, so just hardcode .First() - CoreComm.RomStatusDetails = $"{game.Name}\r\nSHA1:{_roms.First().HashSHA1()}\r\nMD5:{roms.First().HashMD5()}\r\nMapper Impl \"{_board.CartPort.CartridgeType}\""; + CoreComm.RomStatusDetails = $"{game.Name}\r\nSHA1:{_roms[0].HashSHA1()}\r\nMD5:{_roms[0].HashMD5()}\r\nMapper Impl \"{_board.CartPort.CartridgeType}\""; } SetupMemoryDomains(); @@ -238,7 +238,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 private void Init(VicType initRegion, BorderType borderType, SidType sidType, TapeDriveType tapeDriveType, DiskDriveType diskDriveType) { // Force certain drive types to be available depending on ROM type - var rom = _roms.First(); + var rom = _roms[0]; switch (C64FormatFinder.GetFormat(rom)) { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000A.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000A.cs index 7916a45765..57e80d1a48 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000A.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000A.cs @@ -22,7 +22,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge public Mapper000A(IList newData) { _rom = new int[0x2000]; - Array.Copy(newData.First(), _rom, 0x2000); + Array.Copy(newData[0], _rom, 0x2000); pinGame = true; } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper002B.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper002B.cs index 8d733d9fcc..c521ecdcec 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper002B.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper002B.cs @@ -22,7 +22,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge pinExRom = false; pinGame = true; _rom = new int[0x40000]; - Array.Copy(newData.First(), _rom, 0x2000); + Array.Copy(newData[0], _rom, 0x2000); pinGame = true; for (var i = 0; i < newData.Count; i++) { diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs index 7e8840e757..ef9b63398e 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs @@ -686,7 +686,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum for (int i = 0; i < size - ActualDataByteLength; i++) { //l.Add(SectorData[i]); - l.Add(SectorData.Last()); + l.Add(SectorData[SectorData.Length - 1]); } return l.ToArray(); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs index 0488c98d3c..bf58bf67f2 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs @@ -324,7 +324,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _position += blockLen; // generate PAUSE block - CreatePauseBlock(_datacorder.DataBlocks.Last()); + CreatePauseBlock(_datacorder.DataBlocks[_datacorder.DataBlocks.Count - 1]); } #endregion @@ -384,7 +384,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _position += blockLen; // generate PAUSE block - CreatePauseBlock(_datacorder.DataBlocks.Last()); + CreatePauseBlock(_datacorder.DataBlocks[_datacorder.DataBlocks.Count - 1]); } #endregion @@ -510,7 +510,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _position += blockLen; // generate PAUSE block - CreatePauseBlock(_datacorder.DataBlocks.Last()); + CreatePauseBlock(_datacorder.DataBlocks[_datacorder.DataBlocks.Count - 1]); } #endregion @@ -616,7 +616,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _datacorder.DataBlocks.Add(t); // generate PAUSE block - CreatePauseBlock(_datacorder.DataBlocks.Last()); + CreatePauseBlock(_datacorder.DataBlocks[_datacorder.DataBlocks.Count - 1]); } #endregion @@ -687,7 +687,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _datacorder.DataBlocks.Add(t); // generate PAUSE block - CreatePauseBlock(_datacorder.DataBlocks.Last()); + CreatePauseBlock(_datacorder.DataBlocks[_datacorder.DataBlocks.Count - 1]); } #endregion @@ -840,7 +840,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _position += 2; // generate PAUSE block - CreatePauseBlock(_datacorder.DataBlocks.Last()); + CreatePauseBlock(_datacorder.DataBlocks[_datacorder.DataBlocks.Count - 1]); } #endregion diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/SoundProviderMixer.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/SoundProviderMixer.cs index 55df2265f9..95cfb1a335 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/SoundProviderMixer.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/SoundProviderMixer.cs @@ -152,7 +152,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } // are all the sample lengths the same? - var firstEntry = SoundProviders.First(); + var firstEntry = SoundProviders[0]; bool sameCount = SoundProviders.All(s => s.NSamp == firstEntry.NSamp); if (!sameCount) diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs index 6b0e1ac686..38464f9c34 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs @@ -764,7 +764,7 @@ namespace BizHawk.Emulation.DiscSystem throw new MDSParseException("BLOB Error!"); // is the currBlob valid for this track, or do we need to increment? - string bString = tBlobs.First(); + string bString = tBlobs[0]; IBlob mdfBlob = null; diff --git a/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs b/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs index e4fe3c2f74..b15f68c8f7 100644 --- a/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs +++ b/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs @@ -211,7 +211,7 @@ namespace BizHawk.Emulation.DiscSystem var absTxt = iso.Root.Children.Where(a => a.Key.Contains("ABS.TXT")).ToList(); if (absTxt.Count > 0) { - if (SectorContains("abstracted by snk", Convert.ToInt32(absTxt.First().Value.Offset))) + if (SectorContains("abstracted by snk", Convert.ToInt32(absTxt[0].Value.Offset))) return DiscType.NeoGeoCD; }