From 8e414aea29b79891e68b9a50bc5d35d2d1364680 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Thu, 18 Jun 2020 07:35:13 +1000 Subject: [PATCH] Enable CA1829 and fix noncompliance "Use Length/Count property instead of Count() when available" --- Common.ruleset | 3 -- .../movie/tasproj/TasMovie.History.cs | 2 +- .../AmstradCPC/AmstradCPC.Messaging.cs | 7 ++--- .../Hardware/Datacorder/DatacorderDevice.cs | 26 ++++++++-------- .../AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs | 6 ++-- .../AmstradCPC/Hardware/Disk/NECUPD765.FDD.cs | 5 ++-- .../Hardware/Display/AmstradGateArray.cs | 2 +- .../AmstradCPC/Machine/CPCBase.Media.cs | 12 ++++---- .../AmstradCPC/Media/Disk/FloppyDisk.cs | 4 +-- .../AmstradCPC/Media/Tape/CDT/CdtConverter.cs | 8 ++--- .../Hardware/Datacorder/DatacorderDevice.cs | 30 +++++++++---------- .../Hardware/Disk/NECUPD765.FDC.cs | 6 ++-- .../Hardware/Disk/NECUPD765.FDD.cs | 5 ++-- .../Machine/SpectrumBase.Input.cs | 2 +- .../Machine/SpectrumBase.Media.cs | 12 ++++---- .../SinclairSpectrum/Media/Disk/FloppyDisk.cs | 4 +-- .../Media/Disk/IPFFormat/IPFFloppyDisk.cs | 2 +- .../Media/Tape/TZX/TzxConverter.cs | 4 +-- .../SinclairSpectrum/ZXSpectrum.Messaging.cs | 7 ++--- .../Consoles/Nintendo/NES/Boards/Mapper030.cs | 3 +- 20 files changed, 71 insertions(+), 79 deletions(-) diff --git a/Common.ruleset b/Common.ruleset index e36f992415..708171d798 100644 --- a/Common.ruleset +++ b/Common.ruleset @@ -179,9 +179,6 @@ - - - diff --git a/src/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs b/src/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs index ccd08904dc..1d143a2529 100644 --- a/src/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs +++ b/src/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs @@ -802,7 +802,7 @@ namespace BizHawk.Client.Common public MovieActionInsertFrames(int frame, List newInputs) { FirstFrame = frame; - LastFrame = frame + newInputs.Count(); + LastFrame = frame + newInputs.Count; _onlyEmpty = false; _newInputs = newInputs; } diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Messaging.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Messaging.cs index 7308954caa..7af587d540 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Messaging.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Messaging.cs @@ -1,4 +1,3 @@ -using System.Linq; using System.Text; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC @@ -61,7 +60,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC StringBuilder sb = new StringBuilder(); if (_machine.diskImages != null && _machine.UPDDiskDevice != null) { - sb.Append("Disk Media Imported (count: " + _machine.diskImages.Count() + ")"); + sb.Append("Disk Media Imported (count: " + _machine.diskImages.Count + ")"); SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Emulator); } } @@ -149,7 +148,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC return; StringBuilder sb = new StringBuilder(); - sb.Append("Tape Media Imported (count: " + _tapeInfo.Count() + ")"); + sb.Append("Tape Media Imported (count: " + _tapeInfo.Count + ")"); SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Emulator); } @@ -408,7 +407,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC sb.Append("Block: "); sb.Append("(" + (_machine.TapeDevice.CurrentDataBlockIndex + 1) + - " of " + _machine.TapeDevice.DataBlocks.Count() + ") " + + " of " + _machine.TapeDevice.DataBlocks.Count + ") " + _machine.TapeDevice.DataBlocks[_machine.TapeDevice.CurrentDataBlockIndex].BlockDescription); SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Tape); sb.Clear(); diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs index 2132a36674..ed66c530ea 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs @@ -91,7 +91,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC set { if (value == _currentDataBlockIndex) { return; } - if (value < _dataBlocks.Count() && value >= 0) + if (value < _dataBlocks.Count && value >= 0) { _currentDataBlockIndex = value; _position = 0; @@ -233,7 +233,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC // move to the next block _currentDataBlockIndex++; - if (_currentDataBlockIndex >= _dataBlocks.Count()) + if (_currentDataBlockIndex >= _dataBlocks.Count) { _currentDataBlockIndex = -1; } @@ -244,7 +244,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC if ( _currentDataBlockIndex < 0 && // block index is -1 - _dataBlocks.Count() > 0 // number of blocks is greater than 0 + _dataBlocks.Count > 0 // number of blocks is greater than 0 ) { // move the index on to 0 @@ -305,7 +305,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC StringBuilder sbd = new StringBuilder(); sbd.Append("("); - sbd.Append((targetBlockId + 1) + " of " + _dataBlocks.Count()); + sbd.Append((targetBlockId + 1) + " of " + _dataBlocks.Count); sbd.Append(") : "); //sbd.Append("ID" + bl.BlockID.ToString("X2") + " - "); sbd.Append(bl.BlockDescription); @@ -486,7 +486,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC StringBuilder sbd = new StringBuilder(); sbd.Append("("); - sbd.Append((_currentDataBlockIndex + 1) + " of " + _dataBlocks.Count()); + sbd.Append((_currentDataBlockIndex + 1) + " of " + _dataBlocks.Count); sbd.Append(") : "); //sbd.Append("ID" + bl.BlockID.ToString("X2") + " - "); sbd.Append(bl.BlockDescription); @@ -502,17 +502,17 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC // increment the current period position _position++; - if (_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count()) + if (_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count) { // we have reached the end of the current block - if (_dataBlocks[_currentDataBlockIndex].DataPeriods.Count() == 0) + if (_dataBlocks[_currentDataBlockIndex].DataPeriods.Count == 0) { // notify about the current block (we are skipping it because its empty) var bl = _dataBlocks[_currentDataBlockIndex]; StringBuilder sbd = new StringBuilder(); sbd.Append("("); - sbd.Append((_currentDataBlockIndex + 1) + " of " + _dataBlocks.Count()); + sbd.Append((_currentDataBlockIndex + 1) + " of " + _dataBlocks.Count); sbd.Append(") : "); //sbd.Append("ID" + bl.BlockID.ToString("X2") + " - "); sbd.Append(bl.BlockDescription); @@ -526,7 +526,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } // skip any empty blocks (and process any command blocks) - while (_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count()) + while (_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count) { // check for any commands var command = _dataBlocks[_currentDataBlockIndex].Command; @@ -546,7 +546,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC _machine.CPC.OSD_TapeStoppedAuto(); shouldStop = true; - if (_currentDataBlockIndex >= _dataBlocks.Count()) + if (_currentDataBlockIndex >= _dataBlocks.Count) RTZ(); else { @@ -562,7 +562,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC _machine.CPC.OSD_TapeStoppedAuto(); shouldStop = true; - if (_currentDataBlockIndex >= _dataBlocks.Count()) + if (_currentDataBlockIndex >= _dataBlocks.Count) RTZ(); else { @@ -583,14 +583,14 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC _position = 0; _currentDataBlockIndex++; - if (_currentDataBlockIndex >= _dataBlocks.Count()) + if (_currentDataBlockIndex >= _dataBlocks.Count) { break; } } // check for end of tape - if (_currentDataBlockIndex >= _dataBlocks.Count()) + if (_currentDataBlockIndex >= _dataBlocks.Count) { _currentDataBlockIndex = -1; RTZ(); diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs index dfa8e97c25..e66b09f074 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs @@ -2498,7 +2498,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC if (cmd == null) { // no command found - use invalid - CMDIndex = CommandList.Count() - 1; + CMDIndex = CommandList.Count - 1; } else { @@ -2522,7 +2522,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC if (invalid) { // command byte included spurious bit 5,6 or 7 flags - CMDIndex = CommandList.Count() - 1; + CMDIndex = CommandList.Count - 1; } /* @@ -2531,7 +2531,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC (CMD_FLAG_SK && !ActiveCommand.SK)) { // command byte included spurious bit 5,6 or 7 flags - CMDIndex = CommandList.Count() - 1; + CMDIndex = CommandList.Count - 1; } */ } diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDD.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDD.cs index 8ba0235604..c98ccaabc5 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDD.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDD.cs @@ -1,7 +1,6 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; using System; -using System.Linq; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { @@ -237,7 +236,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC if (Disk == null) return (byte)id; - if (Disk.DiskTracks.Count() == 0) + if (Disk.DiskTracks.Length == 0) return (byte)id; if (TrackIndex >= Disk.GetTrackCount()) @@ -305,7 +304,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC public void MoveHead(SkipDirection direction, int cylinderCount) { // get total tracks - int trackCount = Disk.DiskTracks.Count(); + int trackCount = Disk.DiskTracks.Length; int trk = 0; diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs index bc85e00f2d..7b2fd48e9d 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs @@ -1255,7 +1255,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC Phases.Add(phase); } - public int PhaseCount => Phases.Count(); + public int PhaseCount => Phases.Count; public void Clear(int screenMode) { diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Media.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Media.cs index 60520e64f6..6b0bd5154c 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Media.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Media.cs @@ -38,13 +38,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC int tmp = value; int result = value; - if (tapeImages == null || tapeImages.Count() == 0) + if (tapeImages == null || tapeImages.Count == 0) { // no tape images found return; } - if (value >= tapeImages.Count()) + if (value >= tapeImages.Count) { // media at this index does not exist - loop back to 0 result = 0; @@ -52,7 +52,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC else if (value < 0) { // negative index not allowed - move to last item in the collection - result = tapeImages.Count() - 1; + result = tapeImages.Count - 1; } // load the media into the tape device @@ -75,13 +75,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC int tmp = value; int result = value; - if (diskImages == null || diskImages.Count() == 0) + if (diskImages == null || diskImages.Count == 0) { // no tape images found return; } - if (value >= diskImages.Count()) + if (value >= diskImages.Count) { // media at this index does not exist - loop back to 0 result = 0; @@ -89,7 +89,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC else if (value < 0) { // negative index not allowed - move to last item in the collection - result = diskImages.Count() - 1; + result = diskImages.Count - 1; } // load the media into the disk device diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs index bbafc189bc..db000dc794 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs @@ -156,7 +156,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } sec.SectorData = data.ToArray(); - sec.ActualDataByteLength = data.Count(); + sec.ActualDataByteLength = data.Count; sec.ContainsMultipleWeakSectors = true; } } @@ -496,7 +496,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC // commit the sector data sec.SectorData = data.ToArray(); sec.ContainsMultipleWeakSectors = true; - sec.ActualDataByteLength = data.Count(); + sec.ActualDataByteLength = data.Count; } */ diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs index 5e1265d151..b658f3ebf5 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs @@ -68,7 +68,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC double multiplier = 8.0 / 7.0; //double cycleScale = ((40 << 16) / 35); - double origPeriods = db.DataPeriods.Count(); + double origPeriods = db.DataPeriods.Count; for (int i = 0; i < origPeriods; i++) { @@ -182,7 +182,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /* // convert for Amstrad CPC List newBlocks = new List(); - for (int i = 0; i < _datacorder.DataBlocks.Count(); i++) + for (int i = 0; i < _datacorder.DataBlocks.Count; i++) { newBlocks.Add(ConvertClock(_datacorder.DataBlocks[i])); } @@ -1002,7 +1002,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC }; // loop should start from the next block - int loopStart = _datacorder.DataBlocks.Count() + 1; + int loopStart = _datacorder.DataBlocks.Count + 1; int numberOfRepetitions = GetWordValue(data, _position); @@ -1050,7 +1050,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } // get the number of blocks to loop - int blockCnt = _datacorder.DataBlocks.Count() - loopStart; + int blockCnt = _datacorder.DataBlocks.Count - loopStart; // loop through each group to repeat for (int b = 0; b < numberOfRepetitions; b++) diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs index 5924416a26..94e3364e81 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs @@ -48,13 +48,13 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { get { - if (_dataBlocks.Count() > 0) { return _currentDataBlockIndex; } + if (_dataBlocks.Count > 0) { return _currentDataBlockIndex; } else { return -1; } } set { if (value == _currentDataBlockIndex) { return; } - if (value < _dataBlocks.Count() && value >= 0) + if (value < _dataBlocks.Count && value >= 0) { _currentDataBlockIndex = value; _position = 0; @@ -204,7 +204,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // move to the next block _currentDataBlockIndex++; - if (_currentDataBlockIndex >= _dataBlocks.Count()) + if (_currentDataBlockIndex >= _dataBlocks.Count) { _currentDataBlockIndex = -1; } @@ -215,7 +215,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum if ( _currentDataBlockIndex < 0 && // block index is -1 - _dataBlocks.Count() > 0 // number of blocks is greater than 0 + _dataBlocks.Count > 0 // number of blocks is greater than 0 ) { // move the index on to 0 @@ -276,7 +276,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum StringBuilder sbd = new StringBuilder(); sbd.Append("("); - sbd.Append((targetBlockId + 1) + " of " + _dataBlocks.Count()); + sbd.Append((targetBlockId + 1) + " of " + _dataBlocks.Count); sbd.Append(") : "); sbd.Append(bl.BlockDescription); if (bl.MetaData.Count > 0) @@ -492,7 +492,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum StringBuilder sbd = new StringBuilder(); sbd.Append("("); - sbd.Append((_currentDataBlockIndex + 1) + " of " + _dataBlocks.Count()); + sbd.Append((_currentDataBlockIndex + 1) + " of " + _dataBlocks.Count); sbd.Append(") : "); sbd.Append(bl.BlockDescription); if (bl.MetaData.Count > 0) @@ -506,16 +506,16 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // increment the current period position _position++; - if (_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count()) + if (_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count) { // we have reached the end of the current block - if (_dataBlocks[_currentDataBlockIndex].DataPeriods.Count() == 0) + if (_dataBlocks[_currentDataBlockIndex].DataPeriods.Count == 0) { // notify about the current block (we are skipping it because its empty) var bl = _dataBlocks[_currentDataBlockIndex]; StringBuilder sbd = new StringBuilder(); sbd.Append("("); - sbd.Append((_currentDataBlockIndex + 1) + " of " + _dataBlocks.Count()); + sbd.Append((_currentDataBlockIndex + 1) + " of " + _dataBlocks.Count); sbd.Append(") : "); sbd.Append(bl.BlockDescription); if (bl.MetaData.Count > 0) @@ -528,7 +528,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } // skip any empty blocks (and process any command blocks) - while (_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count()) + while (_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count) { // check for any commands var command = _dataBlocks[_currentDataBlockIndex].Command; @@ -543,7 +543,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _machine.Spectrum.OSD_TapeStoppedAuto(); shouldStop = true; - if (_currentDataBlockIndex >= _dataBlocks.Count()) + if (_currentDataBlockIndex >= _dataBlocks.Count) RTZ(); else { @@ -558,7 +558,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _machine.Spectrum.OSD_TapeStoppedAuto(); shouldStop = true; - if (_currentDataBlockIndex >= _dataBlocks.Count()) + if (_currentDataBlockIndex >= _dataBlocks.Count) RTZ(); else { @@ -576,14 +576,14 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _position = 0; _currentDataBlockIndex++; - if (_currentDataBlockIndex >= _dataBlocks.Count()) + if (_currentDataBlockIndex >= _dataBlocks.Count) { break; } } // check for end of tape - if (_currentDataBlockIndex >= _dataBlocks.Count()) + if (_currentDataBlockIndex >= _dataBlocks.Count) { _currentDataBlockIndex = -1; RTZ(); @@ -592,7 +592,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } // update waitEdge with current position within the current block - _waitEdge = _dataBlocks[_currentDataBlockIndex].DataPeriods.Count() > 0 ? _dataBlocks[_currentDataBlockIndex].DataPeriods[_position] : 0; + _waitEdge = _dataBlocks[_currentDataBlockIndex].DataPeriods.Count > 0 ? _dataBlocks[_currentDataBlockIndex].DataPeriods[_position] : 0; // flip the current state FlipTapeState(); diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDC.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDC.cs index 9e2f6c2673..0d92eea2dc 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDC.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDC.cs @@ -2522,7 +2522,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum if (cmd == null) { // no command found - use invalid - CMDIndex = CommandList.Count() - 1; + CMDIndex = CommandList.Count - 1; } else { @@ -2546,7 +2546,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum if (invalid) { // command byte included spurious bit 5,6 or 7 flags - CMDIndex = CommandList.Count() - 1; + CMDIndex = CommandList.Count - 1; } /* @@ -2555,7 +2555,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum (CMD_FLAG_SK && !ActiveCommand.SK)) { // command byte included spurious bit 5,6 or 7 flags - CMDIndex = CommandList.Count() - 1; + CMDIndex = CommandList.Count - 1; } */ } diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDD.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDD.cs index 3f3a9f3dcc..1a55ad668c 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDD.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDD.cs @@ -1,7 +1,6 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; using System; -using System.Linq; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { @@ -237,7 +236,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum if (Disk == null) return (byte)id; - if (Disk.DiskTracks.Count() == 0) + if (Disk.DiskTracks.Length == 0) return (byte)id; if (TrackIndex >= Disk.GetTrackCount()) @@ -298,7 +297,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public void MoveHead(SkipDirection direction, int cylinderCount) { // get total tracks - int trackCount = Disk.DiskTracks.Count(); + int trackCount = Disk.DiskTracks.Length; int trk = 0; diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs index bac2ae50c5..d6c370a850 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs @@ -282,7 +282,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { var jCollection = new List(); - for (int i = 0; i < joys.Count(); i++) + for (int i = 0; i < joys.Count; i++) { jCollection.Add(InstantiateJoystick(joys[i], i + 1)); } diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Media.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Media.cs index 2f4fc56688..954b605707 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Media.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Media.cs @@ -44,13 +44,13 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum int tmp = value; int result = value; - if (tapeImages == null || tapeImages.Count() == 0) + if (tapeImages == null || tapeImages.Count == 0) { // no tape images found return; } - if (value >= tapeImages.Count()) + if (value >= tapeImages.Count) { // media at this index does not exist - loop back to 0 result = 0; @@ -58,7 +58,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum else if (value < 0) { // negative index not allowed - move to last item in the collection - result = tapeImages.Count() - 1; + result = tapeImages.Count - 1; } // load the media into the tape device @@ -84,13 +84,13 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum int tmp = value; int result = value; - if (diskImages == null || diskImages.Count() == 0) + if (diskImages == null || diskImages.Count == 0) { // no tape images found return; } - if (value >= diskImages.Count()) + if (value >= diskImages.Count) { // media at this index does not exist - loop back to 0 result = 0; @@ -98,7 +98,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum else if (value < 0) { // negative index not allowed - move to last item in the collection - result = diskImages.Count() - 1; + result = diskImages.Count - 1; } // load the media into the disk device diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs index f3e37fe03f..2823c9591c 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs @@ -156,7 +156,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } sec.SectorData = data.ToArray(); - sec.ActualDataByteLength = data.Count(); + sec.ActualDataByteLength = data.Count; sec.ContainsMultipleWeakSectors = true; } } @@ -496,7 +496,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // commit the sector data sec.SectorData = data.ToArray(); sec.ContainsMultipleWeakSectors = true; - sec.ActualDataByteLength = data.Count(); + sec.ActualDataByteLength = data.Count; } */ diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/IPFFormat/IPFFloppyDisk.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/IPFFormat/IPFFloppyDisk.cs index 4ceedf9d22..98c122544a 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/IPFFormat/IPFFloppyDisk.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/IPFFormat/IPFFloppyDisk.cs @@ -66,7 +66,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum var IMGEblocks = blocks.Where(a => a.RecordType == RecordHeaderType.IMGE).ToList(); var DATAblocks = blocks.Where(a => a.RecordType == RecordHeaderType.DATA); - DiskHeader.NumberOfTracks = (byte)(IMGEblocks.Count()); + DiskHeader.NumberOfTracks = (byte)(IMGEblocks.Count); DiskHeader.NumberOfSides = (byte)(infoBlock.INFOmaxSide + 1); DiskTracks = new Track[DiskHeader.NumberOfTracks]; diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs index 20b1538480..8b8fab1b14 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs @@ -922,7 +922,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum t.BlockDescription = BlockType.Loop_Start; // loop should start from the next block - int loopStart = _datacorder.DataBlocks.Count() + 1; + int loopStart = _datacorder.DataBlocks.Count + 1; int numberOfRepetitions = GetWordValue(data, _position); @@ -968,7 +968,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } // get the number of blocks to loop - int blockCnt = _datacorder.DataBlocks.Count() - loopStart; + int blockCnt = _datacorder.DataBlocks.Count - loopStart; // loop through each group to repeat for (int b = 0; b < numberOfRepetitions; b++) diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Messaging.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Messaging.cs index 33463c244b..9d0e1f35dd 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Messaging.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Messaging.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Text; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum @@ -62,7 +61,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum StringBuilder sb = new StringBuilder(); if (_machine.diskImages != null && _machine.UPDDiskDevice != null) { - sb.Append("Disk Media Imported (count: " + _machine.diskImages.Count() + ")"); + sb.Append("Disk Media Imported (count: " + _machine.diskImages.Count + ")"); SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Emulator); } } @@ -149,7 +148,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum return; StringBuilder sb = new StringBuilder(); - sb.Append("Tape Media Imported (count: " + _tapeInfo.Count() + ")"); + sb.Append("Tape Media Imported (count: " + _tapeInfo.Count + ")"); SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Emulator); } @@ -380,7 +379,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum sb.Append("Block: "); sb.Append("(" + (_machine.TapeDevice.CurrentDataBlockIndex + 1) + - " of " + _machine.TapeDevice.DataBlocks.Count() + ") " + + " of " + _machine.TapeDevice.DataBlocks.Count + ") " + _machine.TapeDevice.DataBlocks[_machine.TapeDevice.CurrentDataBlockIndex].BlockDescription); SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Tape); sb.Clear(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper030.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper030.cs index a1371cfa12..8a3b78f496 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper030.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper030.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES @@ -154,7 +153,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { //Of course, we gotta emulate the behaviour. for (int i = 0; i < (Cart.PrgSize / 4); i++) increment_flash_write_count(i, true); - for (int i = 0; i < flash_rom.Count(); i++) + for (int i = 0; i < flash_rom.Length; i++) flash_rom[Cart.PrgSize + i] = 0xFF; } else if (value == 0x30)