diff --git a/.global.editorconfig.ini b/.global.editorconfig.ini index 69357c073c..396c5ec882 100644 --- a/.global.editorconfig.ini +++ b/.global.editorconfig.ini @@ -470,6 +470,8 @@ dotnet_diagnostic.RCS1240.severity = warning dotnet_diagnostic.RCS1242.severity = silent # Duplicate word in a comment dotnet_diagnostic.RCS1243.severity = warning +# Use element access +dotnet_diagnostic.RCS1246.severity = warning ## Microsoft.CodeAnalysis.BannedApiAnalyzers rules diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index e79a7c65ee..6a8555ef85 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -4178,7 +4178,7 @@ namespace BizHawk.Client.EmuHawk if (result.Warnings.Count is not 0) { - AddOnScreenMessage(result.Warnings.First()); // For now, just show the first warning + AddOnScreenMessage(result.Warnings[0]); // For now, just show the first warning } AddOnScreenMessage($"{Path.GetFileName(fn)} imported as {result.Movie.Filename}"); diff --git a/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000A.cs b/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000A.cs index a2dec44f0c..48bf1c15cf 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000A.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000A.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using BizHawk.Common; @@ -20,8 +19,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge public Mapper000A(IList newData) { - _rom = new int[0x2000]; - Array.Copy(newData.First(), _rom, 0x2000); + if (newData[0] is not { Length: >= 0x2000 } first) throw new ArgumentException(paramName: nameof(newData), message: "first array must have 0x2000 elements"); + _rom = first.AsSpan(start: 0, length: 0x2000).ToArray(); pinGame = true; } diff --git a/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper002B.cs b/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper002B.cs index 4bc455c97a..8fcb735da1 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper002B.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper002B.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using BizHawk.Common; @@ -21,7 +20,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge pinExRom = false; pinGame = true; _rom = new int[0x40000]; - Array.Copy(newData.First(), _rom, 0x2000); + if (newData[0] is not { Length: >= 0x2000 } first) throw new ArgumentException(paramName: nameof(newData), message: "first array must have 0x2000 elements"); + first.AsSpan(start: 0, length: 0x2000).CopyTo(_rom); pinGame = true; for (var i = 0; i < newData.Count; i++) {