Address reviews.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
@@ -17,6 +17,7 @@ using WalletWasabi.KeyManagement;
using WalletWasabi.Logging;
using WalletWasabi.Models.ChaumianCoinJoin;
using WalletWasabi.Services;
+using WalletWasabi.Models;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -28,6 +28,7 @@ using WalletWasabi.KeyManagement;
using WalletWasabi.Models;
using WalletWasabi.Models.TransactionBuilding;
using WalletWasabi.Services;
+using WalletWasabi.Models;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
@@ -11,6 +11,7 @@ using WalletWasabi.Gui.ViewModels.Validation;
using WalletWasabi.Helpers;
using WalletWasabi.KeyManagement;
using WalletWasabi.Services;
+using WalletWasabi.Models;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{

MODIFY
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
@@ -16,6 +16,7 @@ using System.Text.RegularExpressions;
using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Gui.ViewModels.Validation;
using WalletWasabi.Helpers;
+using WalletWasabi.Models;
namespace WalletWasabi.Gui.Tabs
{

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/GenerateWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/GenerateWalletViewModel.cs
@@ -13,6 +13,7 @@ using WalletWasabi.Gui.ViewModels.Validation;
using WalletWasabi.Helpers;
using WalletWasabi.KeyManagement;
using WalletWasabi.Logging;
+using WalletWasabi.Models;
namespace WalletWasabi.Gui.Tabs.WalletManager
{

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
@@ -28,6 +28,7 @@ using WalletWasabi.Hwi;
using WalletWasabi.Hwi.Models;
using WalletWasabi.KeyManagement;
using WalletWasabi.Logging;
+using WalletWasabi.Models;
namespace WalletWasabi.Gui.Tabs.WalletManager
{

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/RecoverWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/RecoverWalletViewModel.cs
@@ -13,6 +13,7 @@ using WalletWasabi.Gui.ViewModels.Validation;
using WalletWasabi.Helpers;
using WalletWasabi.KeyManagement;
using WalletWasabi.Logging;
+using WalletWasabi.Models;
namespace WalletWasabi.Gui.Tabs.WalletManager
{
@@ -101,11 +102,6 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
set => this.RaiseAndSetIfChanged(ref _password, value);
}
- private void ValidatePasswordN(ErrorDescriptor obj)
- {
- throw new NotImplementedException();
- }
-
public string MnemonicWords
{
get => _mnemonicWords;

MODIFY
WalletWasabi.Gui/ViewModels/Validation/Validator.cs
WalletWasabi.Gui/ViewModels/Validation/Validator.cs
@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
-using WalletWasabi.Helpers;
+using WalletWasabi.Models;
namespace WalletWasabi.Gui.ViewModels.Validation
{
@@ -24,6 +24,8 @@ namespace WalletWasabi.Gui.ViewModels.Validation
public static ErrorDescriptors ValidateAllProperties(ViewModelBase viewModelBase,
List<(string propertyName, MethodInfo mInfo)> validationMethodCache)
{
+ if (validationMethodCache is null) return ErrorDescriptors.Empty;
+
ErrorDescriptors result = null;
foreach (var validationCache in validationMethodCache)
@@ -42,6 +44,9 @@ namespace WalletWasabi.Gui.ViewModels.Validation
string propertyName,
List<(string propertyName, MethodInfo mInfo)> validationMethodCache)
{
+
+ if (validationMethodCache is null) return ErrorDescriptors.Empty;
+
ErrorDescriptors result = null;
foreach (var validationCache in validationMethodCache)

MODIFY
WalletWasabi.Gui/ViewModels/ViewModelBase.cs
WalletWasabi.Gui/ViewModels/ViewModelBase.cs
@@ -6,13 +6,13 @@ using System.ComponentModel;
using System.Linq;
using System.Reflection;
using WalletWasabi.Gui.ViewModels.Validation;
-using WalletWasabi.Helpers;
+using WalletWasabi.Models;
namespace WalletWasabi.Gui.ViewModels
{
public class ViewModelBase : ReactiveObject, INotifyDataErrorInfo
{
- private List<(string, MethodInfo)> ValidationMethodCache;
+ private List<(string propertyName, MethodInfo mInfo)> ValidationMethodCache;
public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;
public ViewModelBase()
@@ -22,6 +22,19 @@ namespace WalletWasabi.Gui.ViewModels
if (vmc.Count == 0) return;
ValidationMethodCache = vmc;
+ this.PropertyChanged += ValidationHandler;
+ }
+
+ private void ValidationHandler(object sender, PropertyChangedEventArgs e)
+ {
+ if (ValidationMethodCache is null) return;
+
+ foreach (var validationCache in ValidationMethodCache)
+ {
+ if (validationCache.propertyName != e.PropertyName) continue;
+
+ NotifyErrorsChanged(e.PropertyName);
+ }
}
public bool HasErrors => Validator.ValidateAllProperties(this, ValidationMethodCache).HasErrors;
@@ -32,7 +45,7 @@ namespace WalletWasabi.Gui.ViewModels
if (error.HasErrors)
{
- return error;
+ return error.Select(p => p.Message);
}
return ErrorDescriptors.Empty;

DELETE
WalletWasabi/Helpers/ErrorDescriptor.cs
-using System;
-using System.Collections.Generic;
-
-namespace WalletWasabi.Helpers
-{
- public class ErrorDescriptors : List<ErrorDescriptor>
- {
- public bool HasErrors => this.Count > 0;
-
- public static ErrorDescriptors Empty = new ErrorDescriptors();
-
- public ErrorDescriptors() : base()
- {
-
- }
-
- public ErrorDescriptors(params ErrorDescriptor[] errors)
- {
- this.AddRange(errors);
- }
- }
-
- public enum ErrorSeverity
- {
- Default,
- Info,
- Warning,
- Error
- }
-
- public struct ErrorDescriptor : IEquatable<ErrorDescriptor>
- {
- public static ErrorDescriptor Default = new ErrorDescriptor(ErrorSeverity.Default, string.Empty);
-
-
- public ErrorSeverity Severity { get; }
- public string Message { get; }
-
- public ErrorDescriptor(ErrorSeverity severity, string message)
- {
- this.Severity = severity;
- this.Message = message;
- }
-
- public bool Equals(ErrorDescriptor other)
- {
- return (this.Severity == other.Severity && this.Message == other.Message);
- }
- }
-}

MODIFY
WalletWasabi/Helpers/PasswordHelper.cs
WalletWasabi/Helpers/PasswordHelper.cs
@@ -7,6 +7,7 @@ using WalletWasabi.KeyManagement;
using NBitcoin;
using System.Security;
using WalletWasabi.Logging;
+using WalletWasabi.Models;
namespace WalletWasabi.Helpers
{

ADD
WalletWasabi/Models/ErrorDescriptor.cs
+using System;
+
+namespace WalletWasabi.Models
+{
+ public struct ErrorDescriptor : IEquatable<ErrorDescriptor>
+ {
+ public static ErrorDescriptor Default = new ErrorDescriptor(ErrorSeverity.Default, string.Empty);
+ public ErrorSeverity Severity { get; }
+ public string Message { get; }
+
+ public ErrorDescriptor(ErrorSeverity severity, string message)
+ {
+ Severity = severity;
+ Message = message;
+ }
+
+ public bool Equals(ErrorDescriptor other)
+ {
+ return (Severity == other.Severity && Message == other.Message);
+ }
+ }
+}

ADD
WalletWasabi/Models/ErrorDescriptors.cs
+using System.Collections.Generic;
+
+namespace WalletWasabi.Models
+{
+ public class ErrorDescriptors : List<ErrorDescriptor>
+ {
+ public bool HasErrors => Count > 0;
+
+ public static ErrorDescriptors Empty = new ErrorDescriptors();
+
+ public ErrorDescriptors() : base()
+ {
+ }
+
+ public ErrorDescriptors(params ErrorDescriptor[] errors)
+ {
+ AddRange(errors);
+ }
+ }
+}

ADD
WalletWasabi/Models/ErrorSeverity.cs
+namespace WalletWasabi.Models
+{
+ public enum ErrorSeverity
+ {
+ Default,
+ Info,
+ Warning,
+ Error
+ }
+}

Address reviews.