diff --git a/src/BizHawk.Client.Common/Api/Classes/EmulationApi.cs b/src/BizHawk.Client.Common/Api/Classes/EmulationApi.cs index 59038831bd..0483759ac7 100644 --- a/src/BizHawk.Client.Common/Api/Classes/EmulationApi.cs +++ b/src/BizHawk.Client.Common/Api/Classes/EmulationApi.cs @@ -111,7 +111,7 @@ namespace BizHawk.Client.Common return null; } - public Dictionary GetRegisters() + public IReadOnlyDictionary GetRegisters() { try { diff --git a/src/BizHawk.Client.Common/Api/Classes/MovieApi.cs b/src/BizHawk.Client.Common/Api/Classes/MovieApi.cs index 1e53078941..ce13a0f3b1 100644 --- a/src/BizHawk.Client.Common/Api/Classes/MovieApi.cs +++ b/src/BizHawk.Client.Common/Api/Classes/MovieApi.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using BizHawk.Common; using BizHawk.Emulation.Common; namespace BizHawk.Client.Common @@ -73,23 +72,16 @@ namespace BizHawk.Client.Common _movieSession.Movie.Save(); } - public Dictionary GetHeader() - { - var table = new Dictionary(); - if (_movieSession.Movie.NotActive()) - { - return table; - } - foreach (var (k, v) in _movieSession.Movie.HeaderEntries) table[k] = v; - return table; - } + public IReadOnlyDictionary GetHeader() + => _movieSession.Movie.NotActive() + ? new Dictionary() + : _movieSession.Movie.HeaderEntries.ToDictionary(static kvp => kvp.Key, static kvp => kvp.Value); - public List GetComments() => _movieSession.Movie.Comments.ToList(); + public IReadOnlyList GetComments() + => _movieSession.Movie.Comments.ToList(); - public List GetSubtitles() => - _movieSession.Movie.Subtitles - .Select(s => s.ToString()) - .ToList(); + public IReadOnlyList GetSubtitles() + => _movieSession.Movie.Subtitles.Select(static s => s.ToString()).ToList(); public string Filename() => _movieSession.Movie.Filename; diff --git a/src/BizHawk.Client.Common/Api/Interfaces/IEmulationApi.cs b/src/BizHawk.Client.Common/Api/Interfaces/IEmulationApi.cs index 77e7b11e43..437e35eead 100644 --- a/src/BizHawk.Client.Common/Api/Interfaces/IEmulationApi.cs +++ b/src/BizHawk.Client.Common/Api/Interfaces/IEmulationApi.cs @@ -13,7 +13,7 @@ namespace BizHawk.Client.Common int FrameCount(); object Disassemble(uint pc, string name = ""); ulong? GetRegister(string name); - Dictionary GetRegisters(); + IReadOnlyDictionary GetRegisters(); void SetRegister(string register, int value); long TotalExecutedCycles(); string GetSystemId(); diff --git a/src/BizHawk.Client.Common/Api/Interfaces/IMovieApi.cs b/src/BizHawk.Client.Common/Api/Interfaces/IMovieApi.cs index bed563b7d7..6538bfbd4b 100644 --- a/src/BizHawk.Client.Common/Api/Interfaces/IMovieApi.cs +++ b/src/BizHawk.Client.Common/Api/Interfaces/IMovieApi.cs @@ -21,8 +21,8 @@ namespace BizHawk.Client.Common void SetRerecordCounting(bool counting); void Stop(); double GetFps(); - Dictionary GetHeader(); - List GetComments(); - List GetSubtitles(); + IReadOnlyDictionary GetHeader(); + IReadOnlyList GetComments(); + IReadOnlyList GetSubtitles(); } } diff --git a/src/BizHawk.Client.Common/lua/NLuaTableHelper.cs b/src/BizHawk.Client.Common/lua/NLuaTableHelper.cs index d066f5006b..9a6b8ce211 100644 --- a/src/BizHawk.Client.Common/lua/NLuaTableHelper.cs +++ b/src/BizHawk.Client.Common/lua/NLuaTableHelper.cs @@ -36,7 +36,7 @@ namespace BizHawk.Client.Common public IEnumerable EnumerateValues(LuaTable table) => table.Values.Cast(); - public LuaTable ListToTable(IList list, int indexFrom = 1) + public LuaTable ListToTable(IReadOnlyList list, int indexFrom = 1) { var table = _lua.NewTable(); for (int i = 0, l = list.Count; i != l; i++) table[indexFrom + i] = list[i];