Skip to content

Commit

Permalink
Prefer IsEmpty over Count/Any
Browse files Browse the repository at this point in the history
Reported by CA1836
  • Loading branch information
jnyrup committed Feb 23, 2023
1 parent caf4776 commit 74a9919
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/PuppeteerSharp/CDPSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public Task DetachAsync()
internal void Send(string method, object args = null)
=> _ = SendAsync(method, args, false);

internal bool HasPendingCallbacks() => _callbacks.Count != 0;
internal bool HasPendingCallbacks() => !_callbacks.IsEmpty;

internal void OnMessage(ConnectionResponse obj)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/PuppeteerSharp/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ internal async Task<CDPSession> CreateSessionAsync(TargetInfo targetInfo, bool i
return await GetSessionAsync(sessionId).ConfigureAwait(false);
}

internal bool HasPendingCallbacks() => _callbacks.Count != 0;
internal bool HasPendingCallbacks() => !_callbacks.IsEmpty;

internal void Close(string closeReason)
{
Expand Down
4 changes: 2 additions & 2 deletions lib/PuppeteerSharp/DOMWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public DOMWorld(CDPSession client, FrameManager frameManager, Frame frame, Timeo
_logger = _client.Connection.LoggerFactory.CreateLogger<DOMWorld>();
}

internal ICollection<WaitTask> WaitTasks { get; set; }
internal ConcurrentSet<WaitTask> WaitTasks { get; set; }

internal Frame Frame { get; }

Expand Down Expand Up @@ -143,7 +143,7 @@ internal async Task<IElementHandle> AdoptHandleAsync(IElementHandle handle)
internal void Detach()
{
_detached = true;
while (WaitTasks.Count > 0)
while (!WaitTasks.IsEmpty)
{
WaitTasks.First().Terminate(new Exception("waitForFunction failed: frame got detached."));
}
Expand Down
6 changes: 3 additions & 3 deletions lib/PuppeteerSharp/Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ async void ResponseEventListener(object sender, ResponseCreatedEventArgs e)
/// <inheritdoc/>
public async Task<FileChooser> WaitForFileChooserAsync(WaitForFileChooserOptions options = null)
{
if (!_fileChooserInterceptors.Any())
if (_fileChooserInterceptors.IsEmpty)
{
await Client.SendAsync("Page.setInterceptFileChooserDialog", new PageSetInterceptFileChooserDialog
{
Expand Down Expand Up @@ -1472,7 +1472,7 @@ private async void Client_MessageReceived(object sender, MessageEventArgs e)

private async Task OnFileChooserAsync(PageFileChooserOpenedResponse e)
{
if (_fileChooserInterceptors.Count == 0)
if (_fileChooserInterceptors.IsEmpty)
{
try
{
Expand All @@ -1493,7 +1493,7 @@ private async Task OnFileChooserAsync(PageFileChooserOpenedResponse e)
var world = context.World;
var element = await world.AdoptBackendNodeAsync(e.BackendNodeId).ConfigureAwait(false);
var fileChooser = new FileChooser(element, e);
while (_fileChooserInterceptors.Count > 0)
while (!_fileChooserInterceptors.IsEmpty)
{
var key = _fileChooserInterceptors.FirstOrDefault().Key;

Expand Down

0 comments on commit 74a9919

Please sign in to comment.