remove ValidateMethod attribute.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
@@ -54,6 +54,8 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Global = Locator.Current.GetService<Global>();
Wallet = wallet;
+ RegisterValidationMethod(nameof(Password), ValidatePassword);
+
Password = "";
TimeLeftTillRoundTimeout = TimeSpan.Zero;
@@ -135,7 +137,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Wallet IWalletViewModel.Wallet => Wallet;
- [ValidateMethod(nameof(ValidatePassword))]
public string Password
{
get => _password;

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
@@ -82,6 +82,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Wallet = wallet;
RegisterValidationMethod(nameof(Address), ValidateActiveAddress);
+ RegisterValidationMethod(nameof(UserFeeText), ValidateUserFeeText);
+ RegisterValidationMethod(nameof(Password), ValidatePassword);
+ RegisterValidationMethod(nameof(CustomChangeAddress), ValidateCustomChangeAddress);
+
LabelSuggestion = new SuggestLabelViewModel();
BuildTransactionButtonText = DoButtonText;
@@ -471,7 +475,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
set => this.RaiseAndSetIfChanged(ref _amountText, value);
}
- [ValidateMethod(nameof(ValidateUserFeeText))]
public string UserFeeText
{
get => _userFeeText;
@@ -542,21 +545,18 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public bool IsWatchOnly => Wallet.KeyManager.IsWatchOnly;
- [ValidateMethod(nameof(ValidatePassword))]
public string Password
{
get => _password;
set => this.RaiseAndSetIfChanged(ref _password, value);
}
- [ValidateMethod(nameof(ValidateActiveAddress))]
public string Address
{
get => _address;
set => this.RaiseAndSetIfChanged(ref _address, value?.Trim());
}
- [ValidateMethod(nameof(ValidateCustomChangeAddress))]
public string CustomChangeAddress
{
get => _customChangeAddress;
@@ -873,7 +873,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
&& userFee > 0;
}
- public void ValidateUserFeeText(IErrorList errors)
+ private void ValidateUserFeeText(IErrorList errors)
{
if (!TryParseUserFee(out _))
{
@@ -881,9 +881,9 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
}
- public void ValidatePassword(IErrorList errors) => PasswordHelper.ValidatePassword(errors, Password);
+ private void ValidatePassword(IErrorList errors) => PasswordHelper.ValidatePassword(errors, Password);
- public void ValidateActiveAddress(IErrorList errors)
+ private void ValidateActiveAddress(IErrorList errors)
{
if (string.IsNullOrWhiteSpace(Address))
{
@@ -911,7 +911,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
errors.Add(ErrorSeverity.Error, "Invalid address.");
}
- public void ValidateCustomChangeAddress(IErrorList errors)
+ private void ValidateCustomChangeAddress(IErrorList errors)
{
if (string.IsNullOrWhiteSpace(CustomChangeAddress))
{

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
@@ -32,6 +32,8 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Global = Locator.Current.GetService<Global>();
Wallet = wallet;
+ RegisterValidationMethod(nameof(Password), ValidatePassword);
+
ClearSensitiveData(true);
ToggleSensitiveKeysCommand = ReactiveCommand.Create(() =>
@@ -88,7 +90,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
set => this.RaiseAndSetIfChanged(ref _showSensitiveKeys, value);
}
- [ValidateMethod(nameof(ValidatePassword))]
public string Password
{
get => _password;

MODIFY
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
@@ -45,6 +45,13 @@ namespace WalletWasabi.Gui.Tabs
{
Global = Locator.Current.GetService<Global>();
+ RegisterValidationMethod(nameof(TorSocks5EndPoint), ValidateTorSocks5EndPoint);
+ RegisterValidationMethod(nameof(BitcoinP2pEndPoint), ValidateBitcoinP2pEndPoint);
+ RegisterValidationMethod(nameof(SomePrivacyLevel), ValidateSomePrivacyLevel);
+ RegisterValidationMethod(nameof(FinePrivacyLevel), ValidateFinePrivacyLevel);
+ RegisterValidationMethod(nameof(StrongPrivacyLevel), ValidateStrongPrivacyLevel);
+ RegisterValidationMethod(nameof(DustThreshold), ValidateDustThreshold);
+
Autocopy = Global.UiConfig.Autocopy;
CustomFee = Global.UiConfig.IsCustomFee;
CustomChangeAddress = Global.UiConfig.IsCustomChangeAddress;
@@ -180,15 +187,12 @@ namespace WalletWasabi.Gui.Tabs
get => _network;
set => this.RaiseAndSetIfChanged(ref _network, value);
}
-
- [ValidateMethod(nameof(ValidateTorSocks5EndPoint))]
public string TorSocks5EndPoint
{
get => _torSocks5EndPoint;
set => this.RaiseAndSetIfChanged(ref _torSocks5EndPoint, value);
}
- [ValidateMethod(nameof(ValidateBitcoinP2pEndPoint))]
public string BitcoinP2pEndPoint
{
get => _bitcoinP2pEndPoint;
@@ -243,28 +247,24 @@ namespace WalletWasabi.Gui.Tabs
set => this.RaiseAndSetIfChanged(ref _useTor, value);
}
- [ValidateMethod(nameof(ValidateSomePrivacyLevel))]
public string SomePrivacyLevel
{
get => _somePrivacyLevel;
set => this.RaiseAndSetIfChanged(ref _somePrivacyLevel, value);
}
- [ValidateMethod(nameof(ValidateFinePrivacyLevel))]
public string FinePrivacyLevel
{
get => _finePrivacyLevel;
set => this.RaiseAndSetIfChanged(ref _finePrivacyLevel, value);
}
- [ValidateMethod(nameof(ValidateStrongPrivacyLevel))]
public string StrongPrivacyLevel
{
get => _strongPrivacyLevel;
set => this.RaiseAndSetIfChanged(ref _strongPrivacyLevel, value);
}
- [ValidateMethod(nameof(ValidateDustThreshold))]
public string DustThreshold
{
get => _dustThreshold;

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/GenerateWallets/GenerateWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/GenerateWallets/GenerateWalletViewModel.cs
@@ -26,6 +26,8 @@ namespace WalletWasabi.Gui.Tabs.WalletManager.GenerateWallets
Global = Locator.Current.GetService<Global>();
Owner = owner;
+ RegisterValidationMethod(nameof(Password), ValidatePassword);
+
NextCommand = ReactiveCommand.Create(DoNextCommand, this.WhenAnyValue(x=>x.HasErrors).Select(x=> !x));
NextCommand.ThrownExceptions
@@ -37,7 +39,6 @@ namespace WalletWasabi.Gui.Tabs.WalletManager.GenerateWallets
private Global Global { get; }
- [ValidateMethod(nameof(ValidatePassword))]
public string Password
{
get => _password;

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/LoadWallets/LoadWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/LoadWallets/LoadWalletViewModel.cs
@@ -40,6 +40,8 @@ namespace WalletWasabi.Gui.Tabs.WalletManager.LoadWallets
{
Global = Locator.Current.GetService<Global>();
+ RegisterValidationMethod(nameof(Password), ValidatePassword);
+
Owner = owner;
Password = "";
LoadWalletType = loadWalletType;
@@ -108,7 +110,6 @@ namespace WalletWasabi.Gui.Tabs.WalletManager.LoadWallets
public ReadOnlyObservableCollection<WalletViewModelBase> Wallets => _wallets;
- [ValidateMethod(nameof(ValidatePassword))]
public string Password
{
get => _password;

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/RecoverWallets/RecoverWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/RecoverWallets/RecoverWalletViewModel.cs
@@ -45,6 +45,8 @@ namespace WalletWasabi.Gui.Tabs.WalletManager.RecoverWallets
MnemonicWords = Guard.Correct(MnemonicWords);
Password = Guard.Correct(Password); // Do not let whitespaces to the beginning and to the end.
+ RegisterValidationMethod(nameof(Password), ValidatePassword);
+
string walletFilePath = WalletManager.WalletDirectories.GetWalletFilePaths(WalletName).walletFilePath;
if (string.IsNullOrWhiteSpace(WalletName))
@@ -111,7 +113,6 @@ namespace WalletWasabi.Gui.Tabs.WalletManager.RecoverWallets
public void ValidatePassword(IErrorList errors) => PasswordHelper.ValidatePassword(errors, Password);
- [ValidateMethod(nameof(ValidatePassword))]
public string Password
{
get => _password;

DELETE
WalletWasabi.Gui/ViewModels/Validation/ValidateMethodAttribute.cs
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace WalletWasabi.Gui.ViewModels.Validation
-{
- [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
- public sealed class ValidateMethodAttribute : Attribute
- {
- public ValidateMethodAttribute(string methodName)
- {
- MethodName = methodName;
- }
-
- public string MethodName { get; }
- }
-}

DELETE
WalletWasabi.Tests/UnitTests/ValidateMethodTests.cs
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using WalletWasabi.Gui.Converters;
-using WalletWasabi.Gui.ViewModels.Validation;
-using WalletWasabi.Models;
-using Xunit;
-
-namespace WalletWasabi.Tests.UnitTests
-{
- public class ValidateMethodTests
- {
- [Fact]
- public void PropertiesWithValidationTest()
- {
- var testClass = new ValidateTestClass();
-
- var validator = Validator.PropertiesWithValidation(testClass);
- Assert.Equal(2, validator.Count());
- }
-
- public class ValidateTestClass
- {
- [ValidateMethod(nameof(ValidateProperty))]
- public bool BooleanProperty { get; set; }
-
- [ValidateMethod(nameof(ValidateProperty))]
- public string StringProperty { get; set; }
-
- public ErrorDescriptors ValidateProperty()
- {
- return new ErrorDescriptors(new ErrorDescriptor(ErrorSeverity.Warning, "My warning error descriptor"), new ErrorDescriptor(ErrorSeverity.Error, "My error error descriptor"));
- }
- }
- }
-}

remove ValidateMethod attribute.