diff --git a/src/BizHawk.Client.Common/Api/Classes/EmulationApi.cs b/src/BizHawk.Client.Common/Api/Classes/EmulationApi.cs index 7ae6b0e335..35b26b5144 100644 --- a/src/BizHawk.Client.Common/Api/Classes/EmulationApi.cs +++ b/src/BizHawk.Client.Common/Api/Classes/EmulationApi.cs @@ -1,4 +1,6 @@ -using System; +#nullable enable + +using System; using System.Collections.Generic; using System.ComponentModel; @@ -20,29 +22,29 @@ namespace BizHawk.Client.Common public sealed class EmulationApi : IEmulationApi { [RequiredService] - private IEmulator Emulator { get; set; } + private IEmulator? Emulator { get; set; } [OptionalService] - private IBoardInfo BoardInfo { get; set; } + private IBoardInfo? BoardInfo { get; set; } [OptionalService] - private IDebuggable DebuggableCore { get; set; } + private IDebuggable? DebuggableCore { get; set; } [OptionalService] - private IDisassemblable DisassemblableCore { get; set; } + private IDisassemblable? DisassemblableCore { get; set; } [OptionalService] - private IInputPollable InputPollableCore { get; set; } + private IInputPollable? InputPollableCore { get; set; } [OptionalService] - private IMemoryDomains MemoryDomains { get; set; } + private IMemoryDomains? MemoryDomains { get; set; } [OptionalService] - private IRegionable RegionableCore { get; set; } + private IRegionable? RegionableCore { get; set; } private readonly Config _config; - private readonly IGameInfo _game; + private readonly IGameInfo? _game; private readonly Action LogCallback; @@ -58,7 +60,7 @@ namespace BizHawk.Client.Common public bool ForbiddenConfigReferenceUsed { get; private set; } - public EmulationApi(Action logCallback, Config config, IGameInfo game) + public EmulationApi(Action logCallback, Config config, IGameInfo? game) { _config = config; _game = game; @@ -67,9 +69,10 @@ namespace BizHawk.Client.Common public void DisplayVsync(bool enabled) => _config.VSync = enabled; - public int FrameCount() => Emulator.Frame; + public int FrameCount() + => Emulator!.Frame; - public object Disassemble(uint pc, string name = "") + public object? Disassemble(uint pc, string? name = null) { try { @@ -77,7 +80,7 @@ namespace BizHawk.Client.Common { return new { disasm = DisassemblableCore.Disassemble( - string.IsNullOrEmpty(name) ? MemoryDomains.SystemBus : MemoryDomains[name]!, + string.IsNullOrEmpty(name) ? MemoryDomains!.SystemBus : MemoryDomains![name!]!, pc, out var l ), @@ -97,7 +100,7 @@ namespace BizHawk.Client.Common if (DebuggableCore != null) { var registers = DebuggableCore.GetCpuFlagsAndRegisters(); - return registers.TryGetValue(name, out var rv) ? rv.Value : (ulong?) null; + return registers.TryGetValue(name, out var rv) ? rv.Value : null; } } catch (NotImplementedException) {} @@ -146,7 +149,8 @@ namespace BizHawk.Client.Common return default; } - public string GetSystemId() => _game.System; + public string GetSystemId() + => _game!.System; public bool IsLagged() { @@ -182,7 +186,7 @@ namespace BizHawk.Client.Common public string GetBoardName() => BoardInfo?.BoardName ?? ""; - public object GetSettings() => Emulator switch + public object? GetSettings() => Emulator switch { GPGX gpgx => gpgx.GetSettings(), LibsnesCore snes => snes.GetSettings(), diff --git a/src/BizHawk.Client.Common/Api/Interfaces/IEmulationApi.cs b/src/BizHawk.Client.Common/Api/Interfaces/IEmulationApi.cs index f2eb833f49..760ae2fee7 100644 --- a/src/BizHawk.Client.Common/Api/Interfaces/IEmulationApi.cs +++ b/src/BizHawk.Client.Common/Api/Interfaces/IEmulationApi.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +#nullable enable + +using System.Collections.Generic; using BizHawk.Emulation.Common; @@ -8,7 +10,7 @@ namespace BizHawk.Client.Common { void DisplayVsync(bool enabled); int FrameCount(); - object Disassemble(uint pc, string name = ""); + object? Disassemble(uint pc, string? name = null); ulong? GetRegister(string name); IReadOnlyDictionary GetRegisters(); void SetRegister(string register, int value); @@ -22,7 +24,7 @@ namespace BizHawk.Client.Common void MinimizeFrameskip(bool enabled); string GetDisplayType(); string GetBoardName(); - object GetSettings(); + object? GetSettings(); PutSettingsDirtyBits PutSettings(object settings); void SetRenderPlanes(params bool[] args); }