Use Collection Count property when possible
MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -55,7 +55,7 @@ namespace WalletWasabi.Tests
{
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var filters = await response.Content.ReadAsJsonAsync<List<string>>();
- var filterCount = filters.Count();
+ var filterCount = filters.Count;
if (filterCount >= 101)
{
break;
@@ -2171,7 +2171,7 @@ namespace WalletWasabi.Tests
}
var mempool = await rpc.GetRawMempoolAsync();
- Assert.Equal(inputRegistrationUsers.SelectMany(x => x.userInputData).Count(), mempool.Count());
+ Assert.Equal(inputRegistrationUsers.SelectMany(x => x.userInputData).Count(), mempool.Length);
while ((await rpc.GetRawMempoolAsync()).Length != 0)
{
@@ -2209,7 +2209,7 @@ namespace WalletWasabi.Tests
Logger.TurnOn();
- Assert.Equal(users.Count(), roundConfig.AnonymitySet);
+ Assert.Equal(users.Count, roundConfig.AnonymitySet);
var confirmationRequests = new List<Task<string>>();

MODIFY
WalletWasabi/Helpers/HttpMessageHelper.cs
WalletWasabi/Helpers/HttpMessageHelper.cs
@@ -37,7 +37,7 @@ namespace System.Net.Http
}
var startLine = bab.ToString(Encoding.ASCII);
- if (startLine == null || startLine == "") throw new FormatException($"{nameof(startLine)} cannot be null or empty.");
+ if (string.IsNullOrEmpty(startLine)) throw new FormatException($"{nameof(startLine)} cannot be null or empty.");
return startLine;
}
@@ -77,9 +77,9 @@ namespace System.Net.Http
builder.Append(header + CRLF); // CRLF is part of the headerstring
}
headers = builder.ToString();
- if (headers == null || headers == "")
+ if (string.IsNullOrEmpty(headers))
{
- headers = "";
+ headers = string.Empty;
}
return headers;
@@ -486,7 +486,7 @@ namespace System.Net.Http
if (contentHeaders.Contains("Content-Length"))
{
if (contentHeaders.ContentLength < 0)
- throw new HttpRequestException("Content-Length MUST be bigger than zero.");
+ throw new HttpRequestException("Content-Length MUST be larger than zero.");
}
}

MODIFY
WalletWasabi/Services/CcjCoordinator.cs
WalletWasabi/Services/CcjCoordinator.cs
@@ -288,7 +288,7 @@ namespace WalletWasabi.Services
{
using (await CoinJoinsLock.LockAsync())
{
- if (UnconfirmedCoinJoins.Count() < 24)
+ if (UnconfirmedCoinJoins.Count < 24)
{
return false;
}

MODIFY
WalletWasabi/Services/MemPoolBehavior.cs
WalletWasabi/Services/MemPoolBehavior.cs
@@ -54,13 +54,11 @@ namespace WalletWasabi.Services
catch (OperationCanceledException ex)
{
Logger.LogDebug<MemPoolBehavior>(ex);
- return;
}
catch (Exception ex)
{
Logger.LogInfo<MemPoolBehavior>($"Ignoring {ex.GetType()}: {ex.Message}");
Logger.LogDebug<MemPoolBehavior>(ex);
- return;
}
}

MODIFY
WalletWasabi/Services/UtxoReferee.cs
WalletWasabi/Services/UtxoReferee.cs
@@ -72,7 +72,7 @@ namespace WalletWasabi.Services
File.WriteAllLines(BannedUtxosFilePath, newAllLines);
}
- Logger.LogInfo<UtxoReferee>($"{allLines.Count()} banned UTXOs are loaded from {BannedUtxosFilePath}.");
+ Logger.LogInfo<UtxoReferee>($"{allLines.Length} banned UTXOs are loaded from {BannedUtxosFilePath}.");
}
catch (Exception ex)
{

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -628,7 +628,7 @@ namespace WalletWasabi.Services
int inNum;
if (spendAll)
{
- inNum = allowedSmartCoinInputs.Count();
+ inNum = allowedSmartCoinInputs.Count;
}
else
{

Use Collection Count property when possible