diff --git a/.global.editorconfig.ini b/.global.editorconfig.ini index b50d511f22..1068bb1e79 100644 --- a/.global.editorconfig.ini +++ b/.global.editorconfig.ini @@ -59,6 +59,8 @@ dotnet_diagnostic.BHI3300.severity = error # Do not declare static members on generic types dotnet_diagnostic.CA1000.severity = error +# Do not raise exceptions in unexpected locations +dotnet_diagnostic.CA1065.severity = warning ## Globalization rules diff --git a/src/BizHawk.Bizware.Graphics/OpenGL/SDL2OpenGLContext.cs b/src/BizHawk.Bizware.Graphics/OpenGL/SDL2OpenGLContext.cs index 677fa93244..29576830e6 100644 --- a/src/BizHawk.Bizware.Graphics/OpenGL/SDL2OpenGLContext.cs +++ b/src/BizHawk.Bizware.Graphics/OpenGL/SDL2OpenGLContext.cs @@ -20,6 +20,7 @@ namespace BizHawk.Bizware.Graphics /// public class SDL2OpenGLContext : IDisposable { +#pragma warning disable CA1065 // not sure how else to handle failure other than throwing with a good message static SDL2OpenGLContext() { if (OSTailoredCode.IsUnixHost) @@ -101,6 +102,7 @@ namespace BizHawk.Bizware.Graphics // it's not needed and can be dangerous in some rare cases SDL_SetHintWithPriority(SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP, "0", SDL_HintPriority.SDL_HINT_OVERRIDE); } +#pragma warning restore CA1065 #if DEBUG_OPENGL private static readonly DebugProc _debugProc = DebugCallback; diff --git a/src/BizHawk.Client.Common/Api/Classes/MemoryApi.cs b/src/BizHawk.Client.Common/Api/Classes/MemoryApi.cs index be318cee45..9683945b31 100644 --- a/src/BizHawk.Client.Common/Api/Classes/MemoryApi.cs +++ b/src/BizHawk.Client.Common/Api/Classes/MemoryApi.cs @@ -48,7 +48,9 @@ namespace BizHawk.Client.Common { var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains"; LogCallback(error); +#pragma warning disable CA1065 // yes, really throw throw new NotImplementedException(error); +#pragma warning restore CA1065 } return MemoryDomainCore; } @@ -62,7 +64,9 @@ namespace BizHawk.Client.Common { var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains"; LogCallback(error); +#pragma warning disable CA1065 // yes, really throw throw new NotImplementedException(error); +#pragma warning restore CA1065 } return MemoryDomainCore.MainMemory.Name; } diff --git a/src/BizHawk.Client.EmuHawk/FormBase.cs b/src/BizHawk.Client.EmuHawk/FormBase.cs index e122057623..bef701765c 100644 --- a/src/BizHawk.Client.EmuHawk/FormBase.cs +++ b/src/BizHawk.Client.EmuHawk/FormBase.cs @@ -67,7 +67,9 @@ namespace BizHawk.Client.EmuHawk get { if (DesignMode) return PLACEHOLDER_TITLE; +#pragma warning disable CA1065 // yes, really throw throw new NotImplementedException("you have to implement this; the Designer prevents this from being an abstract method"); +#pragma warning restore CA1065 } } diff --git a/src/BizHawk.Common/Extensions/PathExtensions.cs b/src/BizHawk.Common/Extensions/PathExtensions.cs index ed260d0b6b..235cb8ab29 100644 --- a/src/BizHawk.Common/Extensions/PathExtensions.cs +++ b/src/BizHawk.Common/Extensions/PathExtensions.cs @@ -222,7 +222,9 @@ namespace BizHawk.Common.PathExtensions { var dirPath = AppContext.BaseDirectory; DataDirectoryPath = ExeDirectoryPath = string.IsNullOrEmpty(dirPath) +#pragma warning disable CA1065 // yes, really throw ? throw new Exception("failed to get location of executable, very bad things must have happened") +#pragma warning restore CA1065 : dirPath.RemoveSuffix('\\'); DllDirectoryPath = Path.Combine(ExeDirectoryPath, "dll"); } diff --git a/src/BizHawk.Common/MemoryBlock/MemoryBlockUtils.cs b/src/BizHawk.Common/MemoryBlock/MemoryBlockUtils.cs index ad4c93d571..6364ed5a84 100644 --- a/src/BizHawk.Common/MemoryBlock/MemoryBlockUtils.cs +++ b/src/BizHawk.Common/MemoryBlock/MemoryBlockUtils.cs @@ -52,7 +52,9 @@ namespace BizHawk.Common if (PageSize != Environment.SystemPageSize) { // We can do it, but we'll have to change up some waterbox stuff +#pragma warning disable CA1065 // yes, really throw throw new InvalidOperationException("Wrong page size"); +#pragma warning restore CA1065 } } diff --git a/src/BizHawk.Emulation.Common/Base Implementations/LinkedDebuggable.cs b/src/BizHawk.Emulation.Common/Base Implementations/LinkedDebuggable.cs index c73210adec..4dc871e174 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/LinkedDebuggable.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/LinkedDebuggable.cs @@ -53,6 +53,8 @@ namespace BizHawk.Emulation.Common public void Step(StepType type) => throw new NotImplementedException(); [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE public long TotalExecutedCycles => throw new NotImplementedException(); +#pragma warning restore CA1065 } } diff --git a/src/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.IDebuggable.cs b/src/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.IDebuggable.cs index 71abed5c10..cce922a049 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.IDebuggable.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.IDebuggable.cs @@ -146,6 +146,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial private const byte Rts = 0x60; private const byte JsrSize = 3; + [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE public IMemoryCallbackSystem MemoryCallbacks => throw new NotImplementedException(); +#pragma warning restore CA1065 } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/jaguar/VirtualJaguar.IDebuggable.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/jaguar/VirtualJaguar.IDebuggable.cs index 7cc02d3ea4..412d7998ff 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/jaguar/VirtualJaguar.IDebuggable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/jaguar/VirtualJaguar.IDebuggable.cs @@ -88,7 +88,9 @@ namespace BizHawk.Emulation.Cores.Atari.Jaguar [FeatureNotImplemented] public long TotalExecutedCycles +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE => throw new NotImplementedException(); +#pragma warning restore CA1065 public IMemoryCallbackSystem MemoryCallbacks => _memoryCallbacks; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IInputPollable.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IInputPollable.cs index 6fc585e53e..972c8e2332 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IInputPollable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IInputPollable.cs @@ -12,7 +12,9 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE get => throw new NotImplementedException(); +#pragma warning restore CA1065 } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IInputPollable.cs b/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IInputPollable.cs index 477288a222..bf9e54ed73 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IInputPollable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IInputPollable.cs @@ -19,7 +19,9 @@ namespace BizHawk.Emulation.Cores.ColecoVision public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE get => throw new NotImplementedException(); +#pragma warning restore CA1065 } private int _lagCount = 0; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Ares64/Ares64.IDebuggable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Ares64/Ares64.IDebuggable.cs index 6340f0cdf9..7134e901d5 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Ares64/Ares64.IDebuggable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Ares64/Ares64.IDebuggable.cs @@ -46,12 +46,16 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Ares64 public void SetCpuRegister(string register, int value) => throw new NotImplementedException(); [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE public IMemoryCallbackSystem MemoryCallbacks => throw new NotImplementedException(); +#pragma warning restore CA1065 public bool CanStep(StepType type) => false; [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE public long TotalExecutedCycles => throw new NotImplementedException(); +#pragma warning restore CA1065 [FeatureNotImplemented] public void Step(StepType type) => throw new NotImplementedException(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs index e3b26a7419..7c2d131620 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs @@ -96,7 +96,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 } [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE public long TotalExecutedCycles => throw new NotImplementedException(); +#pragma warning restore CA1065 public void Step(StepType type) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDebuggable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDebuggable.cs index 969f458c1e..fe0c207f3e 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDebuggable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDebuggable.cs @@ -34,10 +34,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES public IMemoryCallbackSystem MemoryCallbacks { [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE get => throw new NotImplementedException(); +#pragma warning restore CA1065 } [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE public long TotalExecutedCycles => throw new NotImplementedException(); +#pragma warning restore CA1065 } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IInputPollable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IInputPollable.cs index a7eb3fc9be..0617398d23 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IInputPollable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IInputPollable.cs @@ -10,7 +10,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE get => throw new NotImplementedException(); +#pragma warning restore CA1065 } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi.cs index 901dcd076c..c7bae8e3b4 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi.cs @@ -29,7 +29,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES { if (sizeof(CommStruct) != 368) { +#pragma warning disable CA1065 // yes, really throw throw new InvalidOperationException("sizeof(comm)"); +#pragma warning restore CA1065 } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IDebuggable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IDebuggable.cs index 8d57d19509..5f34bebffc 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IDebuggable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IDebuggable.cs @@ -62,6 +62,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES } [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE public long TotalExecutedCycles => throw new NotImplementedException(); +#pragma warning restore CA1065 } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDebuggable.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDebuggable.cs index be118a8c19..686b42b57c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDebuggable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDebuggable.cs @@ -51,7 +51,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx return _memoryCallbacks; } +#pragma warning disable CA1065 // I guess this is like a conditional [FeatureNotImplemented], for which the convention is to throw NIE throw new NotImplementedException(); +#pragma warning restore CA1065 } } @@ -61,7 +63,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx public void Step(StepType type) => throw new NotImplementedException(); [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE public long TotalExecutedCycles => throw new NotImplementedException(); +#pragma warning restore CA1065 private readonly MemoryCallbackSystem _memoryCallbacks = new([ "M68K BUS" ]); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDebuggable.cs b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDebuggable.cs index 8cb60cfb06..7738733571 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDebuggable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDebuggable.cs @@ -85,7 +85,9 @@ namespace BizHawk.Emulation.Cores.Sony.PSX public void Step(StepType type) => throw new NotImplementedException(); [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE public long TotalExecutedCycles => throw new NotImplementedException(); +#pragma warning restore CA1065 private OctoshockDll.ShockCallback_Mem mem_cb; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index 4da4f1382d..5a6d547160 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -874,7 +874,9 @@ namespace BizHawk.Emulation.Cores.Sony.PSX public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE get => throw new NotImplementedException(); +#pragma warning restore CA1065 } public bool DeterministicEmulation => true; diff --git a/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs index d2bbc05e25..fe77008e8f 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs @@ -129,7 +129,9 @@ namespace BizHawk.Emulation.Cores.WonderSwan public void Step(StepType type) => throw new NotImplementedException(); [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE public long TotalExecutedCycles => throw new NotImplementedException(); +#pragma warning restore CA1065 private BizSwan.MemoryCallback ReadCallbackD; private BizSwan.MemoryCallback WriteCallbackD; diff --git a/src/BizHawk.Emulation.Cores/Libretro/Libretro.IInputPollable.cs b/src/BizHawk.Emulation.Cores/Libretro/Libretro.IInputPollable.cs index 1f8b488e23..38ccf81c8e 100644 --- a/src/BizHawk.Emulation.Cores/Libretro/Libretro.IInputPollable.cs +++ b/src/BizHawk.Emulation.Cores/Libretro/Libretro.IInputPollable.cs @@ -14,7 +14,9 @@ namespace BizHawk.Emulation.Cores.Libretro public bool IsLagFrame { get; set; } [FeatureNotImplemented] +#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE public IInputCallbackSystem InputCallbacks => throw new NotImplementedException(); +#pragma warning restore CA1065 private readonly short[] _joypad0States = new short[(int)RETRO_DEVICE_ID_JOYPAD.LAST]; private readonly short[] _joypad1States = new short[(int)RETRO_DEVICE_ID_JOYPAD.LAST];