Simplify object initializations in library project
MODIFY
WalletWasabi/BitcoinCore/Configuration/Whitening/WhiteEntry.cs
WalletWasabi/BitcoinCore/Configuration/Whitening/WhiteEntry.cs
@@ -19,8 +19,10 @@ namespace WalletWasabi.BitcoinCore.Configuration.Whitening
{
if (EndPointParser.TryParse(parts.LastOrDefault(), network.DefaultPort, out EndPoint endPoint))
{
- whiteEntry = new T();
- whiteEntry.EndPoint = endPoint;
+ whiteEntry = new T
+ {
+ EndPoint = endPoint
+ };
if (parts.Length > 1)
{
whiteEntry.Permissions = parts.First();

MODIFY
WalletWasabi/BitcoinCore/CoreNode.cs
WalletWasabi/BitcoinCore/CoreNode.cs
@@ -44,11 +44,13 @@ namespace WalletWasabi.BitcoinCore
Guard.NotNull(nameof(coreNodeParams), coreNodeParams);
using (BenchmarkLogger.Measure())
{
- var coreNode = new CoreNode();
- coreNode.HostedServices = coreNodeParams.HostedServices;
- coreNode.DataDir = coreNodeParams.DataDir;
- coreNode.Network = coreNodeParams.Network;
- coreNode.MempoolService = coreNodeParams.MempoolService;
+ var coreNode = new CoreNode
+ {
+ HostedServices = coreNodeParams.HostedServices,
+ DataDir = coreNodeParams.DataDir,
+ Network = coreNodeParams.Network,
+ MempoolService = coreNodeParams.MempoolService
+ };
var configPath = Path.Combine(coreNode.DataDir, "bitcoin.conf");
coreNode.Config = new CoreConfig();

MODIFY
WalletWasabi/WebClients/Bitstamp/BitstampExchangeRateProvider.cs
WalletWasabi/WebClients/Bitstamp/BitstampExchangeRateProvider.cs
@@ -12,8 +12,10 @@ namespace WalletWasabi.WebClients.Bitstamp
{
public async Task<IEnumerable<ExchangeRate>> GetExchangeRateAsync()
{
- using var httpClient = new HttpClient();
- httpClient.BaseAddress = new Uri("https://www.bitstamp.net");
+ using var httpClient = new HttpClient
+ {
+ BaseAddress = new Uri("https://www.bitstamp.net")
+ };
using var response = await httpClient.GetAsync("/api/v2/ticker/btcusd").ConfigureAwait(false);
using var content = response.Content;
var rate = await content.ReadAsJsonAsync<BitstampExchangeRate>().ConfigureAwait(false);

MODIFY
WalletWasabi/WebClients/BlockchainInfo/BlockchainInfoExchangeRateProvider.cs
WalletWasabi/WebClients/BlockchainInfo/BlockchainInfoExchangeRateProvider.cs
@@ -12,8 +12,10 @@ namespace WalletWasabi.WebClients.BlockchainInfo
{
public async Task<IEnumerable<ExchangeRate>> GetExchangeRateAsync()
{
- using var httpClient = new HttpClient();
- httpClient.BaseAddress = new Uri("https://blockchain.info");
+ using var httpClient = new HttpClient
+ {
+ BaseAddress = new Uri("https://blockchain.info")
+ };
using var response = await httpClient.GetAsync("/ticker").ConfigureAwait(false);
using var content = response.Content;
var rates = await content.ReadAsJsonAsync<BlockchainInfoExchangeRates>().ConfigureAwait(false);

MODIFY
WalletWasabi/WebClients/CoinGecko/CoinGeckoExchangeRateProvider.cs
WalletWasabi/WebClients/CoinGecko/CoinGeckoExchangeRateProvider.cs
@@ -12,8 +12,10 @@ namespace WalletWasabi.WebClients.CoinGecko
{
public async Task<IEnumerable<ExchangeRate>> GetExchangeRateAsync()
{
- using var httpClient = new HttpClient();
- httpClient.BaseAddress = new Uri("https://api.coingecko.com");
+ using var httpClient = new HttpClient
+ {
+ BaseAddress = new Uri("https://api.coingecko.com")
+ };
using var response = await httpClient.GetAsync("/api/v3/coins/markets?vs_currency=usd&ids=bitcoin").ConfigureAwait(false);
using var content = response.Content;
var rates = await content.ReadAsJsonAsync<CoinGeckoExchangeRate[]>().ConfigureAwait(false);

MODIFY
WalletWasabi/WebClients/Coinbase/CoinbaseExchangeRateProvider.cs
WalletWasabi/WebClients/Coinbase/CoinbaseExchangeRateProvider.cs
@@ -12,8 +12,10 @@ namespace WalletWasabi.WebClients.Coinbase
{
public async Task<IEnumerable<ExchangeRate>> GetExchangeRateAsync()
{
- using var httpClient = new HttpClient();
- httpClient.BaseAddress = new Uri("https://api.coinbase.com");
+ using var httpClient = new HttpClient
+ {
+ BaseAddress = new Uri("https://api.coinbase.com")
+ };
using var response = await httpClient.GetAsync("/v2/exchange-rates?currency=BTC").ConfigureAwait(false);
using var content = response.Content;
var wrapper = await content.ReadAsJsonAsync<DataWrapper>().ConfigureAwait(false);

MODIFY
WalletWasabi/WebClients/Gemini/GeminiExchangeRateProvider.cs
WalletWasabi/WebClients/Gemini/GeminiExchangeRateProvider.cs
@@ -12,8 +12,10 @@ namespace WalletWasabi.WebClients.Gemini
{
public async Task<IEnumerable<ExchangeRate>> GetExchangeRateAsync()
{
- using var httpClient = new HttpClient();
- httpClient.BaseAddress = new Uri("https://api.gemini.com");
+ using var httpClient = new HttpClient
+ {
+ BaseAddress = new Uri("https://api.gemini.com")
+ };
using var response = await httpClient.GetAsync("/v1/pubticker/btcusd").ConfigureAwait(false);
using var content = response.Content;
var data = await content.ReadAsJsonAsync<GeminiExchangeRateInfo>().ConfigureAwait(false);

MODIFY
WalletWasabi/WebClients/ItBit/ItBitExchangeRateProvider.cs
WalletWasabi/WebClients/ItBit/ItBitExchangeRateProvider.cs
@@ -12,8 +12,10 @@ namespace WalletWasabi.WebClients.ItBit
{
public async Task<IEnumerable<ExchangeRate>> GetExchangeRateAsync()
{
- using var httpClient = new HttpClient();
- httpClient.BaseAddress = new Uri("https://api.itbit.com");
+ using var httpClient = new HttpClient
+ {
+ BaseAddress = new Uri("https://api.itbit.com")
+ };
using var response = await httpClient.GetAsync("v1/markets/XBTUSD/ticker").ConfigureAwait(false);
using var content = response.Content;
var data = await content.ReadAsJsonAsync<ItBitExchangeRateInfo>().ConfigureAwait(false);

MODIFY
WalletWasabi/WebClients/PayJoin/PayjoinClient.cs
WalletWasabi/WebClients/PayJoin/PayjoinClient.cs
@@ -297,8 +297,10 @@ namespace WalletWasabi.WebClients.PayJoin
}
// Remove query from endpoint.
- var builder = new UriBuilder(endpoint);
- builder.Query = "";
+ var builder = new UriBuilder(endpoint)
+ {
+ Query = ""
+ };
// Construct final URI.
return new Uri(QueryHelpers.AddQueryString(builder.Uri.AbsoluteUri, parameters));

Simplify object initializations in library project