Refactor existing conditional expression
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
@@ -492,11 +492,11 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
SetSelections();
SelectionChanged?.Invoke(this, cvm);
SelectedAmount = Coins.Where(x => x.IsSelected).Sum(x => x.Amount);
- LabelExposeCommonOwnershipWarning = CoinListContainerType == CoinListContainerType.CoinJoinTabViewModel ?
- false // Because in CoinJoin the selection algorithm makes sure not to combine red with non-red.
+ LabelExposeCommonOwnershipWarning = CoinListContainerType == CoinListContainerType.CoinJoinTabViewModel
+ ? false // Because in CoinJoin the selection algorithm makes sure not to combine red with non-red.
: Coins.Any(c =>
- c.AnonymitySet == 1 && c.IsSelected
- && Coins.Any(x => x.AnonymitySet > 1 && x.IsSelected));
+ c.AnonymitySet == 1 && c.IsSelected && Coins.Any(x =>
+ x.AnonymitySet > 1 && x.IsSelected));
}
public void OnCoinStatusChanged()

MODIFY
WalletWasabi.Gui/Converters/AmountForegroundConverter.cs
WalletWasabi.Gui/Converters/AmountForegroundConverter.cs
@@ -14,7 +14,11 @@ namespace WalletWasabi.Gui.Converters
if (value is string amount)
{
// When the amount starts with a '~' then Max is selected
- return amount.StartsWith("~") ? Brushes.ForestGreen : (amount.Equals("No Coins Selected", StringComparison.OrdinalIgnoreCase) ? Brushes.IndianRed : Brushes.White);
+ return amount.StartsWith("~")
+ ? Brushes.ForestGreen
+ : amount.Equals("No Coins Selected", StringComparison.OrdinalIgnoreCase)
+ ? Brushes.IndianRed
+ : Brushes.White;
}
else
{

MODIFY
WalletWasabi.Gui/Converters/PhaseColorConverter.cs
WalletWasabi.Gui/Converters/PhaseColorConverter.cs
@@ -20,8 +20,10 @@ namespace WalletWasabi.Gui.Converters
var global = Application.Current.Resources[Global.GlobalResourceKey] as Global;
var phaseError = global.ChaumianClient.State.IsInErrorState;
- return ((CcjRoundPhase)p <= (CcjRoundPhase)value)
- ? (phaseError ? Brushes.IndianRed : Brushes.Green)
+ return (CcjRoundPhase)p <= (CcjRoundPhase)value
+ ? phaseError
+ ? Brushes.IndianRed
+ : Brushes.Green
: Brushes.Gray;
}

MODIFY
WalletWasabi.Gui/Converters/UpdateStatusBrushConverter.cs
WalletWasabi.Gui/Converters/UpdateStatusBrushConverter.cs
@@ -21,8 +21,8 @@ namespace WalletWasabi.Gui.Converters
}
return Application.Current.Resources.TryGetResource("ApplicationAccentBrushLow", out object brush)
- ? brush :
- null;
+ ? brush
+ : null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

MODIFY
WalletWasabi.Gui/Dialogs/AvaloniaControlsExtensions.cs
WalletWasabi.Gui/Dialogs/AvaloniaControlsExtensions.cs
@@ -36,29 +36,33 @@ namespace Avalonia.Controls
{
WalletWasabi.Logging.Logger.LogWarning(ex, me.GetType().Name);
- string title =
- !string.IsNullOrWhiteSpace(me.Title) ? me.Title :
- me is OpenFileDialog ? "Open File" :
- me is SaveFileDialog ? "Save File" :
- throw new NotImplementedException();
+ string title = !string.IsNullOrWhiteSpace(me.Title)
+ ? me.Title
+ : me is OpenFileDialog
+ ? "Open File"
+ : me is SaveFileDialog
+ ? "Save File"
+ : throw new NotImplementedException();
- string instructions =
- me is OpenFileDialog ? $"Failed to use your operating system's {nameof(OpenFileDialog)}. Please provide the path of the file you want to open manually:" :
- me is SaveFileDialog ? $"Failed to use your operating system's {nameof(SaveFileDialog)}. Please provide the path where you want your file to be saved to:" :
- throw new NotImplementedException();
+ string instructions = me is OpenFileDialog
+ ? $"Failed to use your operating system's {nameof(OpenFileDialog)}. Please provide the path of the file you want to open manually:"
+ : me is SaveFileDialog
+ ? $"Failed to use your operating system's {nameof(SaveFileDialog)}. Please provide the path where you want your file to be saved to:"
+ : throw new NotImplementedException();
- string exampleFilePath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
- @"C:\path\to\the\file.ext" :
- @"/path/to/the/file";
+ string exampleFilePath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
+ ? @"C:\path\to\the\file.ext"
+ : @"/path/to/the/file";
- string defaultTextInput =
- me is OpenFileDialog ? Path.Combine(me.InitialDirectory ?? "", me.InitialFileName ?? "") :
- me is SaveFileDialog sfd ? Path.ChangeExtension(
+ string defaultTextInput = me is OpenFileDialog
+ ? Path.Combine(me.InitialDirectory ?? "", me.InitialFileName ?? "")
+ : me is SaveFileDialog sfd
+ ? Path.ChangeExtension(
Path.Combine(
string.IsNullOrEmpty(me.InitialDirectory) ? Path.GetDirectoryName(exampleFilePath) : me.InitialDirectory,
string.IsNullOrEmpty(me.InitialFileName) ? Path.GetFileName(exampleFilePath) : me.InitialFileName),
- string.IsNullOrEmpty(sfd.DefaultExtension) ? "ext" : sfd.DefaultExtension) :
- throw new NotImplementedException();
+ string.IsNullOrEmpty(sfd.DefaultExtension) ? "ext" : sfd.DefaultExtension)
+ : throw new NotImplementedException();
var dialog = new TextInputDialogViewModel(title, instructions, exampleFilePath, defaultTextInput);
var success = await MainWindowViewModel.Instance.ShowDialogAsync(dialog);

MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -526,7 +526,9 @@ namespace WalletWasabi.Gui
using (var process = Process.Start(new ProcessStartInfo
{
FileName = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "osascript" : "notify-send",
- Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? $"-e \"display notification \\\"Received {amountString} BTC\\\" with title \\\"Wasabi\\\"\"" : $"--expire-time=3000 \"Wasabi\" \"Received {amountString} BTC\"",
+ Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
+ ? $"-e \"display notification \\\"Received {amountString} BTC\\\" with title \\\"Wasabi\\\"\""
+ : $"--expire-time=3000 \"Wasabi\" \"Received {amountString} BTC\"",
CreateNoWindow = true
}))
{ }
@@ -689,8 +691,10 @@ namespace WalletWasabi.Gui
public string GetNextHardwareWalletName(Hwi.Models.HardwareWalletInfo hwi = null, string customPrefix = null)
{
- var prefix = customPrefix is null ?
- (hwi is null ? "HardwareWallet" : hwi.Type.ToString())
+ var prefix = customPrefix is null
+ ? hwi is null
+ ? "HardwareWallet"
+ : hwi.Type.ToString()
: customPrefix;
for (int i = 0; i < int.MaxValue; i++)

MODIFY
WalletWasabi.Gui/ManagedDialogs/ManagedFileChooserViewModel.cs
WalletWasabi.Gui/ManagedDialogs/ManagedFileChooserViewModel.cs
@@ -13,9 +13,10 @@ using WalletWasabi.Gui.ViewModels;
namespace WalletWasabi.Gui.ManagedDialogs
{
- class ManagedFileChooserViewModel : ViewModelBase
+ internal class ManagedFileChooserViewModel : ViewModelBase
{
public event Action CancelRequested;
+
public event Action<string[]> CompleteRequested;
public AvaloniaList<ManagedFileChooserItemViewModel> QuickLinks { get; } =
@@ -30,8 +31,8 @@ namespace WalletWasabi.Gui.ManagedDialogs
public AvaloniaList<ManagedFileChooserItemViewModel> SelectedItems { get; } =
new AvaloniaList<ManagedFileChooserItemViewModel>();
- string _location;
- string _fileName;
+ private string _location;
+ private string _fileName;
private bool _showHiddenFiles;
private ManagedFileChooserFilterViewModel _selectedFilter;
private bool _selectingDirectory;
@@ -105,10 +106,12 @@ namespace WalletWasabi.Gui.ManagedDialogs
QuickLinks.AddRange(quickSources.GetAllItems().Select(i => new ManagedFileChooserItemViewModel(i)));
- Title = dialog.Title ?? (
- dialog is OpenFileDialog ? "Open file"
- : dialog is SaveFileDialog ? "Save file"
- : dialog is OpenFolderDialog ? "Select directory"
+ Title = dialog.Title ?? (dialog is OpenFileDialog
+ ? "Open file"
+ : dialog is SaveFileDialog
+ ? "Save file"
+ : dialog is OpenFolderDialog
+ ? "Select directory"
: throw new ArgumentException(nameof(dialog)));
var directory = dialog.InitialDirectory;
@@ -198,7 +201,7 @@ namespace WalletWasabi.Gui.ManagedDialogs
});
}
- void NavigateRoot(string initialSelectionName)
+ private void NavigateRoot(string initialSelectionName)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{

MODIFY
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
@@ -58,9 +58,9 @@ namespace WalletWasabi.Gui.Tabs
var configBitcoinP2pEndPoint = Network == Network.Main
? config.MainNetBitcoinP2pEndPoint
- : (Network == Network.TestNet
+ : Network == Network.TestNet
? config.TestNetBitcoinP2pEndPoint
- : config.RegTestBitcoinP2pEndPoint);
+ : config.RegTestBitcoinP2pEndPoint;
BitcoinP2pEndPoint = configBitcoinP2pEndPoint.ToString(defaultPort: -1);
});
@@ -305,9 +305,9 @@ namespace WalletWasabi.Gui.Tabs
var configBitcoinP2pEndPoint = network == NBitcoin.Network.Main
? config.MainNetBitcoinP2pEndPoint
- : (network == NBitcoin.Network.TestNet
+ : network == NBitcoin.Network.TestNet
? config.TestNetBitcoinP2pEndPoint
- : config.RegTestBitcoinP2pEndPoint);
+ : config.RegTestBitcoinP2pEndPoint;
if (config.Network != network
|| config.TorSocks5EndPoint != torSocks5EndPoint

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
@@ -59,7 +59,8 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
private object WalletLock { get; }
- public LoadWalletViewModel(WalletManagerViewModel owner, LoadWalletType loadWalletType) : base(loadWalletType == LoadWalletType.Password ? "Test Password" : (loadWalletType == LoadWalletType.Desktop ? "Load Wallet" : "Hardware Wallet"))
+ public LoadWalletViewModel(WalletManagerViewModel owner, LoadWalletType loadWalletType)
+ : base(loadWalletType == LoadWalletType.Password ? "Test Password" : (loadWalletType == LoadWalletType.Desktop ? "Load Wallet" : "Hardware Wallet"))
{
Owner = owner;
Password = "";

MODIFY
WalletWasabi.Tests/NodeBuilding/NodeBuilder.cs
WalletWasabi.Tests/NodeBuilding/NodeBuilder.cs
@@ -97,8 +97,8 @@ namespace WalletWasabi.Tests.NodeBuilding
return bitcoind;
}
- zip = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ?
- Path.Combine(Global.Instance.DataDir, $"bitcoin-{version}-x86_64-linux-gnu.tar.gz")
+ zip = RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
+ ? Path.Combine(Global.Instance.DataDir, $"bitcoin-{version}-x86_64-linux-gnu.tar.gz")
: Path.Combine(Global.Instance.DataDir, $"bitcoin-{version}-osx64.tar.gz");
string url = string.Format("https://bitcoincore.org/bin/bitcoin-core-{0}/" + Path.GetFileName(zip), version);

MODIFY
WalletWasabi/Gma/QrCodeNet/Encoding/EncodingRegion/FormatInformation.cs
WalletWasabi/Gma/QrCodeNet/Encoding/EncodingRegion/FormatInformation.cs
@@ -40,12 +40,14 @@ namespace Gma.QrCodeNet.Encoding.EncodingRegion
{
if (bitsIndex <= 7)
{
- return bitsIndex >= 6 ? new MatrixPoint(bitsIndex + 1, 8)
+ return bitsIndex >= 6
+ ? new MatrixPoint(bitsIndex + 1, 8)
: new MatrixPoint(bitsIndex, 8);
}
else
{
- return bitsIndex == 8 ? new MatrixPoint(8, 8 - (bitsIndex - 7))
+ return bitsIndex == 8
+ ? new MatrixPoint(8, 8 - (bitsIndex - 7))
: new MatrixPoint(8, 8 - (bitsIndex - 7) - 1);
}
}

MODIFY
WalletWasabi/Gma/QrCodeNet/Encoding/Masking/Scoring/Penalty1.cs
WalletWasabi/Gma/QrCodeNet/Encoding/Masking/Scoring/Penalty1.cs
@@ -26,13 +26,15 @@ namespace Gma.QrCodeNet.Encoding.Masking.Scoring
{
while (j < width - 4)
{
- bool preBit = isHorizontal ? matrix[j + 4, i]
+ bool preBit = isHorizontal
+ ? matrix[j + 4, i]
: matrix[i, j + 4];
int numSameBitCell = 1;
for (int x = 1; x <= 4; x++)
{
- bool bit = isHorizontal ? matrix[j + 4 - x, i]
+ bool bit = isHorizontal
+ ? matrix[j + 4 - x, i]
: matrix[i, j + 4 - x];
if (bit == preBit)
{
@@ -53,7 +55,8 @@ namespace Gma.QrCodeNet.Encoding.Masking.Scoring
int x = 5;
while ((j + x) < width)
{
- bool bit = isHorizontal ? matrix[j + x, i]
+ bool bit = isHorizontal
+ ? matrix[j + x, i]
: matrix[i, j + x];
if (bit == preBit)
{

MODIFY
WalletWasabi/Gma/QrCodeNet/Encoding/Masking/Scoring/Penalty3.cs
WalletWasabi/Gma/QrCodeNet/Encoding/Masking/Scoring/Penalty3.cs
@@ -21,11 +21,13 @@ namespace Gma.QrCodeNet.Encoding.Masking.Scoring
{
while (j < width - 5)
{
- bit = isHorizontal ? matrix[j + 4, i]
+ bit = isHorizontal
+ ? matrix[j + 4, i]
: matrix[i, j + 4];
if (!bit)
{
- bit = isHorizontal ? matrix[j, i]
+ bit = isHorizontal
+ ? matrix[j, i]
: matrix[i, j];
if (!bit)
{
@@ -41,7 +43,8 @@ namespace Gma.QrCodeNet.Encoding.Masking.Scoring
{
for (int num = 4; num > 0; num--)
{
- bit = isHorizontal ? matrix[j + num, i]
+ bit = isHorizontal
+ ? matrix[j + num, i]
: matrix[i, j + num];
if (!bit)
{
@@ -66,7 +69,8 @@ namespace Gma.QrCodeNet.Encoding.Masking.Scoring
bool bit;
for (int num = 3; num >= 1; num--)
{
- bit = isHorizontal ? matrix[j + num, i]
+ bit = isHorizontal
+ ? matrix[j + num, i]
: matrix[i, j + num];
if (!bit)
{
@@ -79,14 +83,16 @@ namespace Gma.QrCodeNet.Encoding.Masking.Scoring
return 0;
}
- bit = isHorizontal ? matrix[j + 5, i]
+ bit = isHorizontal
+ ? matrix[j + 5, i]
: matrix[i, j + 5];
if (!bit)
{
return 0;
}
- bit = isHorizontal ? matrix[j - 1, i]
+ bit = isHorizontal
+ ? matrix[j - 1, i]
: matrix[i, j - 1];
if (!bit)
{
@@ -97,7 +103,8 @@ namespace Gma.QrCodeNet.Encoding.Masking.Scoring
{
for (int num = -2; num >= -5; num--)
{
- bit = isHorizontal ? matrix[j + num, i]
+ bit = isHorizontal
+ ? matrix[j + num, i]
: matrix[i, j + num];
if (bit)
{
@@ -115,7 +122,8 @@ namespace Gma.QrCodeNet.Encoding.Masking.Scoring
{
for (int num = 6; num <= 9; num++)
{
- bit = isHorizontal ? matrix[j + num, i]
+ bit = isHorizontal
+ ? matrix[j + num, i]
: matrix[i, j + num];
if (bit)
{

MODIFY
WalletWasabi/Helpers/IoHelpers.cs
WalletWasabi/Helpers/IoHelpers.cs
@@ -123,7 +123,11 @@ namespace System.IO
{
using (Process process = Process.Start(new ProcessStartInfo
{
- FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "explorer.exe" : (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "open" : "xdg-open"),
+ FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
+ ? "explorer.exe"
+ : (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
+ ? "open"
+ : "xdg-open"),
Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? $"\"{dirPath}\"" : dirPath,
CreateNoWindow = true
}))

MODIFY
WalletWasabi/Models/Height.cs
WalletWasabi/Models/Height.cs
@@ -111,7 +111,7 @@ namespace WalletWasabi.Models
Type = type;
- Value = (Type == HeightType.Mempool)
+ Value = Type == HeightType.Mempool
? int.MaxValue - 1
: int.MaxValue;
}

MODIFY
WalletWasabi/Nito/AsyncEx/AsyncMutex.cs
WalletWasabi/Nito/AsyncEx/AsyncMutex.cs
@@ -117,9 +117,9 @@ namespace Nito.AsyncEx
/// <param name="cancellationTokenObj"></param>
private void HoldLock(object cancellationTokenObj)
{
- CancellationToken ct = cancellationTokenObj is CancellationToken token ?
- token :
- CancellationToken.None;
+ CancellationToken ct = cancellationTokenObj is CancellationToken token
+ ? token
+ : CancellationToken.None;
while (true)
{

Refactor existing conditional expression