Use new keyword in most modified files
MODIFY
WalletWasabi.Tests/IntegrationTests/LiveServerTests.cs
WalletWasabi.Tests/IntegrationTests/LiveServerTests.cs
@@ -26,8 +26,8 @@ namespace WalletWasabi.Tests.IntegrationTests
{
LiveServerTestsFixture = liveServerTestsFixture;
- TorHttpPool = new TorHttpPool(new TorTcpConnectionFactory(Common.TorSocks5Endpoint));
- TorManager = new TorProcessManager(Common.TorSettings, Common.TorSocks5Endpoint);
+ TorHttpPool = new(new TorTcpConnectionFactory(Common.TorSocks5Endpoint));
+ TorManager = new(Common.TorSettings, Common.TorSocks5Endpoint);
}
private TorProcessManager TorManager { get; }
@@ -55,7 +55,7 @@ namespace WalletWasabi.Tests.IntegrationTests
Network network = (networkType == NetworkType.Mainnet) ? Network.Main : Network.TestNet;
TorHttpClient torHttpClient = MakeTorHttpClient(networkType);
- var client = new WasabiClient(torHttpClient);
+ WasabiClient client = new(torHttpClient);
var filterModel = StartingFilters.GetStartingFilter(network);
@@ -71,7 +71,7 @@ namespace WalletWasabi.Tests.IntegrationTests
public async Task GetAllRoundStatesAsync(NetworkType networkType)
{
TorHttpClient torHttpClient = MakeTorHttpClient(networkType);
- var client = new SatoshiClient(torHttpClient);
+ SatoshiClient client = new(torHttpClient);
var states = await client.GetAllRoundStatesAsync();
Assert.True(states.NotNullAndNotEmpty());
Assert.True(states.Any());
@@ -83,7 +83,7 @@ namespace WalletWasabi.Tests.IntegrationTests
public async Task GetTransactionsAsync(NetworkType networkType)
{
TorHttpClient torHttpClient = MakeTorHttpClient(networkType);
- var client = new WasabiClient(torHttpClient);
+ WasabiClient client = new(torHttpClient);
var randomTxIds = Enumerable.Range(0, 20).Select(_ => RandomUtils.GetUInt256());
var network = networkType == NetworkType.Mainnet ? Network.Main : Network.TestNet;
@@ -109,7 +109,7 @@ namespace WalletWasabi.Tests.IntegrationTests
public async Task GetExchangeRateAsync(NetworkType networkType) // xunit wtf: If this function is called GetExchangeRatesAsync, it'll stuck on 1 CPU VMs (Manjuro, Fedora)
{
TorHttpClient torHttpClient = MakeTorHttpClient(networkType);
- var client = new WasabiClient(torHttpClient);
+ WasabiClient client = new(torHttpClient);
var exchangeRates = await client.GetExchangeRatesAsync();
@@ -126,13 +126,13 @@ namespace WalletWasabi.Tests.IntegrationTests
public async Task GetVersionsTestsAsync(NetworkType networkType)
{
TorHttpClient torHttpClient = MakeTorHttpClient(networkType);
- var client = new WasabiClient(torHttpClient);
+ WasabiClient client = new(torHttpClient);
var versions = await client.GetVersionsAsync(CancellationToken.None);
- Assert.InRange(versions.ClientVersion, new Version(1, 1, 10), new Version(1, 2));
- Assert.InRange(versions.ClientVersion, new Version(1, 1, 10), WalletWasabi.Helpers.Constants.ClientVersion);
+ Assert.InRange(versions.ClientVersion, new(1, 1, 10), new(1, 2));
+ Assert.InRange(versions.ClientVersion, new(1, 1, 10), WalletWasabi.Helpers.Constants.ClientVersion);
Assert.Equal(4, versions.BackendMajorVersion);
- Assert.Equal(new Version(2, 0), versions.LegalDocumentsVersion);
+ Assert.Equal(new(2, 0), versions.LegalDocumentsVersion);
}
[Theory]
@@ -141,13 +141,13 @@ namespace WalletWasabi.Tests.IntegrationTests
public async Task CheckUpdatesTestsAsync(NetworkType networkType)
{
TorHttpClient torHttpClient = MakeTorHttpClient(networkType);
- var client = new WasabiClient(torHttpClient);
+ WasabiClient client = new(torHttpClient);
var updateStatus = await client.CheckUpdatesAsync(CancellationToken.None);
- var expectedVersion = new Version(2, 0);
+ Version expectedVersion = new(2, 0);
ushort backendVersion = 4;
- Assert.Equal(new UpdateStatus(true, true, expectedVersion, backendVersion), updateStatus);
+ Assert.Equal(new(true, true, expectedVersion, backendVersion), updateStatus);
Assert.True(updateStatus.BackendCompatible);
Assert.True(updateStatus.ClientUpToDate);
Assert.Equal(expectedVersion, updateStatus.LegalDocumentsVersion);
@@ -167,7 +167,7 @@ namespace WalletWasabi.Tests.IntegrationTests
public async Task GetLegalDocumentsTestsAsync(NetworkType networkType)
{
TorHttpClient torHttpClient = MakeTorHttpClient(networkType);
- var client = new WasabiClient(torHttpClient);
+ WasabiClient client = new(torHttpClient);
var content = await client.GetLegalDocumentsAsync(CancellationToken.None);
@@ -182,7 +182,7 @@ namespace WalletWasabi.Tests.IntegrationTests
private TorHttpClient MakeTorHttpClient(NetworkType networkType)
{
Uri baseUri = LiveServerTestsFixture.UriMappings[networkType];
- return new TorHttpClient(baseUri, TorHttpPool);
+ return new(baseUri, TorHttpPool);
}
}
}

MODIFY
WalletWasabi.Tests/IntegrationTests/TorTests.cs
WalletWasabi.Tests/IntegrationTests/TorTests.cs
@@ -17,7 +17,7 @@ namespace WalletWasabi.Tests.IntegrationTests
{
public TorTests()
{
- TorHttpPool = new TorHttpPool(new TorTcpConnectionFactory(Common.TorSocks5Endpoint));
+ TorHttpPool = new(new TorTcpConnectionFactory(Common.TorSocks5Endpoint));
TorManager = new(Common.TorSettings, Common.TorSocks5Endpoint);
}
@@ -38,7 +38,7 @@ namespace WalletWasabi.Tests.IntegrationTests
[Fact]
public async Task CanDoRequestManyDifferentAsync()
{
- TorHttpClient client = MakeTorHttpClient(new Uri("http://api.qbit.ninja"));
+ TorHttpClient client = MakeTorHttpClient(new("http://api.qbit.ninja"));
await QBitTestAsync(client, 10, alterRequests: true);
}
@@ -47,7 +47,7 @@ namespace WalletWasabi.Tests.IntegrationTests
{
using CancellationTokenSource ctsTimeout = new(TimeSpan.FromMinutes(2));
- TorHttpClient client = MakeTorHttpClient(new Uri("http://anglesharp.azurewebsites.net/"));
+ TorHttpClient client = MakeTorHttpClient(new("http://anglesharp.azurewebsites.net/"));
var response = await client.SendAsync(HttpMethod.Get, "Chunked", null, ctsTimeout.Token);
var content = await response.Content.ReadAsStringAsync(ctsTimeout.Token);
Assert.Contains("Chunked transfer encoding test", content);
@@ -60,7 +60,7 @@ namespace WalletWasabi.Tests.IntegrationTests
{
using CancellationTokenSource ctsTimeout = new(TimeSpan.FromMinutes(2));
- TorHttpClient client = MakeTorHttpClient(new Uri("https://postman-echo.com"));
+ TorHttpClient client = MakeTorHttpClient(new("https://postman-echo.com"));
using HttpContent content = new StringContent("This is expected to be sent back as part of response body.");
HttpResponseMessage message = await client.SendAsync(HttpMethod.Post, "post", content, ctsTimeout.Token);
@@ -88,7 +88,7 @@ namespace WalletWasabi.Tests.IntegrationTests
// 2. Get Tor IP
{
- TorHttpClient torClient = MakeTorHttpClient(new Uri(requestUri));
+ TorHttpClient torClient = MakeTorHttpClient(new(requestUri));
var content = await (await torClient.SendAsync(HttpMethod.Get, "", null, ctsTimeout.Token)).Content.ReadAsStringAsync(ctsTimeout.Token);
var gotIp = IPAddress.TryParse(content.Replace("\n", ""), out torIp);
Assert.True(gotIp);
@@ -102,7 +102,7 @@ namespace WalletWasabi.Tests.IntegrationTests
{
using CancellationTokenSource ctsTimeout = new(TimeSpan.FromMinutes(2));
- TorHttpClient client = MakeTorHttpClient(new Uri("https://postman-echo.com"));
+ TorHttpClient client = MakeTorHttpClient(new("https://postman-echo.com"));
using HttpResponseMessage httpResponseMessage = await client.SendAsync(HttpMethod.Get, "get?foo1=bar1&foo2=bar2", null, ctsTimeout.Token);
var content = await httpResponseMessage.Content.ReadAsStringAsync(ctsTimeout.Token);
@@ -114,7 +114,7 @@ namespace WalletWasabi.Tests.IntegrationTests
{
using CancellationTokenSource ctsTimeout = new(TimeSpan.FromMinutes(2));
- TorHttpClient client = MakeTorHttpClient(new Uri("http://172.217.6.142"));
+ TorHttpClient client = MakeTorHttpClient(new("http://172.217.6.142"));
HttpResponseMessage httpResponseMessage = await client.SendAsync(HttpMethod.Get, relativeUri: "", content: null, ctsTimeout.Token);
string content = await httpResponseMessage.Content.ReadAsStringAsync(ctsTimeout.Token);
@@ -126,7 +126,7 @@ namespace WalletWasabi.Tests.IntegrationTests
{
using CancellationTokenSource ctsTimeout = new(TimeSpan.FromMinutes(2));
- TorHttpClient client = MakeTorHttpClient(new Uri("http://api.qbit.ninja"));
+ TorHttpClient client = MakeTorHttpClient(new("http://api.qbit.ninja"));
await (await client.SendAsync(HttpMethod.Get, "/transactions/38d4cfeb57d6685753b7a3b3534c3cb576c34ca7344cd4582f9613ebf0c2b02a?format=json&headeronly=true", null, ctsTimeout.Token)).Content.ReadAsStringAsync(ctsTimeout.Token);
await (await client.SendAsync(HttpMethod.Get, "/balances/15sYbVpRh6dyWycZMwPdxJWD4xbfxReeHe?unspentonly=true", null, ctsTimeout.Token)).Content.ReadAsStringAsync(ctsTimeout.Token);
await (await client.SendAsync(HttpMethod.Get, "balances/akEBcY5k1dn2yeEdFnTMwdhVbHxtgHb6GGi?from=tip&until=336000", null, ctsTimeout.Token)).Content.ReadAsStringAsync(ctsTimeout.Token);
@@ -137,7 +137,7 @@ namespace WalletWasabi.Tests.IntegrationTests
{
using CancellationTokenSource ctsTimeout = new(TimeSpan.FromMinutes(2));
- TorHttpClient client = MakeTorHttpClient(new Uri("http://expyuzz4wqqyqhjn.onion/"));
+ TorHttpClient client = MakeTorHttpClient(new("http://expyuzz4wqqyqhjn.onion/"));
HttpResponseMessage response = await client.SendAsync(HttpMethod.Get, relativeUri: "", null, ctsTimeout.Token);
var content = await response.Content.ReadAsStringAsync(ctsTimeout.Token);
@@ -151,7 +151,7 @@ namespace WalletWasabi.Tests.IntegrationTests
{
using CancellationTokenSource ctsTimeout = new(TimeSpan.FromMinutes(2));
- TorHttpClient client = MakeTorHttpClient(new Uri("http://www.dds6qkxpwdeubwucdiaord2xgbbeyds25rbsgr73tbfpqpt4a6vjwsyd.onion"));
+ TorHttpClient client = MakeTorHttpClient(new("http://www.dds6qkxpwdeubwucdiaord2xgbbeyds25rbsgr73tbfpqpt4a6vjwsyd.onion"));
HttpResponseMessage response = await client.SendAsync(HttpMethod.Get, "", null, ctsTimeout.Token);
var content = await response.Content.ReadAsStringAsync();
@@ -165,9 +165,9 @@ namespace WalletWasabi.Tests.IntegrationTests
{
using CancellationTokenSource ctsTimeout = new(TimeSpan.FromMinutes(2));
- TorHttpClient c1 = MakeTorHttpClient(new Uri("http://api.ipify.org"));
- TorHttpClient c2 = MakeTorHttpClient(new Uri("http://api.ipify.org"));
- TorHttpClient c3 = MakeTorHttpClient(new Uri("http://api.ipify.org"));
+ TorHttpClient c1 = MakeTorHttpClient(new("http://api.ipify.org"));
+ TorHttpClient c2 = MakeTorHttpClient(new("http://api.ipify.org"));
+ TorHttpClient c3 = MakeTorHttpClient(new("http://api.ipify.org"));
Task<HttpResponseMessage> t1 = c1.SendAsync(HttpMethod.Get, "", null, ctsTimeout.Token);
Task<HttpResponseMessage> t2 = c2.SendAsync(HttpMethod.Get, "", null, ctsTimeout.Token);
Task<HttpResponseMessage> t3 = c3.SendAsync(HttpMethod.Get, "", null, ctsTimeout.Token);
@@ -187,9 +187,9 @@ namespace WalletWasabi.Tests.IntegrationTests
{
using CancellationTokenSource ctsTimeout = new(TimeSpan.FromMinutes(2));
- TorHttpClient c1 = MakeTorHttpClient(new Uri("http://api.ipify.org"), isolateStream: true);
- TorHttpClient c2 = MakeTorHttpClient(new Uri("http://api.ipify.org"), isolateStream: true);
- TorHttpClient c3 = MakeTorHttpClient(new Uri("http://api.ipify.org"), isolateStream: true);
+ TorHttpClient c1 = MakeTorHttpClient(new("http://api.ipify.org"), isolateStream: true);
+ TorHttpClient c2 = MakeTorHttpClient(new("http://api.ipify.org"), isolateStream: true);
+ TorHttpClient c3 = MakeTorHttpClient(new("http://api.ipify.org"), isolateStream: true);
Task<HttpResponseMessage> t1 = c1.SendAsync(HttpMethod.Get, "", null, ctsTimeout.Token);
Task<HttpResponseMessage> t2 = c2.SendAsync(HttpMethod.Get, "", null, ctsTimeout.Token);
Task<HttpResponseMessage> t3 = c3.SendAsync(HttpMethod.Get, "", null, ctsTimeout.Token);
@@ -220,13 +220,13 @@ namespace WalletWasabi.Tests.IntegrationTests
var relativetUri = "/whatisit/what%20is%20my%20future";
- var tasks = new List<Task<HttpResponseMessage>>();
+ List<Task<HttpResponseMessage>> tasks = new();
for (var i = 0; i < times; i++)
{
var task = client.SendAsync(HttpMethod.Get, relativetUri);
if (alterRequests)
{
- TorHttpClient ipClient = MakeTorHttpClient(new Uri("https://api.ipify.org/"));
+ TorHttpClient ipClient = MakeTorHttpClient(new("https://api.ipify.org/"));
var task2 = ipClient.SendAsync(HttpMethod.Get, "/", null, ctsTimeout.Token);
tasks.Add(task2);
}
@@ -235,7 +235,7 @@ namespace WalletWasabi.Tests.IntegrationTests
await Task.WhenAll(tasks);
- var contents = new List<string>();
+ List<string> contents = new();
foreach (var task in tasks)
{
contents.Add(await (await task).Content.ReadAsStringAsync(ctsTimeout.Token));
@@ -246,7 +246,7 @@ namespace WalletWasabi.Tests.IntegrationTests
private TorHttpClient MakeTorHttpClient(Uri uri, bool isolateStream = false)
{
- return new TorHttpClient(uri, TorHttpPool, isolateStream);
+ return new(uri, TorHttpPool, isolateStream);
}
}
}

MODIFY
WalletWasabi.Tests/UnitTests/Tor/Socks5/TorHttpPoolTests.cs
WalletWasabi.Tests/UnitTests/Tor/Socks5/TorHttpPoolTests.cs
@@ -105,8 +105,8 @@ namespace WalletWasabi.Tests.UnitTests.Tor.Socks5
int n = new Random().Next(0, 1_000_000);
string pipeName = $"{testName}.Pipe.{n}";
- Server = new NamedPipeServerStream(pipeName, PipeDirection.InOut, maxNumberOfServerInstances: 4, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
- Client = new NamedPipeClientStream(".", pipeName, PipeDirection.InOut, PipeOptions.Asynchronous);
+ Server = new(pipeName, PipeDirection.InOut, maxNumberOfServerInstances: 4, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
+ Client = new(".", pipeName, PipeDirection.InOut, PipeOptions.Asynchronous);
}
public NamedPipeServerStream Server { get; }

MODIFY
WalletWasabi.Tests/UnitTests/Tor/Socks5/TorTcpConnectionFactoryTests.cs
WalletWasabi.Tests/UnitTests/Tor/Socks5/TorTcpConnectionFactoryTests.cs
@@ -159,7 +159,7 @@ namespace WalletWasabi.Tests.UnitTests.Tor.Socks5
stream.WriteByte(MethodField.NoAuthenticationRequired.ToByte());
stream.Flush();
- TorSocks5Request expectedConnectionRequest = new(cmd: CmdField.Connect, new AddrField(httpRequestHost), new PortField(httpRequestPort));
+ TorSocks5Request expectedConnectionRequest = new(cmd: CmdField.Connect, new(httpRequestHost), new(httpRequestPort));
int i = 0;
foreach (byte byteValue in expectedConnectionRequest.ToBytes())

MODIFY
WalletWasabi/Tor/Http/IHttpClient.cs
WalletWasabi/Tor/Http/IHttpClient.cs
@@ -33,8 +33,8 @@ namespace WalletWasabi.Tor.Http
throw new InvalidOperationException("Base URI is not set.");
}
- var requestUri = new Uri(baseUri, relativeUri);
- using var httpRequestMessage = new HttpRequestMessage(method, requestUri);
+ Uri requestUri = new(baseUri, relativeUri);
+ using HttpRequestMessage httpRequestMessage = new(method, requestUri);
if (content is { })
{

MODIFY
WalletWasabi/Tor/Socks5/Pool/TorHttpPool.cs
WalletWasabi/Tor/Socks5/Pool/TorHttpPool.cs
@@ -32,7 +32,7 @@ namespace WalletWasabi.Tor.Socks5.Pool
public TorHttpPool(EndPoint endpoint)
{
- TcpConnectionFactory = new TorTcpConnectionFactory(endpoint);
+ TcpConnectionFactory = new(endpoint);
}
/// <summary>Use in tests.</summary>
@@ -45,10 +45,10 @@ namespace WalletWasabi.Tor.Socks5.Pool
/// <summary>Key is always a URI host. Value is a list of pool connections that can connect to the URI host.</summary>
/// <remarks>All access to this object must be guarded by <see cref="ObtainPoolConnectionLock"/>.</remarks>
- private Dictionary<string, List<TorTcpConnection>> ConnectionPerHost { get; } = new Dictionary<string, List<TorTcpConnection>>();
+ private Dictionary<string, List<TorTcpConnection>> ConnectionPerHost { get; } = new();
/// <remarks>Lock object required for the combination of <see cref="TorTcpConnection"/> selection or creation in <see cref="ObtainFreeConnectionAsync(HttpRequestMessage, bool, CancellationToken)"/>.</remarks>
- private AsyncLock ObtainPoolConnectionLock { get; } = new AsyncLock();
+ private AsyncLock ObtainPoolConnectionLock { get; } = new();
private TorTcpConnectionFactory TcpConnectionFactory { get; }
@@ -246,7 +246,7 @@ namespace WalletWasabi.Tor.Socks5.Pool
// other than those acting as tunnels) MUST send their own HTTP - version
// in forwarded messages.
request.Version = HttpProtocol.HTTP11.Version;
- request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
+ request.Headers.AcceptEncoding.Add(new("gzip"));
string requestString = await request.ToHttpStringAsync(token).ConfigureAwait(false);
byte[] bytes = Encoding.UTF8.GetBytes(requestString);
@@ -279,7 +279,7 @@ namespace WalletWasabi.Tor.Socks5.Pool
{
if (!ConnectionPerHost.ContainsKey(host))
{
- ConnectionPerHost.Add(host, new List<TorTcpConnection>());
+ ConnectionPerHost.Add(host, new());
}
List<TorTcpConnection> hostConnections = ConnectionPerHost[host];

MODIFY
WalletWasabi/Tor/Socks5/TorTcpConnection.cs
WalletWasabi/Tor/Socks5/TorTcpConnection.cs
@@ -30,7 +30,7 @@ namespace WalletWasabi.Tor.Socks5
}
/// <remarks>Lock object to guard <see cref="State"/> property.</remarks>
- private object StateLock { get; } = new object();
+ private object StateLock { get; } = new();
/// <remarks>All access to this property must be guarded by <see cref="StateLock"/>.</remarks>
public TcpConnectionState State { get; private set; }

MODIFY
WalletWasabi/Tor/Socks5/TorTcpConnectionFactory.cs
WalletWasabi/Tor/Socks5/TorTcpConnectionFactory.cs
@@ -60,7 +60,7 @@ namespace WalletWasabi.Tor.Socks5
try
{
- tcpClient = new TcpClient(TorSocks5EndPoint.AddressFamily);
+ tcpClient = new(TorSocks5EndPoint.AddressFamily);
transportStream = await ConnectAsync(tcpClient, cancellationToken).ConfigureAwait(false);
await HandshakeAsync(tcpClient, isolateStream, cancellationToken).ConfigureAwait(false);
@@ -118,7 +118,7 @@ namespace WalletWasabi.Tor.Socks5
try
{
// Internal TCP client may close, so we need a new instance here.
- using var tcpClient = new TcpClient(TorSocks5EndPoint.AddressFamily);
+ using TcpClient tcpClient = new(TorSocks5EndPoint.AddressFamily);
await ConnectAsync(tcpClient).ConfigureAwait(false);
await HandshakeAsync(tcpClient, isolateStream: false).ConfigureAwait(false);
@@ -152,7 +152,7 @@ namespace WalletWasabi.Tor.Socks5
// username / password fields of this message to be empty. This technically
// violates RFC1929[4], but ensures interoperability with somewhat broken
// SOCKS5 client implementations.
- var methods = new MethodsField(isolateStream ? MethodField.UsernamePassword : MethodField.NoAuthenticationRequired);
+ MethodsField methods = new(isolateStream ? MethodField.UsernamePassword : MethodField.NoAuthenticationRequired);
byte[] receiveBuffer = await SendRequestAsync(tcpClient, new VersionMethodRequest(methods), cancellationToken).ConfigureAwait(false);
@@ -177,13 +177,13 @@ namespace WalletWasabi.Tor.Socks5
// sub-negotiation begins. This begins with the client producing a
// Username / Password request:
var identity = RandomString.CapitalAlphaNumeric(21);
- var uName = new UNameField(uName: identity);
- var passwd = new PasswdField(password: identity);
- var usernamePasswordRequest = new UsernamePasswordRequest(uName, passwd);
+ UNameField uName = new(uName: identity);
+ PasswdField passwd = new(password: identity);
+ UsernamePasswordRequest usernamePasswordRequest = new(uName, passwd);
receiveBuffer = await SendRequestAsync(tcpClient, usernamePasswordRequest, cancellationToken).ConfigureAwait(false);
- var userNamePasswordResponse = new UsernamePasswordResponse(receiveBuffer);
+ UsernamePasswordResponse userNamePasswordResponse = new(receiveBuffer);
if (userNamePasswordResponse.Ver != usernamePasswordRequest.Ver)
{
@@ -204,7 +204,7 @@ namespace WalletWasabi.Tor.Socks5
private static async Task<SslStream> UpgradeToSslAsync(TcpClient tcpClient, string host)
{
SslStream sslStream = new(tcpClient.GetStream(), leaveInnerStreamOpen: true);
- await sslStream.AuthenticateAsClientAsync(host, new X509CertificateCollection(), true).ConfigureAwait(false);
+ await sslStream.AuthenticateAsClientAsync(host, new(), true).ConfigureAwait(false);
return sslStream;
}
@@ -227,7 +227,7 @@ namespace WalletWasabi.Tor.Socks5
try
{
- TorSocks5Request connectionRequest = new(cmd: CmdField.Connect, new AddrField(host), new PortField(port));
+ TorSocks5Request connectionRequest = new(cmd: CmdField.Connect, new(host), new(port));
byte[] receiveBuffer = await SendRequestAsync(tcpClient, connectionRequest, cancellationToken).ConfigureAwait(false);

MODIFY
WalletWasabi/Tor/TorProcessManager.cs
WalletWasabi/Tor/TorProcessManager.cs
@@ -27,7 +27,7 @@ namespace WalletWasabi.Tor
TorSocks5EndPoint = torSocks5EndPoint;
TorProcess = null;
Settings = settings;
- TcpConnectionFactory = new TorTcpConnectionFactory(torSocks5EndPoint);
+ TcpConnectionFactory = new(torSocks5EndPoint);
IoHelpers.EnsureContainingDirectoryExists(Settings.LogFilePath);
}
@@ -89,7 +89,7 @@ namespace WalletWasabi.Tor
Logger.LogDebug($"Environment variable 'LD_LIBRARY_PATH' set to: '{env["LD_LIBRARY_PATH"]}'.");
}
- TorProcess = new ProcessAsync(startInfo);
+ TorProcess = new(startInfo);
Logger.LogInfo($"Starting Tor process ...");
TorProcess.Start();
@@ -147,7 +147,7 @@ namespace WalletWasabi.Tor
try
{
TorProcess.Kill();
- using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1));
+ using CancellationTokenSource cts = new(TimeSpan.FromMinutes(1));
await TorProcess.WaitForExitAsync(cts.Token, killOnCancel: true).ConfigureAwait(false);
Logger.LogInfo($"Tor process killed successfully.");

MODIFY
WalletWasabi/WebClients/Wasabi/HttpClientFactory.cs
WalletWasabi/WebClients/Wasabi/HttpClientFactory.cs
@@ -24,14 +24,14 @@ namespace WalletWasabi.WebClients.Wasabi
/// <param name="torEndPoint">If <c>null</c> then clearnet (not over Tor) is used, otherwise HTTP requests are routed through provided Tor endpoint.</param>
public HttpClientFactory(EndPoint? torEndPoint, Func<Uri> backendUriGetter)
{
- SocketHandler = new SocketsHttpHandler()
+ SocketHandler = new()
{
// Only GZip is currently used by Wasabi Backend.
AutomaticDecompression = DecompressionMethods.GZip,
PooledConnectionLifetime = TimeSpan.FromMinutes(5)
};
- HttpClient = new HttpClient(SocketHandler);
+ HttpClient = new(SocketHandler);
TorEndpoint = torEndPoint;
BackendUriGetter = backendUriGetter;
@@ -39,7 +39,7 @@ namespace WalletWasabi.WebClients.Wasabi
// Connecting to loopback's URIs cannot be done via Tor.
if (TorEndpoint is { } && !BackendUriGetter().IsLoopback)
{
- TorHttpPool = new TorHttpPool(TorEndpoint);
+ TorHttpPool = new(TorEndpoint);
BackendHttpClient = new TorHttpClient(BackendUriGetter, TorHttpPool, isolateStream: false);
}
else
@@ -47,7 +47,7 @@ namespace WalletWasabi.WebClients.Wasabi
BackendHttpClient = new ClearnetHttpClient(HttpClient, BackendUriGetter);
}
- SharedWasabiClient = new WasabiClient(BackendHttpClient);
+ SharedWasabiClient = new(BackendHttpClient);
}
/// <summary>Tor SOCKS5 endpoint.</summary>

Use new keyword in most modified files