bump AnalysisModeUsage to Recommended

fixes CA2211, CA2215, CA2241, CA2251

silence CA1816 because it's unnecessary

reduce severity of CA2201 because I like the concept but don't wanna fix them all
This commit is contained in:
Morilli 2023-06-08 20:23:53 +02:00 committed by Moritz Bender
parent 71e08e27b9
commit c10d2927ca
30 changed files with 85 additions and 77 deletions

View File

@ -24,3 +24,7 @@ dotnet_code_quality.CA1826.exclude_ordefault_methods = true
dotnet_diagnostic.CA1805.severity = silent
dotnet_diagnostic.CA1822.severity = silent
dotnet_diagnostic.CA1838.severity = suggestion
# Usage rules
dotnet_diagnostic.CA1816.severity = none
dotnet_diagnostic.CA2201.severity = suggestion

View File

@ -5,6 +5,7 @@
<AnalysisModeMaintainability>Recommended</AnalysisModeMaintainability>
<AnalysisModeReliability>Recommended</AnalysisModeReliability>
<AnalysisModePerformance>Recommended</AnalysisModePerformance>
<AnalysisModeUsage>Recommended</AnalysisModeUsage>
<CodeAnalysisRuleSet>$(MSBuildProjectDirectory)/../../Common.ruleset</CodeAnalysisRuleSet>
<ContinuousIntegrationBuild Condition=" '$(GITLAB_CI)' != '' Or '$(APPVEYOR)' != '' ">true</ContinuousIntegrationBuild>
<EnableNETAnalyzers>true</EnableNETAnalyzers>

View File

@ -295,4 +295,4 @@ namespace BizHawk.Bizware.BizwareGL
}
}
}
}
}

View File

@ -71,7 +71,7 @@ namespace BizHawk.Client.Common
{
if (!Frozen)
{
return recentlist.RemoveAll(recent => string.Compare(newFile, recent, StringComparison.OrdinalIgnoreCase) == 0) != 0; // none removed => return false
return recentlist.RemoveAll(recent => string.Equals(newFile, recent, StringComparison.OrdinalIgnoreCase)) != 0; // none removed => return false
}
return false;

View File

@ -36,14 +36,14 @@
public static class DefaultMessagePositions
{
public static MessagePosition Fps = new MessagePosition { X = 0, Y = 0 };
public static MessagePosition FrameCounter = new MessagePosition { X = 0, Y = 14 };
public static MessagePosition LagCounter = new MessagePosition { X = 0, Y = 42 };
public static MessagePosition InputDisplay = new MessagePosition { X = 0, Y = 28 };
public static MessagePosition ReRecordCounter = new MessagePosition { X = 0, Y = 56 };
public static MessagePosition Messages = new MessagePosition { X = 0, Y = 0, Anchor = MessagePosition.AnchorType.BottomLeft };
public static MessagePosition Autohold = new MessagePosition { X = 0, Y = 0, Anchor = MessagePosition.AnchorType.TopRight };
public static MessagePosition RamWatches = new MessagePosition { X = 0, Y = 70 };
public static readonly MessagePosition Fps = new MessagePosition { X = 0, Y = 0 };
public static readonly MessagePosition FrameCounter = new MessagePosition { X = 0, Y = 14 };
public static readonly MessagePosition LagCounter = new MessagePosition { X = 0, Y = 42 };
public static readonly MessagePosition InputDisplay = new MessagePosition { X = 0, Y = 28 };
public static readonly MessagePosition ReRecordCounter = new MessagePosition { X = 0, Y = 56 };
public static readonly MessagePosition Messages = new MessagePosition { X = 0, Y = 0, Anchor = MessagePosition.AnchorType.BottomLeft };
public static readonly MessagePosition Autohold = new MessagePosition { X = 0, Y = 0, Anchor = MessagePosition.AnchorType.TopRight };
public static readonly MessagePosition RamWatches = new MessagePosition { X = 0, Y = 70 };
public const int
MessagesColor = -1,

View File

@ -172,7 +172,7 @@ namespace BizHawk.Client.Common
[JsonIgnore]
internal string TempFilesFragment => this[GLOBAL, "Temp Files"].Path;
public static Lazy<IReadOnlyList<PathEntry>> Defaults = new(() => new[]
public static readonly Lazy<IReadOnlyList<PathEntry>> Defaults = new(() => new[]
{
new[] {
BaseEntryFor(GLOBAL, "."),

View File

@ -32,7 +32,7 @@ namespace BizHawk.Client.Common
return 0;
}
if (string.Compare(x.Notes, y.Notes, StringComparison.OrdinalIgnoreCase) == 0)
if (string.Equals(x.Notes, y.Notes, StringComparison.OrdinalIgnoreCase))
{
if (x.Address.Equals(y.Address))
{

View File

@ -74,8 +74,6 @@ namespace BizHawk.Client.DiscoHawk
OSTC.LinkedLibManager.FreeByPtr(lib);
}
FFmpegService.FFmpegPath = Path.Combine(PathUtils.DataDirectoryPath, "dll", OSTC.IsUnixHost ? "ffmpeg" : "ffmpeg.exe");
if (args.Length == 0)
{
using var dialog = new MainDiscoForm();

View File

@ -27,7 +27,7 @@ namespace BizHawk.Client.EmuHawk
private readonly HashSet<Control> _wantingMouseFocus = new HashSet<Control>();
public static Input Instance;
public static Input Instance { get; set; }
private readonly Thread _updateThread;

View File

@ -172,8 +172,6 @@ namespace BizHawk.Client.EmuHawk
if (initialConfig.SaveSlot is 0) initialConfig.SaveSlot = 10; //TODO remove after a while
// initialConfig should really be globalConfig as it's mutable
FFmpegService.FFmpegPath = Path.Combine(PathUtils.DataDirectoryPath, "dll", OSTC.IsUnixHost ? "ffmpeg" : "ffmpeg.exe");
StringLogUtil.DefaultToDisk = initialConfig.Movies.MoviesOnDisk;
var glInitCount = 0;

View File

@ -15,7 +15,7 @@ namespace BizHawk.Client.EmuHawk
private static readonly string _latestVersionInfoURL = "https://api.github.com/repos/TASVideos/BizHawk/releases/latest";
private static readonly TimeSpan _minimumCheckDuration = TimeSpan.FromHours(8);
public static Config GlobalConfig;
public static Config GlobalConfig { get; set; }
private static bool AutoCheckEnabled
{

View File

@ -9,7 +9,7 @@ namespace BizHawk.Client.EmuHawk
/// </remarks>
public readonly struct TAStudioPalette
{
public static TAStudioPalette Default = new(
public static readonly TAStudioPalette Default = new(
// currentFrame_FrameCol: Color.FromArgb(0xCF, 0xED, 0xFC),
currentFrame_InputLog: Color.FromArgb(0xB5, 0xE7, 0xF7),
greenZone_FrameCol: Color.FromArgb(0xDD, 0xFF, 0xDD),

View File

@ -7,6 +7,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Threading.Tasks;
using BizHawk.Common.PathExtensions;
namespace BizHawk.Common
{
@ -18,7 +19,7 @@ namespace BizHawk.Common
private const string VERSION = "ffmpeg version 4.4.1";
public static string FFmpegPath = string.Empty; // always updated in DiscoHawk.Program/EmuHawk.Program
public static string FFmpegPath => Path.Combine(PathUtils.DataDirectoryPath, "dll", OSTailoredCode.IsUnixHost ? "ffmpeg" : "ffmpeg.exe");
public static readonly string Url = OSTailoredCode.IsUnixHost ? BIN_HOST_URI_LINUX_X64 : BIN_HOST_URI_WIN_X64;
@ -155,4 +156,4 @@ namespace BizHawk.Common
}
}
}
}

View File

@ -285,7 +285,7 @@ namespace BizHawk.Common
}
/// <summary>Set this with an instance which can construct archive handlers as necessary for archive handling.</summary>
public static IFileDearchivalMethod<IHawkArchiveFile>? DearchivalMethod;
public static IFileDearchivalMethod<IHawkArchiveFile>? DearchivalMethod { get; set; }
[return: HawkFilePath]
private static string MakeCanonicalName(string root, string? member) => member == null ? root : $"{root}|{member}";

View File

@ -39,7 +39,7 @@ namespace BizHawk.Common
}
// -------------- Logging Action Configuration --------------
public static Action<string> LogAction = DefaultLogger;
public static readonly Action<string> LogAction = DefaultLogger;
// NOTEs are only logged if the domain is enabled.
// ERRORs are logged regardless.

View File

@ -4,10 +4,10 @@ namespace BizHawk.Emulation.Common
{
public static class Waves
{
public static short[] SquareWave;
public static short[] ImperfectSquareWave;
public static short[] NoiseWave;
public static short[] PeriodicWave16;
public static short[] SquareWave { get; private set; }
public static short[] ImperfectSquareWave { get; private set; }
public static short[] NoiseWave { get; private set; }
public static short[] PeriodicWave16 { get; private set; }
public static void InitWaves()
{
@ -56,4 +56,4 @@ namespace BizHawk.Emulation.Common
#endif
}
}
}
}

View File

@ -114,6 +114,8 @@ namespace BizHawk.Emulation.Common
_ctx.InUse = false;
_disposed = true;
}
base.Dispose(disposing);
}
public override bool CanRead
@ -286,6 +288,8 @@ namespace BizHawk.Emulation.Common
_ctx.InUse = false;
_disposed = true;
}
base.Dispose(disposing);
}
public override bool CanRead

View File

@ -8,21 +8,21 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
{
// registers
public static ushort PCl = 0;
public static ushort PCh = 1;
public static ushort SPl = 2;
public static ushort SPh = 3;
public static ushort A = 4;
public static ushort F = 5;
public static ushort B = 6;
public static ushort C = 7;
public static ushort D = 8;
public static ushort E = 9;
public static ushort H = 10;
public static ushort L = 11;
public static ushort W = 12;
public static ushort Z = 13;
public static ushort Aim = 14; // use this indicator for RLCA etc., since the Z flag is reset on those
public const ushort PCl = 0;
public const ushort PCh = 1;
public const ushort SPl = 2;
public const ushort SPh = 3;
public const ushort A = 4;
public const ushort F = 5;
public const ushort B = 6;
public const ushort C = 7;
public const ushort D = 8;
public const ushort E = 9;
public const ushort H = 10;
public const ushort L = 11;
public const ushort W = 12;
public const ushort Z = 13;
public const ushort Aim = 14; // use this indicator for RLCA etc., since the Z flag is reset on those
public ushort[] Regs = new ushort[14];
@ -151,4 +151,4 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
}
}
}
}
}

View File

@ -295,7 +295,7 @@ namespace BizHawk.Emulation.Cores.Components.W65816
break;
// Block Move
case 0x44: case 0x54:
pbuf = string.Format("${0:X2},${0:X2}", peek(addr + 1), peek(addr + 2));
pbuf = $"${peek(addr + 1):X2},${peek(addr + 2):X2}";
//sprintf(pbuf, "$%02X,$%02X", mem[1], mem[2]);
offset = 3;
break;
@ -494,4 +494,4 @@ namespace BizHawk.Emulation.Cores.Components.W65816
return sb.ToString();
}
}
}
}

View File

@ -171,15 +171,15 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
private IntPtr MSX_Pntr { get; set; } = IntPtr.Zero;
private byte[] MSX_core = new byte[0x28000];
public static byte[] Bios = null;
public static byte[] Basic;
private static byte[] Bios = null;
private static byte[] Basic;
// Constants
private const int BankSize = 16384;
// ROM
public static byte[] RomData;
public static byte[] RomData2;
private static byte[] RomData;
private static byte[] RomData2;
// Machine resources
private IController _controller = NullController.Instance;

View File

@ -364,7 +364,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
}
public static Dictionary<string, string> ValidFilterTypes = new Dictionary<string, string>
public static readonly Dictionary<string, string> ValidFilterTypes = new Dictionary<string, string>
{
{ "None", "None"},
{ "NTSC", "NTSC"},

View File

@ -46,12 +46,12 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
public int DMA_phase = 0;
public int DMA_phase_counter;
public static int DMA_START_UP = 0;
public static int DMA_HEADER = 1;
public static int DMA_GRAPHICS = 2;
public static int DMA_CHAR_MAP = 3;
public static int DMA_SHUTDOWN_OTHER = 4;
public static int DMA_SHUTDOWN_LAST = 5;
public const int DMA_START_UP = 0;
public const int DMA_HEADER = 1;
public const int DMA_GRAPHICS = 2;
public const int DMA_CHAR_MAP = 3;
public const int DMA_SHUTDOWN_OTHER = 4;
public const int DMA_SHUTDOWN_LAST = 5;
public int header_read_time = 8; // default for 4 byte headers (10 for 5 bytes ones)
public int graphics_read_time = 3; // depends on content of graphics header

View File

@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
public int skip;
public uint bright_int_1, bright_int_2, bright_int_3;
public static uint br = 0xFFFFFFFF;
public const uint br = 0xFFFFFFFF;
// lines to draw in a frame and vairables to go to new line
public double[] draw_lines = new double[1024 * 4 * 4];

View File

@ -15,12 +15,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
private BlipBuffer _blip_L = new BlipBuffer(15000);
private BlipBuffer _blip_R = new BlipBuffer(15000);
public static bool[] DUTY_CYCLES = { false, false, false, false, false, false, false, true,
public static readonly bool[] DUTY_CYCLES = { false, false, false, false, false, false, false, true,
true, false, false, false, false, false, false, true,
true, false, false, false, false, true, true, true,
false, true, true, true, true, true, true, false };
public static int[] DIVISOR = { 8, 16, 32, 48, 64, 80, 96, 112 };
public static readonly int[] DIVISOR = { 8, 16, 32, 48, 64, 80, 96, 112 };
public const int NR10 = 0;
public const int NR11 = 1;
@ -44,7 +44,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
public const int NR51 = 19;
public const int NR52 = 20;
public static int[] unused_bits = { 0x80, 0x3F, 0x00, 0xFF, 0xBF,
public static readonly int[] unused_bits = { 0x80, 0x3F, 0x00, 0xFF, 0xBF,
0x3F, 0x00, 0xFF, 0xBF,
0x7F, 0xFF, 0x9F, 0xFF, 0xBF,
0xFF, 0x00, 0x00, 0xBF,
@ -1249,4 +1249,4 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
_blip_R = null;
}
}
}
}

View File

@ -41,6 +41,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
},
_settings.RgbdsSyntax,
out _).PadRight(36),
#pragma warning disable CA2241
registerInfo: string.Format(
"A:{3:x2} F:{8:x2} B:{4:x2} C:{5:x2} D:{6:x2} E:{7:x2} H:{9:x2} L:{10:x2} LY:{13:x2} SP:{2:x2} {11} Cy:{0}",
(ulong)s[0] + _cycleCount,
@ -57,6 +58,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
s[11] != 0 ? "prefetched" : "",
s[12] & 0xffffff, // unused (this is the opcode)
s[13] & 0xff)));
#pragma warning restore CA2241
}
}
}

View File

@ -187,9 +187,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return nes.Board.PeekPPU(addr);
}
public static int PPU_PHASE_VBL = 0;
public static int PPU_PHASE_BG = 1;
public static int PPU_PHASE_OBJ = 2;
public const int PPU_PHASE_VBL = 0;
public const int PPU_PHASE_BG = 1;
public const int PPU_PHASE_OBJ = 2;
public int ppuphase;

View File

@ -52,7 +52,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
private const int SHIFT = 2;
public static byte[,] FCEUX_Standard =
public static readonly byte[,] FCEUX_Standard =
{
{ 0x1D<<SHIFT, 0x1D<<SHIFT, 0x1D<<SHIFT }, /* Value 0 */
{ 0x09<<SHIFT, 0x06<<SHIFT, 0x23<<SHIFT }, /* Value 1 */
@ -120,7 +120,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{ 0x00<<SHIFT, 0x00<<SHIFT, 0x00<<SHIFT }, /* Value 63 */
};
public static byte[,] QuickNESPalette =
public static readonly byte[,] QuickNESPalette =
{
{102, 102, 102},
{0, 42, 136},
@ -188,7 +188,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{0, 0, 0},
};
public static byte[,] palette_2c03_2c05 =
public static readonly byte[,] palette_2c03_2c05 =
{
{3<<5, 3<<5, 3<<5},
{0<<5, 1<<5, 4<<5},
@ -256,7 +256,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{0<<5, 0<<5, 0<<5},
};
public static byte[,] palette_2c04_001 =
public static readonly byte[,] palette_2c04_001 =
{
{7<<5, 5<<5, 5<<5},
{6<<5, 3<<5, 7<<5},
@ -324,7 +324,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{4<<5, 7<<5, 3<<5},
};
public static byte[,] palette_2c04_002 =
public static readonly byte[,] palette_2c04_002 =
{
{0<<5, 0<<5, 0<<5},
{7<<5, 5<<5, 0<<5},
@ -392,7 +392,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{4<<5, 4<<5, 4<<5},
};
public static byte[,] palette_2c04_003 =
public static readonly byte[,] palette_2c04_003 =
{
{5<<5, 0<<5, 7<<5},
{7<<5, 3<<5, 7<<5},
@ -460,7 +460,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{0<<5, 2<<5, 2<<5},
};
public static byte[,] palette_2c04_004 =
public static readonly byte[,] palette_2c04_004 =
{
{4<<5, 3<<5, 0<<5},
{3<<5, 2<<5, 6<<5},

View File

@ -138,7 +138,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
return ret;
}
public static Size[,] ObjSizes =
public static readonly Size[,] ObjSizes =
{
{ new(8,8), new(16,16) },
{ new(8,8), new(32,32) },

View File

@ -85,17 +85,17 @@
public static class BIZCOLOR
{
public static int[] palette = GenLUT(ColorType.BizHawk);
public static readonly int[] palette = GenLUT(ColorType.BizHawk);
}
public static class SNES9XCOLOR
{
public static int[] palette = GenLUT(ColorType.Snes9x);
public static readonly int[] palette = GenLUT(ColorType.Snes9x);
}
public static class BSNESCOLOR
{
public static int[] palette = GenLUT(ColorType.BSNES);
public static readonly int[] palette = GenLUT(ColorType.BSNES);
}
public static int[] GetLUT(ColorType t)

View File

@ -482,7 +482,7 @@ namespace BizHawk.Emulation.DiscSystem
var (dir, fileNoExt, _) = aFile.MDSPath.SplitPathToDirFileAndExt();
if (f.FilenameOffset == 0 ||
string.Compare(fileName, "*.mdf", StringComparison.OrdinalIgnoreCase) == 0)
string.Equals(fileName, "*.mdf", StringComparison.OrdinalIgnoreCase))
{
fileName = $@"{dir}\{fileNoExt}.mdf";
}