Enable CA1065 and fix noncompliance
"Do not raise exceptions in unexpected locations" (e.g. static ctors and `IDisposable.Dispose`, but also prop getters which is a bit annoying)
This commit is contained in:
parent
2ccddbd99e
commit
fcb5d0d273
|
@ -59,6 +59,8 @@ dotnet_diagnostic.BHI3300.severity = error
|
||||||
|
|
||||||
# Do not declare static members on generic types
|
# Do not declare static members on generic types
|
||||||
dotnet_diagnostic.CA1000.severity = error
|
dotnet_diagnostic.CA1000.severity = error
|
||||||
|
# Do not raise exceptions in unexpected locations
|
||||||
|
dotnet_diagnostic.CA1065.severity = warning
|
||||||
|
|
||||||
## Globalization rules
|
## Globalization rules
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ namespace BizHawk.Bizware.Graphics
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SDL2OpenGLContext : IDisposable
|
public class SDL2OpenGLContext : IDisposable
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CA1065 // not sure how else to handle failure other than throwing with a good message
|
||||||
static SDL2OpenGLContext()
|
static SDL2OpenGLContext()
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.IsUnixHost)
|
if (OSTailoredCode.IsUnixHost)
|
||||||
|
@ -101,6 +102,7 @@ namespace BizHawk.Bizware.Graphics
|
||||||
// it's not needed and can be dangerous in some rare cases
|
// 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);
|
SDL_SetHintWithPriority(SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP, "0", SDL_HintPriority.SDL_HINT_OVERRIDE);
|
||||||
}
|
}
|
||||||
|
#pragma warning restore CA1065
|
||||||
|
|
||||||
#if DEBUG_OPENGL
|
#if DEBUG_OPENGL
|
||||||
private static readonly DebugProc _debugProc = DebugCallback;
|
private static readonly DebugProc _debugProc = DebugCallback;
|
||||||
|
|
|
@ -48,7 +48,9 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains";
|
var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains";
|
||||||
LogCallback(error);
|
LogCallback(error);
|
||||||
|
#pragma warning disable CA1065 // yes, really throw
|
||||||
throw new NotImplementedException(error);
|
throw new NotImplementedException(error);
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
return MemoryDomainCore;
|
return MemoryDomainCore;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +64,9 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains";
|
var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains";
|
||||||
LogCallback(error);
|
LogCallback(error);
|
||||||
|
#pragma warning disable CA1065 // yes, really throw
|
||||||
throw new NotImplementedException(error);
|
throw new NotImplementedException(error);
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
return MemoryDomainCore.MainMemory.Name;
|
return MemoryDomainCore.MainMemory.Name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (DesignMode) return PLACEHOLDER_TITLE;
|
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");
|
throw new NotImplementedException("you have to implement this; the Designer prevents this from being an abstract method");
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,9 @@ namespace BizHawk.Common.PathExtensions
|
||||||
{
|
{
|
||||||
var dirPath = AppContext.BaseDirectory;
|
var dirPath = AppContext.BaseDirectory;
|
||||||
DataDirectoryPath = ExeDirectoryPath = string.IsNullOrEmpty(dirPath)
|
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")
|
? throw new Exception("failed to get location of executable, very bad things must have happened")
|
||||||
|
#pragma warning restore CA1065
|
||||||
: dirPath.RemoveSuffix('\\');
|
: dirPath.RemoveSuffix('\\');
|
||||||
DllDirectoryPath = Path.Combine(ExeDirectoryPath, "dll");
|
DllDirectoryPath = Path.Combine(ExeDirectoryPath, "dll");
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,9 @@ namespace BizHawk.Common
|
||||||
if (PageSize != Environment.SystemPageSize)
|
if (PageSize != Environment.SystemPageSize)
|
||||||
{
|
{
|
||||||
// We can do it, but we'll have to change up some waterbox stuff
|
// 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");
|
throw new InvalidOperationException("Wrong page size");
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,8 @@ namespace BizHawk.Emulation.Common
|
||||||
public void Step(StepType type) => throw new NotImplementedException();
|
public void Step(StepType type) => throw new NotImplementedException();
|
||||||
|
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
public long TotalExecutedCycles => throw new NotImplementedException();
|
public long TotalExecutedCycles => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,6 +146,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
|
||||||
private const byte Rts = 0x60;
|
private const byte Rts = 0x60;
|
||||||
private const byte JsrSize = 3;
|
private const byte JsrSize = 3;
|
||||||
|
|
||||||
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
public IMemoryCallbackSystem MemoryCallbacks => throw new NotImplementedException();
|
public IMemoryCallbackSystem MemoryCallbacks => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,9 @@ namespace BizHawk.Emulation.Cores.Atari.Jaguar
|
||||||
|
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
public long TotalExecutedCycles
|
public long TotalExecutedCycles
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
|
|
||||||
public IMemoryCallbackSystem MemoryCallbacks => _memoryCallbacks;
|
public IMemoryCallbackSystem MemoryCallbacks => _memoryCallbacks;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,9 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
|
||||||
public IInputCallbackSystem InputCallbacks
|
public IInputCallbackSystem InputCallbacks
|
||||||
{
|
{
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
get => throw new NotImplementedException();
|
get => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,9 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
public IInputCallbackSystem InputCallbacks
|
public IInputCallbackSystem InputCallbacks
|
||||||
{
|
{
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
get => throw new NotImplementedException();
|
get => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _lagCount = 0;
|
private int _lagCount = 0;
|
||||||
|
|
|
@ -46,12 +46,16 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Ares64
|
||||||
public void SetCpuRegister(string register, int value) => throw new NotImplementedException();
|
public void SetCpuRegister(string register, int value) => throw new NotImplementedException();
|
||||||
|
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
public IMemoryCallbackSystem MemoryCallbacks => throw new NotImplementedException();
|
public IMemoryCallbackSystem MemoryCallbacks => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
|
|
||||||
public bool CanStep(StepType type) => false;
|
public bool CanStep(StepType type) => false;
|
||||||
|
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
public long TotalExecutedCycles => throw new NotImplementedException();
|
public long TotalExecutedCycles => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
|
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
public void Step(StepType type) => throw new NotImplementedException();
|
public void Step(StepType type) => throw new NotImplementedException();
|
||||||
|
|
|
@ -96,7 +96,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
||||||
}
|
}
|
||||||
|
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
public long TotalExecutedCycles => throw new NotImplementedException();
|
public long TotalExecutedCycles => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
|
|
||||||
public void Step(StepType type)
|
public void Step(StepType type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,10 +34,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
||||||
public IMemoryCallbackSystem MemoryCallbacks
|
public IMemoryCallbackSystem MemoryCallbacks
|
||||||
{
|
{
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
get => throw new NotImplementedException();
|
get => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
|
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
public long TotalExecutedCycles => throw new NotImplementedException();
|
public long TotalExecutedCycles => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
||||||
public IInputCallbackSystem InputCallbacks
|
public IInputCallbackSystem InputCallbacks
|
||||||
{
|
{
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
get => throw new NotImplementedException();
|
get => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
||||||
{
|
{
|
||||||
if (sizeof(CommStruct) != 368)
|
if (sizeof(CommStruct) != 368)
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CA1065 // yes, really throw
|
||||||
throw new InvalidOperationException("sizeof(comm)");
|
throw new InvalidOperationException("sizeof(comm)");
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
||||||
}
|
}
|
||||||
|
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
public long TotalExecutedCycles => throw new NotImplementedException();
|
public long TotalExecutedCycles => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
||||||
return _memoryCallbacks;
|
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();
|
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();
|
public void Step(StepType type) => throw new NotImplementedException();
|
||||||
|
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
public long TotalExecutedCycles => throw new NotImplementedException();
|
public long TotalExecutedCycles => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
|
|
||||||
private readonly MemoryCallbackSystem _memoryCallbacks = new([ "M68K BUS" ]);
|
private readonly MemoryCallbackSystem _memoryCallbacks = new([ "M68K BUS" ]);
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,9 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
||||||
public void Step(StepType type) => throw new NotImplementedException();
|
public void Step(StepType type) => throw new NotImplementedException();
|
||||||
|
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
public long TotalExecutedCycles => throw new NotImplementedException();
|
public long TotalExecutedCycles => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
|
|
||||||
private OctoshockDll.ShockCallback_Mem mem_cb;
|
private OctoshockDll.ShockCallback_Mem mem_cb;
|
||||||
|
|
||||||
|
|
|
@ -874,7 +874,9 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
||||||
public IInputCallbackSystem InputCallbacks
|
public IInputCallbackSystem InputCallbacks
|
||||||
{
|
{
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
get => throw new NotImplementedException();
|
get => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DeterministicEmulation => true;
|
public bool DeterministicEmulation => true;
|
||||||
|
|
|
@ -129,7 +129,9 @@ namespace BizHawk.Emulation.Cores.WonderSwan
|
||||||
public void Step(StepType type) => throw new NotImplementedException();
|
public void Step(StepType type) => throw new NotImplementedException();
|
||||||
|
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
public long TotalExecutedCycles => throw new NotImplementedException();
|
public long TotalExecutedCycles => throw new NotImplementedException();
|
||||||
|
#pragma warning restore CA1065
|
||||||
|
|
||||||
private BizSwan.MemoryCallback ReadCallbackD;
|
private BizSwan.MemoryCallback ReadCallbackD;
|
||||||
private BizSwan.MemoryCallback WriteCallbackD;
|
private BizSwan.MemoryCallback WriteCallbackD;
|
||||||
|
|
|
@ -14,7 +14,9 @@ namespace BizHawk.Emulation.Cores.Libretro
|
||||||
public bool IsLagFrame { get; set; }
|
public bool IsLagFrame { get; set; }
|
||||||
|
|
||||||
[FeatureNotImplemented]
|
[FeatureNotImplemented]
|
||||||
|
#pragma warning disable CA1065 // convention for [FeatureNotImplemented] is to throw NIE
|
||||||
public IInputCallbackSystem InputCallbacks => throw new NotImplementedException();
|
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[] _joypad0States = new short[(int)RETRO_DEVICE_ID_JOYPAD.LAST];
|
||||||
private readonly short[] _joypad1States = new short[(int)RETRO_DEVICE_ID_JOYPAD.LAST];
|
private readonly short[] _joypad1States = new short[(int)RETRO_DEVICE_ID_JOYPAD.LAST];
|
||||||
|
|
Loading…
Reference in New Issue