Enable a bunch of Analyzer rules re: `.Count()`/`.Any()` and fix cases
This commit is contained in:
parent
adcbc8a030
commit
cc0f1417f1
|
@ -72,9 +72,20 @@ dotnet_diagnostic.CA1805.severity = silent
|
|||
# Mark members as static
|
||||
dotnet_diagnostic.CA1822.severity = silent
|
||||
# Use property instead of Linq Enumerable method
|
||||
dotnet_diagnostic.CA1826.severity = error
|
||||
dotnet_code_quality.CA1826.exclude_ordefault_methods = true
|
||||
# Do not use Count()/LongCount() when Any() can be used
|
||||
dotnet_diagnostic.CA1827.severity = error
|
||||
# Do not use CountAsync/LongCountAsync when AnyAsync can be used
|
||||
dotnet_diagnostic.CA1828.severity = error
|
||||
# Use Length/Count property instead of Enumerable.Count method
|
||||
dotnet_diagnostic.CA1829.severity = error
|
||||
# Prefer IsEmpty over Count when available
|
||||
dotnet_diagnostic.CA1836.severity = error
|
||||
# Avoid StringBuilder parameters for P/Invokes
|
||||
dotnet_diagnostic.CA1838.severity = suggestion
|
||||
# Avoid using 'Enumerable.Any()' extension method
|
||||
dotnet_diagnostic.CA1860.severity = error
|
||||
# Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
|
||||
dotnet_diagnostic.CA1862.severity = error
|
||||
|
||||
|
@ -344,7 +355,7 @@ dotnet_diagnostic.MA0109.severity = silent
|
|||
# Use the Regex source generator
|
||||
dotnet_diagnostic.MA0110.severity = error
|
||||
# Use 'Count > 0' instead of 'Any()'
|
||||
dotnet_diagnostic.MA0112.severity = silent
|
||||
dotnet_diagnostic.MA0112.severity = error
|
||||
# Raw String contains an implicit end of line character (if you compile on Windows you may get CRLFs in string literals)
|
||||
dotnet_diagnostic.MA0136.severity = warning
|
||||
# Both if and else branch have identical code
|
||||
|
@ -405,6 +416,8 @@ dotnet_diagnostic.RCS1043.severity = warning
|
|||
dotnet_diagnostic.RCS1059.severity = silent
|
||||
# Avoid empty catch clause that catches System.Exception
|
||||
dotnet_diagnostic.RCS1075.severity = silent
|
||||
# Use 'Count/Length' property instead of 'Any' method
|
||||
dotnet_diagnostic.RCS1080.severity = error
|
||||
# Make class static
|
||||
dotnet_diagnostic.RCS1102.severity = silent
|
||||
# Add summary to documentation comment
|
||||
|
|
|
@ -137,7 +137,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
_messages.RemoveAll(m => DateTime.Now > m.ExpireAt);
|
||||
|
||||
if (_messages.Any())
|
||||
if (_messages.Count is not 0)
|
||||
{
|
||||
if (_config.StackOSDMessages)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common.StringExtensions;
|
||||
|
||||
|
@ -32,15 +31,18 @@ namespace BizHawk.Client.Common
|
|||
public bool Frozen { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool Empty => !recentlist.Any();
|
||||
public bool Empty
|
||||
=> recentlist.Count is 0;
|
||||
|
||||
[JsonIgnore]
|
||||
public int Count => recentlist.Count;
|
||||
|
||||
[JsonIgnore]
|
||||
public string MostRecent => recentlist.Any() ? recentlist[0] : "";
|
||||
public string MostRecent
|
||||
=> recentlist.Count is 0 ? string.Empty : recentlist[0];
|
||||
|
||||
public string this[int index] => recentlist.Any() ? recentlist[index] : "";
|
||||
public string this[int index]
|
||||
=> recentlist.Count is 0 ? string.Empty : recentlist[index];
|
||||
|
||||
public IEnumerator<string> GetEnumerator() => recentlist.GetEnumerator();
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private readonly Action Changed;
|
||||
|
||||
public int Count
|
||||
=> _functions.Count;
|
||||
|
||||
public LuaFunctionList(Action onChanged) => Changed = onChanged;
|
||||
|
||||
public NamedLuaFunction this[string guid]
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using System.Linq;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public partial class Bk2Movie
|
||||
{
|
||||
|
@ -9,7 +7,7 @@ namespace BizHawk.Client.Common
|
|||
public virtual void StartNewRecording()
|
||||
{
|
||||
Mode = MovieMode.Record;
|
||||
if (Session.Settings.EnableBackupMovies && MakeBackup && Log.Any())
|
||||
if (MakeBackup && Session.Settings.EnableBackupMovies && Log.Count is not 0)
|
||||
{
|
||||
SaveBackup();
|
||||
MakeBackup = false;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
@ -45,7 +44,7 @@ namespace BizHawk.Client.Common
|
|||
Result.Movie = session.Get(newFileName);
|
||||
RunImport();
|
||||
|
||||
if (!Result.Errors.Any())
|
||||
if (Result.Errors.Count is 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Result.Movie.Hash))
|
||||
{
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
@ -289,7 +288,7 @@ namespace BizHawk.Client.Common.movie.import
|
|||
break;
|
||||
}
|
||||
|
||||
if (peripheral != "" && !Result.Warnings.Any())
|
||||
if (peripheral.Length is not 0 && Result.Warnings.Count is 0)
|
||||
{
|
||||
Result.Warnings.Add($"Unable to import {peripheral}. Not supported yet");
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void RemoveFrames(ICollection<int> frames)
|
||||
{
|
||||
if (frames.Any())
|
||||
if (frames.Count is not 0)
|
||||
{
|
||||
// Separate the given frames into contiguous blocks
|
||||
// and process each block independently
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common.StringExtensions;
|
||||
|
||||
|
@ -33,15 +32,12 @@ namespace BizHawk.Client.Common
|
|||
bs.PutLump(BinaryStateLump.ClientSettings, (TextWriter tw) => tw.Write(inputRollSettingsJson));
|
||||
}
|
||||
|
||||
if (VerificationLog.Any())
|
||||
if (VerificationLog.Count is not 0)
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.VerificationLog, tw => tw.WriteLine(VerificationLog.ToInputLog()));
|
||||
}
|
||||
|
||||
if (Branches.Any())
|
||||
{
|
||||
Branches.Save(bs);
|
||||
}
|
||||
if (Branches.Count is not 0) Branches.Save(bs);
|
||||
|
||||
bs.PutLump(BinaryStateLump.Session, tw => tw.WriteLine(JsonConvert.SerializeObject(TasSession)));
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Bizware.Graphics;
|
||||
using BizHawk.Common;
|
||||
|
@ -99,7 +98,7 @@ namespace BizHawk.Client.Common
|
|||
});
|
||||
}
|
||||
|
||||
if (_userBag.Any())
|
||||
if (_userBag.Count is not 0)
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.UserData,
|
||||
tw =>
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
_defaultFileName = defaultFileName;
|
||||
|
||||
if (_cheatList.Any() && _changes && autosave)
|
||||
if (autosave && _changes && _cheatList.Count is not 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(CurrentFileName))
|
||||
{
|
||||
|
@ -224,7 +224,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (_config.AutoSaveOnClose)
|
||||
{
|
||||
if (Changes && _cheatList.Any())
|
||||
if (Changes && _cheatList.Count is not 0)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(CurrentFileName))
|
||||
{
|
||||
|
@ -233,7 +233,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
SaveFile(CurrentFileName);
|
||||
}
|
||||
else if (!_cheatList.Any() && !string.IsNullOrWhiteSpace(CurrentFileName))
|
||||
else if (_cheatList.Count is 0 && !string.IsNullOrWhiteSpace(CurrentFileName))
|
||||
{
|
||||
File.Delete(CurrentFileName);
|
||||
_config.Recent.Remove(CurrentFileName);
|
||||
|
|
|
@ -43,8 +43,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
var lastVisibleRow = firstVisibleRow + visibleRows;
|
||||
|
||||
var needsColumnRedraw = HorizontalOrientation || e.ClipRectangle.Y < ColumnHeight;
|
||||
if (visibleColumns.Any() && needsColumnRedraw)
|
||||
if (visibleColumns.Count is not 0
|
||||
&& (HorizontalOrientation || e.ClipRectangle.Y < ColumnHeight))
|
||||
{
|
||||
DrawColumnBg(visibleColumns, e.ClipRectangle);
|
||||
DrawColumnText(visibleColumns);
|
||||
|
@ -214,11 +214,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!visibleColumns.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (visibleColumns.Count is 0) return;
|
||||
|
||||
int startRow = firstVisibleRow;
|
||||
int range = Math.Min(lastVisibleRow, RowCount - 1) - startRow + 1;
|
||||
|
@ -342,7 +338,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
y += GetHColHeight(j);
|
||||
}
|
||||
|
||||
if (visibleColumns.Any())
|
||||
if (visibleColumns.Count is not 0)
|
||||
{
|
||||
_renderer.Line(1, y, MaxColumnWidth, y);
|
||||
}
|
||||
|
@ -367,7 +363,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
// Draw right most line
|
||||
if (visibleColumns.Any())
|
||||
if (visibleColumns.Count is not 0)
|
||||
{
|
||||
int right = TotalColWidth - _hBar.Value;
|
||||
if (right <= rect.Left + rect.Width)
|
||||
|
@ -482,7 +478,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_renderer.Line(x, y, x, rect.Height - 1);
|
||||
}
|
||||
|
||||
if (visibleColumns.Any())
|
||||
if (visibleColumns.Count is not 0)
|
||||
{
|
||||
int x = TotalColWidth - _hBar.Value;
|
||||
_renderer.Line(x, y, x, rect.Height - 1);
|
||||
|
@ -496,10 +492,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
if (_selectedItems.Any())
|
||||
{
|
||||
DoSelectionBG(visibleColumns, rect);
|
||||
}
|
||||
if (_selectedItems.Count is not 0) DoSelectionBG(visibleColumns, rect);
|
||||
}
|
||||
|
||||
private void DoSelectionBG(List<RollColumn> visibleColumns, Rectangle rect)
|
||||
|
@ -586,10 +579,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
// Calls QueryItemBkColor callback for all visible cells and fills in the background of those cells.
|
||||
private void DoBackGroundCallback(List<RollColumn> visibleColumns, Rectangle rect, int firstVisibleRow, int lastVisibleRow)
|
||||
{
|
||||
if (!visibleColumns.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (visibleColumns.Count is 0) return;
|
||||
|
||||
int startIndex = firstVisibleRow;
|
||||
int range = Math.Min(lastVisibleRow, RowCount - 1) - startIndex + 1;
|
||||
|
|
|
@ -4013,13 +4013,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var result = MovieImport.ImportFile(this, MovieSession, fn, Config);
|
||||
|
||||
if (result.Errors.Any())
|
||||
if (result.Errors.Count is not 0)
|
||||
{
|
||||
ShowMessageBox(owner: null, string.Join("\n", result.Errors), "Conversion error", EMsgBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.Warnings.Any())
|
||||
if (result.Warnings.Count is not 0)
|
||||
{
|
||||
AddOnScreenMessage(result.Warnings.First()); // For now, just show the first warning
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
HandleHardcoreModeDisable("Using MAME in hardcore mode is not allowed.");
|
||||
break;
|
||||
case NymaCore nyma:
|
||||
if (nyma.GetSettings().DisabledLayers.Any())
|
||||
if (nyma.GetSettings().DisabledLayers.Count is not 0)
|
||||
{
|
||||
HandleHardcoreModeDisable($"Disabling {Emu.GetType().Name}'s graphics layers in hardcore mode is not allowed.");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
|
|
|
@ -447,8 +447,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
var framesItem = new ListViewItem("Frames");
|
||||
framesItem.SubItems.Add(_movieList[firstIndex].FrameCount.ToString());
|
||||
DetailsView.Items.Add(framesItem);
|
||||
CommentsBtn.Enabled = _movieList[firstIndex].Comments.Any();
|
||||
SubtitlesBtn.Enabled = _movieList[firstIndex].Subtitles.Any();
|
||||
CommentsBtn.Enabled = _movieList[firstIndex].Comments.Count is not 0;
|
||||
SubtitlesBtn.Enabled = _movieList[firstIndex].Subtitles.Count is not 0;
|
||||
}
|
||||
|
||||
private void EditMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -400,7 +400,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void RemoveCheatMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var items = SelectedItems.ToList();
|
||||
if (items.Any())
|
||||
if (items.Count is not 0)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
|
@ -600,7 +600,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void ViewInHexEditorContextMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var selected = SelectedCheats.ToList();
|
||||
if (selected.Any())
|
||||
if (selected.Count is not 0)
|
||||
{
|
||||
Tools.Load<HexEditor>();
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void RemoveBreakpointButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var items = EditableItems.ToList();
|
||||
if (!items.Any()) return;
|
||||
if (items.Count is 0) return;
|
||||
foreach (var item in items) _breakpoints.Remove(item);
|
||||
BreakpointView.VirtualListSize = _breakpoints.Count;
|
||||
UpdateBreakpointRemoveButton();
|
||||
|
@ -205,7 +205,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void BreakpointView_ItemActivate(object sender, EventArgs e)
|
||||
{
|
||||
var items = EditableItems.ToList();
|
||||
if (!items.Any()) return;
|
||||
if (items.Count is 0) return;
|
||||
foreach (var item in items) item.Active = !item.Active;
|
||||
BreakpointView.VirtualListSize = _breakpoints.Count;
|
||||
UpdateBreakpointRemoveButton();
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void DisassemblerView_QueryItemBkColor(int index, RollColumn column, ref Color color)
|
||||
{
|
||||
if (_disassemblyLines.Any() && index < _disassemblyLines.Count)
|
||||
if (0 <= index && index < _disassemblyLines.Count)
|
||||
{
|
||||
if (_disassemblyLines[index].Address == _currentDisassemblerAddress)
|
||||
{
|
||||
|
|
|
@ -281,7 +281,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
DataSize = (int)size;
|
||||
SetDataSize(DataSize);
|
||||
var addrList = addresses.ToList();
|
||||
if (addrList.Any())
|
||||
if (addrList.Count is not 0)
|
||||
{
|
||||
SetMemoryDomain(domain.Name);
|
||||
SetHighlighted(addrList[0]);
|
||||
|
@ -295,7 +295,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public byte[] ConvertTextToBytes(string str)
|
||||
{
|
||||
if (_textTable.Any())
|
||||
if (_textTable.Count is not 0)
|
||||
{
|
||||
var byteArr = new byte[str.Length];
|
||||
for (var i = 0; i < str.Length; i++)
|
||||
|
@ -722,7 +722,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var addressesString = "0x" + $"{_domain.Size / DataSize:X8}".TrimStart('0');
|
||||
var viewerText = $"{Emulator.SystemId} {_domain}{(_domain.Writable ? string.Empty : " (READ-ONLY)")} - {addressesString} addresses";
|
||||
if (_nibbles.Any())
|
||||
if (_nibbles.Count is not 0)
|
||||
{
|
||||
viewerText += $" Typing: ({MakeNibbles()})";
|
||||
}
|
||||
|
@ -793,7 +793,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var newTitle = "Hex Editor";
|
||||
newTitle += " - Editing Address 0x" + string.Format(_numDigitsStr, _highlightedAddress);
|
||||
if (_secondaryHighlightedAddresses.Any())
|
||||
if (_secondaryHighlightedAddresses.Count is not 0)
|
||||
{
|
||||
newTitle += $" (Selected 0x{_secondaryHighlightedAddresses.Count + (_secondaryHighlightedAddresses.Contains(_highlightedAddress.Value) ? 0 : 1):X})";
|
||||
}
|
||||
|
@ -880,7 +880,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
MainForm.CheatList.RemoveRange(MainForm.CheatList.Where(x => x.Contains(_highlightedAddress.Value)));
|
||||
}
|
||||
|
||||
if (_secondaryHighlightedAddresses.Any())
|
||||
if (_secondaryHighlightedAddresses.Count is not 0)
|
||||
{
|
||||
MainForm.CheatList.RemoveRange(
|
||||
MainForm.CheatList.Where(cheat => !cheat.IsSeparator && cheat.Domain == _domain
|
||||
|
@ -1241,7 +1241,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
SaveAsBinaryMenuItem.Text = "Save as binary...";
|
||||
}
|
||||
|
||||
CloseTableFileMenuItem.Enabled = _textTable.Any();
|
||||
CloseTableFileMenuItem.Enabled = _textTable.Count is not 0;
|
||||
}
|
||||
|
||||
private void SaveMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -606,7 +606,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// <param name="includeFrameWaiters">should frame waiters be waken up? only use this immediately before a frame of emulation</param>
|
||||
public void ResumeScripts(bool includeFrameWaiters)
|
||||
{
|
||||
if (!LuaImp.ScriptList.Any()
|
||||
if (LuaImp.ScriptList.Count is 0
|
||||
|| LuaImp.IsUpdateSupressed
|
||||
|| (MainForm.IsTurboing && !Config.RunLuaDuringTurbo))
|
||||
{
|
||||
|
@ -805,9 +805,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
MoveDownMenuItem.Enabled =
|
||||
LuaListView.AnyRowsSelected;
|
||||
|
||||
SelectAllMenuItem.Enabled = LuaImp.ScriptList.Any();
|
||||
SelectAllMenuItem.Enabled = LuaImp.ScriptList.Count is not 0;
|
||||
StopAllScriptsMenuItem.Enabled = LuaImp.ScriptList.Any(script => script.Enabled);
|
||||
RegisteredFunctionsMenuItem.Enabled = LuaImp.RegisteredFunctions.Any();
|
||||
RegisteredFunctionsMenuItem.Enabled = LuaImp.RegisteredFunctions.Count is not 0;
|
||||
}
|
||||
|
||||
private void NewScriptMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -943,7 +943,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void RemoveScriptMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var items = SelectedItems.ToList();
|
||||
if (items.Any())
|
||||
if (items.Count is not 0)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
|
@ -1069,7 +1069,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void RegisteredFunctionsMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (LuaImp.RegisteredFunctions.Any())
|
||||
if (LuaImp.RegisteredFunctions.Count is not 0)
|
||||
{
|
||||
var alreadyOpen = false;
|
||||
foreach (Form form in Application.OpenForms)
|
||||
|
@ -1198,17 +1198,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
ScriptContextSeparator.Visible =
|
||||
LuaImp.ScriptList.Exists(file => file.Enabled);
|
||||
|
||||
ClearRegisteredFunctionsContextItem.Enabled =
|
||||
LuaImp.RegisteredFunctions.Any();
|
||||
ClearRegisteredFunctionsContextItem.Enabled = LuaImp.RegisteredFunctions.Count is not 0;
|
||||
}
|
||||
|
||||
private void ConsoleContextMenu_Opening(object sender, CancelEventArgs e)
|
||||
{
|
||||
RegisteredFunctionsContextItem.Enabled = LuaImp.RegisteredFunctions.Any();
|
||||
RegisteredFunctionsContextItem.Enabled = ClearRegisteredFunctionsLogContextItem.Enabled
|
||||
= LuaImp.RegisteredFunctions.Count is not 0;
|
||||
CopyContextItem.Enabled = OutputBox.SelectedText.Length is not 0;
|
||||
ClearConsoleContextItem.Enabled = SelectAllContextItem.Enabled = OutputBox.Text.Length is not 0;
|
||||
ClearRegisteredFunctionsLogContextItem.Enabled =
|
||||
LuaImp.RegisteredFunctions.Any();
|
||||
}
|
||||
|
||||
private void ClearConsoleContextItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
var indexes = FunctionView.SelectedIndices;
|
||||
CallButton.Enabled = indexes.Count > 0;
|
||||
RemoveButton.Enabled = indexes.Count > 0;
|
||||
RemoveAllBtn.Enabled = _registeredFunctions.Any();
|
||||
RemoveAllBtn.Enabled = _registeredFunctions.Count is not 0;
|
||||
}
|
||||
|
||||
private void FunctionView_KeyDown(object sender, KeyEventArgs e)
|
||||
|
|
|
@ -543,7 +543,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void UpdateTextColumnWidth()
|
||||
{
|
||||
if (Branches.Any())
|
||||
if (Branches.Count is not 0)
|
||||
{
|
||||
var longestBranchText = Branches
|
||||
.OrderBy(b => b.UserText?.Length ?? 0)
|
||||
|
|
|
@ -195,7 +195,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void UpdateTextColumnWidth()
|
||||
{
|
||||
if (Markers.Any())
|
||||
if (Markers.Count is not 0)
|
||||
{
|
||||
var longestBranchText = Markers
|
||||
.OrderBy(b => b.Message?.Length ?? 0)
|
||||
|
|
|
@ -940,7 +940,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
// TODO: columns selected?
|
||||
var selectedRowCount = TasView.SelectedRows.Count();
|
||||
var temp = $"Selected: {selectedRowCount} {(selectedRowCount == 1 ? "frame" : "frames")}, States: {CurrentTasMovie.TasStateManager.Count}";
|
||||
if (_tasClipboard.Any()) temp += $", Clipboard: {_tasClipboard.Count} {(_tasClipboard.Count == 1 ? "frame" : "frames")}";
|
||||
var clipboardCount = _tasClipboard.Count;
|
||||
if (clipboardCount is not 0) temp += $", Clipboard: {clipboardCount} {(clipboardCount is 1 ? "frame" : "frames")}";
|
||||
SplicerStatusLabel.Text = temp;
|
||||
}
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
TracerBox.Text = "Trace log - logging to file...";
|
||||
}
|
||||
else if (_instructions.Any())
|
||||
else if (_instructions.Count is not 0)
|
||||
{
|
||||
TracerBox.Text = $"Trace log - logging - {_instructions.Count} instructions";
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
if (_instructions.Any())
|
||||
if (_instructions.Count is not 0)
|
||||
{
|
||||
TracerBox.Text = $"Trace log - {_instructions.Count} instructions";
|
||||
}
|
||||
|
|
|
@ -812,7 +812,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void RemoveAddresses()
|
||||
{
|
||||
var indices = SelectedIndices.ToList();
|
||||
if (indices.Any())
|
||||
if (indices.Count is not 0)
|
||||
{
|
||||
SetRemovedMessage(indices.Count);
|
||||
_searches.RemoveRange(indices);
|
||||
|
@ -865,7 +865,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void AddToRamWatch()
|
||||
{
|
||||
var watches = SelectedWatches.ToList();
|
||||
if (watches.Any())
|
||||
if (watches.Count is not 0)
|
||||
{
|
||||
Tools.LoadRamWatch(true);
|
||||
watches.ForEach(Tools.RamWatch.AddWatch);
|
||||
|
|
|
@ -327,7 +327,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
|
||||
if (_watches.Any())
|
||||
if (_watches.Count is not 0)
|
||||
{
|
||||
_watches.UpdateValues(Config.RamWatchDefinePrevious);
|
||||
DisplayOnScreenWatches();
|
||||
|
@ -342,7 +342,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
DisplayManager.OSD.ClearRamWatches();
|
||||
if (_watches.Any())
|
||||
if (_watches.Count is not 0)
|
||||
{
|
||||
_watches.UpdateValues(Config.RamWatchDefinePrevious);
|
||||
DisplayOnScreenWatches();
|
||||
|
@ -898,10 +898,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void MoveUpMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var indexes = SelectedIndices.ToList();
|
||||
if (!indexes.Any() || indexes[0] == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (indexes is [ ] or [ 0, .. ]) return;
|
||||
|
||||
foreach (var index in indexes)
|
||||
{
|
||||
|
@ -954,10 +951,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void MoveTopMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var indexes = SelectedIndices.ToList();
|
||||
if (!indexes.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (indexes.Count is 0) return;
|
||||
|
||||
for (int i = 0; i < indexes.Count; i++)
|
||||
{
|
||||
|
@ -1177,7 +1171,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void ViewInHexEditorContextMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var selected = SelectedWatches.ToList();
|
||||
if (selected.Any())
|
||||
if (selected.Count is not 0)
|
||||
{
|
||||
Tools.Load<HexEditor>();
|
||||
ViewInHexEditor(
|
||||
|
@ -1193,7 +1187,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var selected = SelectedWatches.ToList();
|
||||
|
||||
if (selected.Any())
|
||||
if (selected.Count is not 0)
|
||||
{
|
||||
var debugger = Tools.Load<GenericDebugger>();
|
||||
|
||||
|
@ -1208,7 +1202,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var selected = SelectedWatches.ToList();
|
||||
|
||||
if (selected.Any())
|
||||
if (selected.Count is not 0)
|
||||
{
|
||||
var debugger = Tools.Load<GenericDebugger>();
|
||||
|
||||
|
|
|
@ -166,8 +166,6 @@ namespace BizHawk.Emulation.Common
|
|||
}
|
||||
|
||||
public bool Any()
|
||||
{
|
||||
return BoolButtons.Any() || Axes.Any();
|
||||
}
|
||||
=> BoolButtons.Count is not 0 || Axes.Count is not 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
|
@ -21,33 +20,28 @@ namespace BizHawk.Emulation.Common
|
|||
// TODO: these just happen to be all the add/remove methods the client uses, to be thorough the others should be overriden as well
|
||||
public void RemoveAll(IEnumerable<Action> actions)
|
||||
{
|
||||
var hadAny = this.Any();
|
||||
|
||||
var hadAny = Count is not 0;
|
||||
foreach (var action in actions)
|
||||
{
|
||||
Remove(action);
|
||||
}
|
||||
|
||||
var hasAny = this.Any();
|
||||
|
||||
var hasAny = Count is not 0;
|
||||
Changes(hadAny, hasAny);
|
||||
}
|
||||
|
||||
public new void Add(Action item)
|
||||
{
|
||||
var hadAny = this.Any();
|
||||
var hadAny = Count is not 0;
|
||||
base.Add(item);
|
||||
var hasAny = this.Any();
|
||||
|
||||
var hasAny = Count is not 0;
|
||||
Changes(hadAny, hasAny);
|
||||
}
|
||||
|
||||
public new bool Remove(Action item)
|
||||
{
|
||||
var hadAny = this.Any();
|
||||
var hadAny = Count is not 0;
|
||||
var result = base.Remove(item);
|
||||
var hasAny = this.Any();
|
||||
|
||||
var hasAny = Count is not 0;
|
||||
Changes(hadAny, hasAny);
|
||||
|
||||
return result;
|
||||
|
|
|
@ -78,15 +78,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
private int _currentDataBlockIndex = 0;
|
||||
public int CurrentDataBlockIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
if (DataBlocks.Any())
|
||||
{
|
||||
return _currentDataBlockIndex;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
get => DataBlocks.Count is 0 ? -1 : _currentDataBlockIndex;
|
||||
set
|
||||
{
|
||||
if (value == _currentDataBlockIndex) { return; }
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
|
@ -180,9 +179,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan
|
|||
}
|
||||
|
||||
private void SetInputCallback()
|
||||
{
|
||||
BizSwan.bizswan_setbuttoncallback(Core, InputCallbacks.Any() ? ButtonCallbackD : null);
|
||||
}
|
||||
=> BizSwan.bizswan_setbuttoncallback(Core, InputCallbacks.Count is 0 ? null : ButtonCallbackD);
|
||||
|
||||
private void SetMemoryCallbacks()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue