Use [CallerMemberName] instead of nameof
MODIFY
WalletWasabi.Tests/KeyManagementTests.cs
WalletWasabi.Tests/KeyManagementTests.cs
@@ -2,6 +2,7 @@ using NBitcoin;
using System;
using System.IO;
using System.Security;
+using WalletWasabi.Helpers;
using WalletWasabi.KeyManagement;
using WalletWasabi.Logging;
using WalletWasabi.Tests.XunitConfiguration;
@@ -88,7 +89,7 @@ namespace WalletWasabi.Tests
{
string password = "password";
- var filePath = Path.Combine(Global.Instance.DataDir, nameof(CanSerialize), "Wallet.json");
+ var filePath = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName(), "Wallet.json");
DeleteFileAndDirectoryIfExists(filePath);
Logger.TurnOff();

MODIFY
WalletWasabi.Tests/P2pTests.cs
WalletWasabi.Tests/P2pTests.cs
@@ -86,7 +86,7 @@ namespace WalletWasabi.Tests
var nodes = new NodesGroup(network, connectionParameters, requirements: Constants.NodeRequirements);
BitcoinStore bitcoinStore = new BitcoinStore();
- await bitcoinStore.InitializeAsync(Path.Combine(Global.Instance.DataDir, nameof(TestServicesAsync)), network);
+ await bitcoinStore.InitializeAsync(Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName()), network);
KeyManager keyManager = KeyManager.CreateNew(out _, "password");
WasabiSynchronizer syncer = new WasabiSynchronizer(network, bitcoinStore, new Uri("http://localhost:12345"), Global.Instance.TorSocks5Endpoint);

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -164,7 +164,7 @@ namespace WalletWasabi.Tests
{
(string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
- var indexBuilderServiceDir = Path.Combine(Global.Instance.DataDir, nameof(IndexBuilderService));
+ var indexBuilderServiceDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
var indexFilePath = Path.Combine(indexBuilderServiceDir, $"Index{rpc.Network}.dat");
var utxoSetFilePath = Path.Combine(indexBuilderServiceDir, $"UtxoSet{rpc.Network}.dat");
@@ -543,7 +543,7 @@ namespace WalletWasabi.Tests
var chaumianClient = new CcjClient(synchronizer, rpc.Network, keyManager, new Uri(RegTestFixture.BackendEndPoint), null);
// 5. Create wallet service.
- var workDir = Path.Combine(Global.Instance.DataDir, nameof(WalletTestsAsync));
+ var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
@@ -774,7 +774,7 @@ namespace WalletWasabi.Tests
var chaumianClient = new CcjClient(synchronizer, rpc.Network, keyManager, new Uri(RegTestFixture.BackendEndPoint), null);
// 6. Create wallet service.
- var workDir = Path.Combine(Global.Instance.DataDir, nameof(SendTestsAsync));
+ var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
@@ -1247,7 +1247,7 @@ namespace WalletWasabi.Tests
var chaumianClient = new CcjClient(synchronizer, rpc.Network, keyManager, new Uri(RegTestFixture.BackendEndPoint), null);
// 6. Create wallet service.
- var workDir = Path.Combine(Global.Instance.DataDir, nameof(BuildTransactionValidationsTestAsync));
+ var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
@@ -1410,7 +1410,7 @@ namespace WalletWasabi.Tests
var chaumianClient = new CcjClient(synchronizer, rpc.Network, keyManager, new Uri(RegTestFixture.BackendEndPoint), null);
// 6. Create wallet service.
- var workDir = Path.Combine(Global.Instance.DataDir, nameof(BuildTransactionReorgsTestAsync));
+ var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
@@ -1573,7 +1573,7 @@ namespace WalletWasabi.Tests
var chaumianClient = new CcjClient(synchronizer, rpc.Network, keyManager, new Uri(RegTestFixture.BackendEndPoint), null);
// 6. Create wallet service.
- var workDir = Path.Combine(Global.Instance.DataDir, nameof(SpendUnconfirmedTxTestAsync));
+ var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
@@ -1741,7 +1741,7 @@ namespace WalletWasabi.Tests
var chaumianClient = new CcjClient(synchronizer, rpc.Network, keyManager, new Uri(RegTestFixture.BackendEndPoint), null);
// 6. Create wallet service.
- var workDir = Path.Combine(Global.Instance.DataDir, nameof(ReplaceByFeeTxTestAsync));
+ var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
@@ -1838,7 +1838,7 @@ namespace WalletWasabi.Tests
var offchainTxId = network.Consensus.ConsensusFactory.CreateTransaction().GetHash();
var mempoolTxId = rpc.SendToAddress(new Key().PubKey.GetSegwitAddress(network), Money.Coins(1));
- var folder = Path.Combine(Global.Instance.DataDir, nameof(CcjCoordinatorCtorTestsAsync));
+ var folder = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
await IoHelpers.DeleteRecursivelyWithMagicDustAsync(folder);
Directory.CreateDirectory(folder);
var cjfile = Path.Combine(folder, $"CoinJoins{network}.txt");
@@ -3356,7 +3356,7 @@ namespace WalletWasabi.Tests
// 3. Create wasabi synchronizer service.
var synchronizer = new WasabiSynchronizer(network, bitcoinStore, new Uri(RegTestFixture.BackendEndPoint), null);
- var indexFilePath2 = Path.Combine(Global.Instance.DataDir, nameof(CoinJoinMultipleRoundTestsAsync), $"Index{network}2.dat");
+ var indexFilePath2 = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName(), $"Index{network}2.dat");
var synchronizer2 = new WasabiSynchronizer(network, bitcoinStore, new Uri(RegTestFixture.BackendEndPoint), null);
// 4. Create key manager service.
@@ -3370,11 +3370,11 @@ namespace WalletWasabi.Tests
var chaumianClient2 = new CcjClient(synchronizer, network, keyManager2, new Uri(RegTestFixture.BackendEndPoint), null);
// 6. Create wallet service.
- var workDir = Path.Combine(Global.Instance.DataDir, nameof(CoinJoinMultipleRoundTestsAsync));
+ var workDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
var wallet = new WalletService(bitcoinStore, keyManager, synchronizer, chaumianClient, mempoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
- var workDir2 = Path.Combine(Global.Instance.DataDir, $"{nameof(CoinJoinMultipleRoundTestsAsync)}2");
+ var workDir2 = Path.Combine(Global.Instance.DataDir, $"{EnvironmentHelpers.GetMethodName()}2");
var wallet2 = new WalletService(bitcoinStore, keyManager2, synchronizer2, chaumianClient2, mempoolService2, nodes2, workDir2, serviceConfiguration);
// Get some money, make it confirm.

MODIFY
WalletWasabi.Tests/StoreTests.cs
WalletWasabi.Tests/StoreTests.cs
@@ -176,7 +176,7 @@ namespace WalletWasabi.Tests
{
var indexStore = new IndexStore();
- var dir = Path.Combine(Global.Instance.DataDir, nameof(IndexStoreTestsAsync));
+ var dir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName());
var network = Network.Main;
await indexStore.InitializeAsync(dir, network, new HashChain());
}
@@ -341,8 +341,8 @@ namespace WalletWasabi.Tests
[Fact]
public async Task IoManagerTestsAsync()
{
- var file1 = Path.Combine(Global.Instance.DataDir, nameof(IoManagerTestsAsync), $"file1.dat");
- var file2 = Path.Combine(Global.Instance.DataDir, nameof(IoManagerTestsAsync), $"file2.dat");
+ var file1 = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName(), $"file1.dat");
+ var file2 = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName(), $"file2.dat");
Random random = new Random();
List<string> lines = new List<string>();
@@ -546,7 +546,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task IoTestsAsync()
{
- var file = Path.Combine(Global.Instance.DataDir, nameof(IoTestsAsync), $"file.dat");
+ var file = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetMethodName(), $"file.dat");
DigestableSafeMutexIoManager ioman = new DigestableSafeMutexIoManager(file);
ioman.DeleteMe();

MODIFY
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
@@ -27,7 +27,7 @@ namespace WalletWasabi.Tests.XunitConfiguration
public RegTestFixture()
{
- BackendNodeBuilder = NodeBuilder.CreateAsync(nameof(RegTestFixture)).GetAwaiter().GetResult();
+ BackendNodeBuilder = NodeBuilder.CreateAsync(EnvironmentHelpers.GetMethodName()).GetAwaiter().GetResult();
BackendNodeBuilder.CreateNodeAsync().GetAwaiter().GetResult();
BackendNodeBuilder.StartAllAsync().GetAwaiter().GetResult();
BackendRegTestNode = BackendNodeBuilder.Nodes[0];

MODIFY
WalletWasabi/Helpers/EnvironmentHelpers.cs
WalletWasabi/Helpers/EnvironmentHelpers.cs
@@ -3,6 +3,7 @@ using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.IO;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using WalletWasabi.Logging;
@@ -186,5 +187,13 @@ namespace WalletWasabi.Helpers
}
return false;
}
+
+ /// <summary>
+ /// Gets the name of the current method.
+ /// </summary>
+ public static string GetMethodName([CallerMemberName] string callerName = "")
+ {
+ return callerName;
+ }
}
}

Use [CallerMemberName] instead of nameof