Re-enable MA0020 and fix noncompliance
This commit is contained in:
parent
65ffa3fc2e
commit
a1fe557d31
|
@ -183,7 +183,7 @@
|
|||
<Rule Id="MA0019" Action="Error" />
|
||||
|
||||
<!-- Use direct methods instead of LINQ methods -->
|
||||
<Rule Id="MA0020" Action="Hidden" />
|
||||
<Rule Id="MA0020" Action="Error" />
|
||||
|
||||
<!-- Use StringComparer.GetHashCode instead of string.GetHashCode -->
|
||||
<Rule Id="MA0021" Action="Hidden" />
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace BizHawk.SrcGen.ReflectionCache
|
|||
// black magic wizardry to find common prefix https://stackoverflow.com/a/35081977
|
||||
var ns = new string(_namespaces[0]
|
||||
.Substring(0, _namespaces.Min(s => s.Length))
|
||||
.TakeWhile((c, i) => _namespaces.All(s => s[i] == c))
|
||||
.TakeWhile((c, i) => _namespaces.TrueForAll(s => s[i] == c))
|
||||
.ToArray());
|
||||
return ns[ns.Length - 1] == '.' ? ns.Substring(0, ns.Length - 1) : ns; // trim trailing '.' (can't use BizHawk.Common from Source Generators)
|
||||
}
|
||||
|
|
|
@ -234,9 +234,7 @@ namespace BizHawk.DATTool
|
|||
{
|
||||
"alpha", "beta", "preview", "pre-release", "proto"
|
||||
};
|
||||
|
||||
bool b = DS.Any(s.Contains);
|
||||
return b;
|
||||
return DS.Exists(s.Contains);
|
||||
}
|
||||
|
||||
public static bool IsCopyrightStatus(string s)
|
||||
|
@ -245,9 +243,7 @@ namespace BizHawk.DATTool
|
|||
{
|
||||
"CW", "CW-R", "FW", "GW", "GW-R", "LW", "PD", "SW", "SW-R"
|
||||
};
|
||||
|
||||
bool b = CS.Any(s.Contains);
|
||||
return b;
|
||||
return CS.Exists(s.Contains);
|
||||
}
|
||||
|
||||
public static bool IsLanguageFlag(string s)
|
||||
|
@ -270,7 +266,7 @@ namespace BizHawk.DATTool
|
|||
}
|
||||
}
|
||||
|
||||
//b = LC.Any(s.Contains);
|
||||
// b = LC.Exists(s.Contains);
|
||||
}
|
||||
|
||||
return b;
|
||||
|
@ -297,7 +293,7 @@ namespace BizHawk.DATTool
|
|||
}
|
||||
}
|
||||
|
||||
//b = CC.Any(s.Contains);
|
||||
// b = CC.Exists(s.Contains);
|
||||
}
|
||||
|
||||
return b;
|
||||
|
|
|
@ -284,9 +284,7 @@ namespace BizHawk.DATTool
|
|||
{
|
||||
"alpha", "beta", "preview", "pre-release", "proto"
|
||||
};
|
||||
|
||||
bool b = DS.Any(s.Contains);
|
||||
return b;
|
||||
return DS.Exists(s.Contains);
|
||||
}
|
||||
|
||||
public static bool IsCopyrightStatus(string s)
|
||||
|
@ -295,9 +293,7 @@ namespace BizHawk.DATTool
|
|||
{
|
||||
"CW", "CW-R", "FW", "GW", "GW-R", "LW", "PD", "SW", "SW-R"
|
||||
};
|
||||
|
||||
bool b = CS.Any(s.Contains);
|
||||
return b;
|
||||
return CS.Exists(s.Contains);
|
||||
}
|
||||
|
||||
public static bool IsLanguageFlag(string s)
|
||||
|
@ -323,7 +319,7 @@ namespace BizHawk.DATTool
|
|||
}
|
||||
}
|
||||
|
||||
//b = LC.Any(s.Contains);
|
||||
// b = LC.Exists(s.Contains);
|
||||
}
|
||||
|
||||
return b;
|
||||
|
@ -353,7 +349,7 @@ namespace BizHawk.DATTool
|
|||
}
|
||||
}
|
||||
|
||||
//b = CC.Any(s.Contains);
|
||||
// b = CC.Exists(s.Contains);
|
||||
}
|
||||
|
||||
return b;
|
||||
|
|
Binary file not shown.
|
@ -44,11 +44,8 @@ namespace BizHawk.Client.Common
|
|||
public bool this[string button] => IsPressed(button);
|
||||
|
||||
// Looks for bindings which are activated by the supplied physical button.
|
||||
public List<string> SearchBindings(string button) =>
|
||||
_bindings
|
||||
.Where(b => b.Value.Any(v => v == button))
|
||||
.Select(b => b.Key)
|
||||
.ToList();
|
||||
public List<string> SearchBindings(string button)
|
||||
=> _bindings.Where(b => b.Value.Contains(button)).Select(static b => b.Key).ToList();
|
||||
|
||||
// Searches bindings for the controller and returns true if this binding is mapped somewhere in this controller
|
||||
public bool HasBinding(string button) =>
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private PathEntry TryGetDebugPath(string system, string type)
|
||||
{
|
||||
if (Paths.Any(p => p.IsSystem(system)))
|
||||
if (Paths.Exists(p => p.IsSystem(system)))
|
||||
{
|
||||
// we have the system, but not the type. don't attempt to add an unknown type
|
||||
return null;
|
||||
|
@ -144,7 +144,7 @@ namespace BizHawk.Client.Common
|
|||
// Add missing entries
|
||||
foreach (var defaultPath in Defaults.Value)
|
||||
{
|
||||
if (!Paths.Any(p => p.System == defaultPath.System && p.Type == defaultPath.Type)) Paths.Add(defaultPath);
|
||||
if (!Paths.Exists(p => p.System == defaultPath.System && p.Type == defaultPath.Type)) Paths.Add(defaultPath);
|
||||
}
|
||||
|
||||
var entriesToRemove = new List<PathEntry>();
|
||||
|
|
|
@ -199,13 +199,7 @@ namespace BizHawk.Client.Common
|
|||
UndoIndex--;
|
||||
|
||||
_recordingBatch = false;
|
||||
|
||||
if (batch.All(a => a.GetType() == typeof(MovieActionMarker)))
|
||||
{
|
||||
return _movie.InputLogLength;
|
||||
}
|
||||
|
||||
return PreviousUndoFrame;
|
||||
return batch.TrueForAll(static a => a is MovieActionMarker) ? _movie.InputLogLength : PreviousUndoFrame;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -227,13 +221,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
_recordingBatch = false;
|
||||
|
||||
if (batch.All(a => a.GetType() == typeof(MovieActionMarker)))
|
||||
{
|
||||
return _movie.InputLogLength;
|
||||
}
|
||||
|
||||
return PreviousRedoFrame;
|
||||
return batch.TrueForAll(static a => a is MovieActionMarker) ? _movie.InputLogLength : PreviousRedoFrame;
|
||||
}
|
||||
|
||||
public bool CanUndo => UndoIndex > -1;
|
||||
|
@ -511,7 +499,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public class MovieActionMarker : IMovieAction
|
||||
public sealed class MovieActionMarker : IMovieAction
|
||||
{
|
||||
public int FirstFrame { get; }
|
||||
public int LastFrame { get; }
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace BizHawk.Client.Common
|
|||
public int ActiveCount => _cheatList.Count(c => c.Enabled);
|
||||
|
||||
public bool AnyActive
|
||||
=> _cheatList.Any(static c => c.Enabled);
|
||||
=> _cheatList.Exists(static c => c.Enabled);
|
||||
|
||||
public bool Changes
|
||||
{
|
||||
|
@ -144,7 +144,7 @@ namespace BizHawk.Client.Common
|
|||
public void Insert(int index, Cheat cheat)
|
||||
{
|
||||
cheat.Changed += CheatChanged;
|
||||
if (_cheatList.Any(c => c.Domain == cheat.Domain && c.Address == cheat.Address))
|
||||
if (_cheatList.Exists(c => c.Domain == cheat.Domain && c.Address == cheat.Address))
|
||||
{
|
||||
_cheatList.First(c => c.Domain == cheat.Domain && c.Address == cheat.Address).Enable();
|
||||
}
|
||||
|
@ -183,9 +183,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
public bool Contains(Cheat cheat)
|
||||
{
|
||||
return _cheatList.Any(c => c == cheat);
|
||||
}
|
||||
=> _cheatList.Exists(c => c == cheat);
|
||||
|
||||
public void CopyTo(Cheat[] array, int arrayIndex)
|
||||
{
|
||||
|
@ -227,13 +225,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
public bool IsActive(MemoryDomain domain, long address)
|
||||
{
|
||||
return _cheatList.Any(cheat =>
|
||||
!cheat.IsSeparator &&
|
||||
cheat.Enabled &&
|
||||
cheat.Domain == domain
|
||||
&& cheat.Contains(address));
|
||||
}
|
||||
=> _cheatList.Exists(cheat => !cheat.IsSeparator && cheat.Enabled && cheat.Domain == domain && cheat.Contains(address));
|
||||
|
||||
public void SaveOnClose()
|
||||
{
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
Functions.Add(new FunctionInfo(method, service));
|
||||
}
|
||||
Complete = Functions.All(f => f.Complete);
|
||||
Complete = Functions.TrueForAll(static f => f.Complete);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -310,7 +310,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
var cheats = CheatList.Where(static c => !c.IsSeparator).ToList();
|
||||
if (cheats.Count is 0) break;
|
||||
var firstWasEnabled = cheats[0].Enabled;
|
||||
var kind = cheats.All(c => c.Enabled == firstWasEnabled)
|
||||
var kind = cheats.TrueForAll(c => c.Enabled == firstWasEnabled)
|
||||
? firstWasEnabled
|
||||
? "off"
|
||||
: "on"
|
||||
|
|
|
@ -1184,10 +1184,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
hotkeyCoalescer.Receive(ie);
|
||||
|
||||
// Check for hotkeys that may not be handled through CheckHotkey() method, reject controller input mapped to these
|
||||
if (!triggers.Any(IsInternalHotkey))
|
||||
{
|
||||
finalHostController.Receive(ie);
|
||||
}
|
||||
if (!triggers.Exists(IsInternalHotkey)) finalHostController.Receive(ie);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -161,7 +161,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
.Select(tuple => tuple.SysID)
|
||||
.Distinct().ToList();
|
||||
releasedCoreSysIDs.Add(VSystemID.Raw.Libretro); // core not actually marked as released, but we still want to show it
|
||||
systems.RemoveAll(tuple => !releasedCoreSysIDs.Any(sysID => PathEntryCollection.InGroup(sysID, tuple.SysGroup)));
|
||||
systems.RemoveAll(tuple => !releasedCoreSysIDs.Exists(sysID => PathEntryCollection.InGroup(sysID, tuple.SysGroup)));
|
||||
}
|
||||
foreach (var (sys, dispName) in systems) AddTabPageForSystem(sys, dispName);
|
||||
|
||||
|
|
|
@ -162,12 +162,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void Cheats_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Hack for previous config settings
|
||||
if (Settings.Columns.Any(c => string.IsNullOrWhiteSpace(c.Text)))
|
||||
{
|
||||
Settings = new CheatsSettings();
|
||||
}
|
||||
|
||||
if (Settings.Columns.Exists(static c => string.IsNullOrWhiteSpace(c.Text))) Settings = new(); //HACK for previous config settings
|
||||
CheatEditor.MemoryDomains = Core;
|
||||
LoadConfigSettings();
|
||||
CheatsMenu.Items.Add(CheatListView.ToColumnsMenu(ColumnToggleCallback));
|
||||
|
|
|
@ -157,11 +157,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void LuaConsole_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Hack for previous config settings
|
||||
if (Settings.Columns.Any(c => c.Text == null))
|
||||
{
|
||||
Settings = new LuaConsoleSettings();
|
||||
}
|
||||
if (Settings.Columns.Exists(static c => c.Text is null)) Settings = new(); //HACK for previous config settings
|
||||
|
||||
if (Config.RecentLuaSession.AutoLoad && !Config.RecentLuaSession.Empty)
|
||||
{
|
||||
|
|
|
@ -211,10 +211,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
throw new Exception("Xml Filename can not be blank");
|
||||
}
|
||||
|
||||
if (names.Any(string.IsNullOrWhiteSpace))
|
||||
{
|
||||
throw new Exception("Rom Names can not be blank");
|
||||
}
|
||||
if (names.Exists(string.IsNullOrWhiteSpace)) throw new Exception("Rom Names can not be blank");
|
||||
|
||||
var system = SystemDropDown.SelectedItem?.ToString();
|
||||
|
||||
|
|
|
@ -465,14 +465,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// </summary>
|
||||
/// <typeparam name="T">Type of tool to check</typeparam>
|
||||
public bool Has<T>() where T : IToolForm
|
||||
{
|
||||
return _tools.Any(t => t is T && t.IsActive);
|
||||
}
|
||||
=> _tools.Exists(static t => t is T && t.IsActive);
|
||||
|
||||
/// <returns><see langword="true"/> iff a tool of the given <paramref name="toolType"/> is <see cref="IToolForm.IsActive">active</see></returns>
|
||||
public bool Has(Type toolType)
|
||||
=> typeof(IToolForm).IsAssignableFrom(toolType)
|
||||
&& _tools.Any(t => toolType.IsInstanceOfType(t) && t.IsActive);
|
||||
&& _tools.Exists(t => toolType.IsInstanceOfType(t) && t.IsActive);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of T, or creates and returns a new instance
|
||||
|
|
|
@ -139,11 +139,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void RamSearch_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Hack for previous config settings
|
||||
if (Settings.Columns.Any(c => string.IsNullOrWhiteSpace(c.Text)))
|
||||
{
|
||||
Settings = new RamSearchSettings();
|
||||
}
|
||||
if (Settings.Columns.Exists(static c => string.IsNullOrWhiteSpace(c.Text))) Settings = new(); //HACK for previous config settings
|
||||
|
||||
RamSearchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback));
|
||||
|
||||
|
|
|
@ -1015,12 +1015,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void RamWatch_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Hack for previous config settings
|
||||
if (Settings.Columns.Any(c => string.IsNullOrWhiteSpace(c.Text)))
|
||||
{
|
||||
Settings = new RamWatchSettings();
|
||||
}
|
||||
|
||||
if (Settings.Columns.Exists(static c => string.IsNullOrWhiteSpace(c.Text))) Settings = new(); //HACK for previous config settings
|
||||
_watches = new WatchList(MemoryDomains, Emu.SystemId);
|
||||
LoadConfigSettings();
|
||||
RamWatchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback));
|
||||
|
|
|
@ -173,22 +173,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (Watches.Count > 1)
|
||||
{
|
||||
// Aggregate state
|
||||
var hasBig = Watches.Any(x => x.BigEndian);
|
||||
var hasLittle = Watches.Any(x => x.BigEndian == false);
|
||||
|
||||
if (hasBig && hasLittle)
|
||||
var firstWasBE = Watches[0].BigEndian;
|
||||
if (Watches.TrueForAll(w => w.BigEndian == firstWasBE))
|
||||
{
|
||||
BigEndianCheckBox.Checked = true;
|
||||
BigEndianCheckBox.CheckState = CheckState.Indeterminate;
|
||||
}
|
||||
else if (hasBig)
|
||||
{
|
||||
BigEndianCheckBox.Checked = true;
|
||||
BigEndianCheckBox.Checked = firstWasBE;
|
||||
}
|
||||
else
|
||||
{
|
||||
BigEndianCheckBox.Checked = false;
|
||||
BigEndianCheckBox.Checked = true;
|
||||
BigEndianCheckBox.CheckState = CheckState.Indeterminate;
|
||||
}
|
||||
}
|
||||
else if (Watches.Count == 1)
|
||||
|
|
|
@ -147,7 +147,7 @@ namespace BizHawk.Emulation.Common
|
|||
}
|
||||
|
||||
// Hack for things like gameboy/ti-83 as opposed to genesis with no controllers plugged in
|
||||
return allNames.Any(b => b.StartsWith("Up")) ? 1 : 0;
|
||||
return allNames.Exists(static b => b.StartsWith("Up")) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,8 +142,8 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
}
|
||||
|
||||
// are all the sample lengths the same?
|
||||
var firstEntry = SoundProviders[0];
|
||||
bool sameCount = SoundProviders.All(s => s.NSamp == firstEntry.NSamp);
|
||||
var firstEntry = SoundProviders[0].NSamp;
|
||||
var sameCount = SoundProviders.TrueForAll(s => s.NSamp == firstEntry);
|
||||
|
||||
if (!sameCount)
|
||||
{
|
||||
|
|
|
@ -29,21 +29,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
public string[] AvailableScopes { get; } = { "System Bus" };
|
||||
public bool ExecuteCallbacksAvailable => true;
|
||||
|
||||
public bool HasReads => _callbacks.Any(c => c.Callback.Type == MemoryCallbackType.Read);
|
||||
public bool HasWrites => _callbacks.Any(c => c.Callback.Type == MemoryCallbackType.Write);
|
||||
public bool HasExecutes => _callbacks.Any(c => c.Callback.Type == MemoryCallbackType.Execute);
|
||||
public bool HasReads
|
||||
=> _callbacks.Exists(static c => c.Callback.Type is MemoryCallbackType.Read);
|
||||
|
||||
public bool HasReadsForScope(string scope) =>
|
||||
_callbacks.Any(c => c.Callback.Scope == scope
|
||||
&& c.Callback.Type == MemoryCallbackType.Read);
|
||||
public bool HasWrites
|
||||
=> _callbacks.Exists(static c => c.Callback.Type is MemoryCallbackType.Write);
|
||||
|
||||
public bool HasWritesForScope(string scope) =>
|
||||
_callbacks.Any(c => c.Callback.Scope == scope
|
||||
&& c.Callback.Type == MemoryCallbackType.Write);
|
||||
public bool HasExecutes
|
||||
=> _callbacks.Exists(static c => c.Callback.Type is MemoryCallbackType.Execute);
|
||||
|
||||
public bool HasExecutesForScope(string scope) =>
|
||||
_callbacks.Any(c => c.Callback.Scope == scope
|
||||
&& c.Callback.Type == MemoryCallbackType.Execute);
|
||||
public bool HasReadsForScope(string scope)
|
||||
=> _callbacks.Exists(c => c.Callback.Type is MemoryCallbackType.Read && c.Callback.Scope == scope);
|
||||
|
||||
public bool HasWritesForScope(string scope)
|
||||
=> _callbacks.Exists(c => c.Callback.Type is MemoryCallbackType.Write && c.Callback.Scope == scope);
|
||||
|
||||
public bool HasExecutesForScope(string scope)
|
||||
=> _callbacks.Exists(c => c.Callback.Type is MemoryCallbackType.Execute && c.Callback.Scope == scope);
|
||||
|
||||
public void Add(IMemoryCallback callback)
|
||||
{
|
||||
|
|
|
@ -342,18 +342,10 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
|
||||
public override void SetValue(object component, object value)
|
||||
{
|
||||
if ((string)value == Port.DefaultSettingsValue)
|
||||
{
|
||||
ResetValue(component);
|
||||
}
|
||||
else if (!Port.AllowedDevices.Any(d => d.SettingValue == (string)value))
|
||||
{
|
||||
// does not validate
|
||||
}
|
||||
else
|
||||
{
|
||||
((NymaSyncSettings)component).PortDevices[PortIndex] = (string)value;
|
||||
}
|
||||
var str = (string) value;
|
||||
if (str == Port.DefaultSettingsValue) ResetValue(component);
|
||||
else if (Port.AllowedDevices.Exists(d => d.SettingValue == str)) ((NymaSyncSettings) component).PortDevices[PortIndex] = str;
|
||||
// else does not validate
|
||||
}
|
||||
|
||||
public override bool ShouldSerializeValue(object component)
|
||||
|
|
Loading…
Reference in New Issue