Simplify string interpolation
MODIFY
WalletWasabi.Backend/Global.cs
WalletWasabi.Backend/Global.cs
@@ -101,7 +101,7 @@ namespace WalletWasabi.Backend
Guard.NotNull(nameof(endPoint), endPoint);
// We have to find it, because it's cloned by the node and not perfectly cloned (event handlers cannot be cloned.)
- P2pNode = new P2pNode(network, endPoint, new MempoolService(), $"/WasabiCoordinator:{Constants.BackendMajorVersion.ToString()}/");
+ P2pNode = new P2pNode(network, endPoint, new MempoolService(), $"/WasabiCoordinator:{Constants.BackendMajorVersion}/");
await P2pNode.ConnectAsync(cancel).ConfigureAwait(false);
HostedServices.Register(new BlockNotifier(TimeSpan.FromSeconds(7), RpcClient, P2pNode), "Block Notifier");
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
@@ -625,7 +625,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
break;
case FeeDisplayFormat.USD:
- FeeText = $"(~ ${UsdFee.ToString("0.##")})";
+ FeeText = $"(~ ${UsdFee:0.##})";
FeeToolTip = $"Estimated total fees in USD. Exchange Rate: {(long)UsdExchangeRate} USD/BTC.";
break;
@@ -635,7 +635,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
break;
case FeeDisplayFormat.Percentage:
- FeeText = $"(~ {FeePercentage.ToString("0.#")} %)";
+ FeeText = $"(~ {FeePercentage:0.#} %)";
FeeToolTip = "Expected percentage of fees against the amount to be sent.";
break;

MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -199,7 +199,7 @@ namespace WalletWasabi.Gui
EndPointStrategy.Default(Network, EndPointType.Rpc),
txIndex: null,
prune: null,
- userAgent: $"/WasabiClient:{Constants.ClientVersion.ToString()}/"),
+ userAgent: $"/WasabiClient:{Constants.ClientVersion}/"),
cancel)
.ConfigureAwait(false);
}

MODIFY
WalletWasabi.Gui/Rpc/WasabiJsonRpcService.cs
WalletWasabi.Gui/Rpc/WasabiJsonRpcService.cs
@@ -60,7 +60,7 @@ namespace WalletWasabi.Gui.Rpc
walletFile = Global.Wallet.KeyManager.FilePath,
extendedAccountPublicKey = km.ExtPubKey.ToString(Global.Network),
extendedAccountZpub = km.ExtPubKey.ToZpub(Global.Network),
- accountKeyPath = $"m/{km.AccountKeyPath.ToString()}",
+ accountKeyPath = $"m/{km.AccountKeyPath}",
masterKeyFingerprint = km.MasterFingerprint?.ToString() ?? "",
balance = Global.Wallet.Coins
.Where(c => c.Unspent && !c.SpentAccordingToBackend)

MODIFY
WalletWasabi.Packager/MacSignTools.cs
WalletWasabi.Packager/MacSignTools.cs
@@ -348,7 +348,7 @@ namespace WalletWasabi.Packager
sw.Start();
while (true) // Wait for the notarization.
{
- Console.WriteLine($"Checking notarization status. Elapsed time: {sw.Elapsed.ToString()}");
+ Console.WriteLine($"Checking notarization status. Elapsed time: {sw.Elapsed}");
using var process = Process.Start(new ProcessStartInfo
{
FileName = "xcrun",

MODIFY
WalletWasabi.Tests/Helpers/TestNodeBuilder.cs
WalletWasabi.Tests/Helpers/TestNodeBuilder.cs
@@ -32,7 +32,7 @@ namespace WalletWasabi.Tests.Helpers
EndPointStrategy.Random,
txIndex: 1,
prune: 0,
- userAgent: $"/WasabiClient:{Constants.ClientVersion.ToString()}/"),
+ userAgent: $"/WasabiClient:{Constants.ClientVersion}/"),
CancellationToken.None);
}
}

MODIFY
WalletWasabi.Tests/UnitTests/AsyncMutexTests.cs
WalletWasabi.Tests/UnitTests/AsyncMutexTests.cs
@@ -65,7 +65,7 @@ namespace WalletWasabi.Tests.UnitTests
[Fact]
public async Task AsyncMutexTestsAsync()
{
- var mutexName1 = $"mutex1-{DateTime.Now.Ticks.ToString()}"; // Randomize the name to avoid system wide collisions.
+ var mutexName1 = $"mutex1-{DateTime.Now.Ticks}"; // Randomize the name to avoid system wide collisions.
AsyncMutex asyncMutex = new AsyncMutex(mutexName1);
@@ -130,7 +130,7 @@ namespace WalletWasabi.Tests.UnitTests
Assert.Equal(prevnum + 1, num);
}
- var mutexName2 = $"mutex2-{DateTime.Now.Ticks.ToString()}";
+ var mutexName2 = $"mutex2-{DateTime.Now.Ticks}";
// Test that asynclock cancellation is going to throw IOException.
var mutex = new AsyncMutex(mutexName2);

MODIFY
WalletWasabi/Blockchain/BlockFilters/StartingFilters.cs
WalletWasabi/Blockchain/BlockFilters/StartingFilters.cs
@@ -25,7 +25,7 @@ namespace WalletWasabi.Blockchain.BlockFilters
else if (network == Network.RegTest)
{
GolombRiceFilter filter = IndexBuilderService.CreateDummyEmptyFilter(startingHeader.BlockHash);
- return FilterModel.FromLine($"{startingHeader.Height}:{startingHeader.BlockHash}:{filter.ToString()}:{startingHeader.PrevHash}:{startingHeader.BlockTime.ToUnixTimeSeconds()}");
+ return FilterModel.FromLine($"{startingHeader.Height}:{startingHeader.BlockHash}:{filter}:{startingHeader.PrevHash}:{startingHeader.BlockTime.ToUnixTimeSeconds()}");
}
else
{

MODIFY
WalletWasabi/CoinJoin/Coordinator/Banning/BannedUtxo.cs
WalletWasabi/CoinJoin/Coordinator/Banning/BannedUtxo.cs
@@ -46,7 +46,7 @@ namespace WalletWasabi.CoinJoin.Coordinator.Banning
/// </summary>
public override string ToString()
{
- return $"{TimeOfBan.ToString("yyyy-MM-dd HH-mm-ss")}:{Severity}:{Utxo.N}:{Utxo.Hash}:{IsNoted}:{BannedForRound}";
+ return $"{TimeOfBan:yyyy-MM-dd HH-mm-ss}:{Severity}:{Utxo.N}:{Utxo.Hash}:{IsNoted}:{BannedForRound}";
}
}
}

MODIFY
WalletWasabi/CoinJoin/Coordinator/Rounds/CoordinatorRound.cs
WalletWasabi/CoinJoin/Coordinator/Rounds/CoordinatorRound.cs
@@ -214,7 +214,7 @@ namespace WalletWasabi.CoinJoin.Coordinator.Rounds
{
try
{
- Logger.LogInfo($"Round ({RoundId}): Phase change requested: {expectedPhase.ToString()}.");
+ Logger.LogInfo($"Round ({RoundId}): Phase change requested: {expectedPhase}.");
if (Status == CoordinatorRoundStatus.NotStarted) // So start the input registration phase
{
@@ -417,7 +417,7 @@ namespace WalletWasabi.CoinJoin.Coordinator.Rounds
return;
}
- Logger.LogInfo($"Round ({RoundId}): Phase initialized: {expectedPhase.ToString()}.");
+ Logger.LogInfo($"Round ({RoundId}): Phase initialized: {expectedPhase}.");
}
catch (Exception ex)
{
@@ -468,7 +468,7 @@ namespace WalletWasabi.CoinJoin.Coordinator.Rounds
if (executeRunAbortion)
{
PhaseTimeoutLog.TryAdd((RoundId, Phase), DateTimeOffset.UtcNow);
- string timedOutLogString = $"Round ({RoundId}): {expectedPhase.ToString()} timed out after {timeout.TotalSeconds} seconds.";
+ string timedOutLogString = $"Round ({RoundId}): {expectedPhase} timed out after {timeout.TotalSeconds} seconds.";
if (expectedPhase == RoundPhase.ConnectionConfirmation)
{
@@ -545,7 +545,7 @@ namespace WalletWasabi.CoinJoin.Coordinator.Rounds
}
catch (Exception ex)
{
- Logger.LogWarning($"Round ({RoundId}): {expectedPhase.ToString()} timeout failed.");
+ Logger.LogWarning($"Round ({RoundId}): {expectedPhase} timeout failed.");
Logger.LogWarning(ex);
}
});
@@ -553,7 +553,7 @@ namespace WalletWasabi.CoinJoin.Coordinator.Rounds
}
catch (Exception ex)
{
- Logger.LogWarning($"Round ({RoundId}): {expectedPhase.ToString()} timeout failed.");
+ Logger.LogWarning($"Round ({RoundId}): {expectedPhase} timeout failed.");
Logger.LogWarning(ex);
}
});
@@ -1116,7 +1116,7 @@ namespace WalletWasabi.CoinJoin.Coordinator.Rounds
{
if ((Phase != RoundPhase.InputRegistration && Phase != RoundPhase.ConnectionConfirmation) || Status != CoordinatorRoundStatus.Running)
{
- throw new InvalidOperationException($"Updating anonymity set is not allowed in {Phase.ToString()} phase.");
+ throw new InvalidOperationException($"Updating anonymity set is not allowed in {Phase} phase.");
}
AnonymitySet = anonymitySet;
}
@@ -1125,7 +1125,7 @@ namespace WalletWasabi.CoinJoin.Coordinator.Rounds
{
if ((Phase != RoundPhase.InputRegistration && Phase != RoundPhase.ConnectionConfirmation) || Status != CoordinatorRoundStatus.Running)
{
- throw new InvalidOperationException($"Updating anonymity set is not allowed in {Phase.ToString()} phase.");
+ throw new InvalidOperationException($"Updating anonymity set is not allowed in {Phase} phase.");
}
AnonymitySet = anonymitySet;
}

MODIFY
WalletWasabi/Helpers/EndPointParser.cs
WalletWasabi/Helpers/EndPointParser.cs
@@ -24,7 +24,7 @@ namespace System.Net
}
else
{
- throw new FormatException($"Invalid endpoint: {me.ToString()}");
+ throw new FormatException($"Invalid endpoint: {me}");
}
if (port == 0)

MODIFY
WalletWasabi/Nito/AsyncEx/AsyncMutex.cs
WalletWasabi/Nito/AsyncEx/AsyncMutex.cs
@@ -256,7 +256,7 @@ namespace Nito.AsyncEx
if (!expectedPreviousStatuses.Contains((AsyncLockStatus)prevstatus))
{
- throw new InvalidOperationException($"Previous {nameof(AsyncLock)} state was unexpected: prev:{((AsyncLockStatus)prevstatus).ToString()} now:{((AsyncLockStatus)_status).ToString()}.");
+ throw new InvalidOperationException($"Previous {nameof(AsyncLock)} state was unexpected: prev:{(AsyncLockStatus)prevstatus} now:{(AsyncLockStatus)_status}.");
}
}

MODIFY
WalletWasabi/Wallets/Wallet.cs
WalletWasabi/Wallets/Wallet.cs
@@ -710,7 +710,7 @@ namespace WalletWasabi.Wallets
{
ConnectCancellation = handshakeTimeout.Token,
IsRelay = false,
- UserAgent = $"/Wasabi:{Constants.ClientVersion.ToString()}/"
+ UserAgent = $"/Wasabi:{Constants.ClientVersion}/"
};
// If an onion was added must try to use Tor.

Simplify string interpolation