Use 'using' keyword to dispose objects and fix warnings
MODIFY
WalletWasabi.Fluent.Desktop/Program.cs
WalletWasabi.Fluent.Desktop/Program.cs
@@ -64,7 +64,8 @@ namespace WalletWasabi.Fluent.Desktop
SetupLogger(dataDir, args);
var (uiConfig, config) = LoadOrCreateConfigs(dataDir);
- singleInstanceChecker = new SingleInstanceChecker(config.Network);
+ using var sic = new SingleInstanceChecker(config.Network);
+ singleInstanceChecker = sic;
singleInstanceChecker.EnsureSingleOrThrowAsync().GetAwaiter().GetResult();
Global = CreateGlobal(dataDir, uiConfig, config);

MODIFY
WalletWasabi.Gui/Dialogs/CannotCloseDialogViewModel.cs
WalletWasabi.Gui/Dialogs/CannotCloseDialogViewModel.cs
@@ -96,7 +96,8 @@ namespace WalletWasabi.Gui.Dialogs
{
Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
- CancelTokenSource = new CancellationTokenSource().DisposeWith(Disposables);
+ using var cancellationTokenSource = new CancellationTokenSource();
+ CancelTokenSource = cancellationTokenSource.DisposeWith(Disposables);
Initialization = StartDequeueAsync();

MODIFY
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
@@ -66,7 +66,8 @@ namespace WalletWasabi.Tests.RegressionTests
var bestBlock = await rpc.GetBlockAsync(bestBlockHash);
var coinbaseTxId = bestBlock.Transactions[0].GetHash();
var offchainTxId = network.Consensus.ConsensusFactory.CreateTransaction().GetHash();
- var mempoolTxId = await rpc.SendToAddressAsync(new Key().PubKey.GetSegwitAddress(network), Money.Coins(1));
+ using var key = new Key();
+ var mempoolTxId = await rpc.SendToAddressAsync(key.PubKey.GetSegwitAddress(network), Money.Coins(1));
var folder = Helpers.Common.GetWorkDir();
await IoHelpers.TryDeleteDirectoryAsync(folder);

MODIFY
WalletWasabi.Tests/UnitTests/CoordinatorRoundTests.cs
WalletWasabi.Tests/UnitTests/CoordinatorRoundTests.cs
@@ -35,7 +35,8 @@ namespace WalletWasabi.Tests.UnitTests
tx.LockTime = LockTime.Zero;
tx.Inputs.Add(GetRandomOutPoint(), new Script(OpcodeType.OP_0, OpcodeType.OP_0), sequence: Sequence.Final);
tx.Inputs.Add(GetRandomOutPoint(), new Script(OpcodeType.OP_0, OpcodeType.OP_0), sequence: Sequence.Final);
- tx.Outputs.Add(Money.Coins(1.9995m), new Key().ScriptPubKey);
+ using var key = new Key();
+ tx.Outputs.Add(Money.Coins(1.9995m), key.ScriptPubKey);
// Under normal circunstances
{

Use 'using' keyword to dispose objects and fix warnings