fix warnings from validation code.
MODIFY
WalletWasabi.Fluent/Validation/Validations.cs
WalletWasabi.Fluent/Validation/Validations.cs
-using ReactiveUI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
+using ReactiveUI;
using WalletWasabi.Models;
namespace WalletWasabi.Fluent.Validation
@@ -22,19 +22,19 @@ namespace WalletWasabi.Fluent.Validation
private Dictionary<string, ValidateMethod> ValidationMethods { get; }
- public bool Any => ErrorsByPropertyName.Where(x => x.Value.Any()).Any();
+ public bool Any => ErrorsByPropertyName.Any(x => x.Value.Any());
- public bool AnyErrors => ErrorsByPropertyName.Where(x => x.Value.Any(x => x.Severity == ErrorSeverity.Error)).Any();
+ public bool AnyErrors => ErrorsByPropertyName.Any(x => x.Value.Any(error => error.Severity == ErrorSeverity.Error));
- public bool AnyWarnings => ErrorsByPropertyName.Where(x => x.Value.Any(x => x.Severity == ErrorSeverity.Warning)).Any();
+ public bool AnyWarnings => ErrorsByPropertyName.Any(x => x.Value.Any(error => error.Severity == ErrorSeverity.Warning));
- public bool AnyInfos => ErrorsByPropertyName.Where(x => x.Value.Any(x => x.Severity == ErrorSeverity.Info)).Any();
+ public bool AnyInfos => ErrorsByPropertyName.Any(x => x.Value.Any(error => error.Severity == ErrorSeverity.Info));
- IEnumerable<string> IValidations.Infos => ErrorsByPropertyName.Values.SelectMany(x => x.Where(x => x.Severity == ErrorSeverity.Info).Select(x => x.Message));
+ IEnumerable<string> IValidations.Infos => ErrorsByPropertyName.Values.SelectMany(x => x.Where(error => error.Severity == ErrorSeverity.Info).Select(error => error.Message));
- IEnumerable<string> IValidations.Warnings => ErrorsByPropertyName.Values.SelectMany(x => x.Where(x => x.Severity == ErrorSeverity.Warning).Select(x => x.Message));
+ IEnumerable<string> IValidations.Warnings => ErrorsByPropertyName.Values.SelectMany(x => x.Where(error => error.Severity == ErrorSeverity.Warning).Select(error => error.Message));
- IEnumerable<string> IValidations.Errors => ErrorsByPropertyName.Values.SelectMany(x => x.Where(x => x.Severity == ErrorSeverity.Error).Select(x => x.Message));
+ IEnumerable<string> IValidations.Errors => ErrorsByPropertyName.Values.SelectMany(x => x.Where(error => error.Severity == ErrorSeverity.Error).Select(error => error.Message));
public void Clear()
{
@@ -85,12 +85,19 @@ namespace WalletWasabi.Fluent.Validation
ErrorsByPropertyName[propertyName] = ErrorDescriptors.Create();
}
- public IEnumerable GetErrors(string propertyName)
+ public IEnumerable GetErrors(string? propertyName)
+ {
+ if (!string.IsNullOrWhiteSpace(propertyName))
{
return ErrorsByPropertyName.ContainsKey(propertyName) && ErrorsByPropertyName[propertyName].Any()
? ErrorsByPropertyName[propertyName]
: ErrorDescriptors.Empty;
}
+ else
+ {
+ return ErrorDescriptors.Empty;
+ }
+ }
private void UpdateAndNotify(List<ErrorDescriptor> currentErrors, List<ErrorDescriptor> previousErrors, string propertyName)
{
@@ -122,7 +129,7 @@ namespace WalletWasabi.Fluent.Validation
this.RaisePropertyChanged(nameof(Any));
}
- propertiesToNotify.ForEach(x => this.RaisePropertyChanged(x));
+ propertiesToNotify.ForEach(this.RaisePropertyChanged);
}
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/ViewModelBase.cs
WalletWasabi.Fluent/ViewModels/ViewModelBase.cs
@@ -45,7 +45,7 @@ namespace WalletWasabi.Fluent.ViewModels
}
}
- IEnumerable INotifyDataErrorInfo.GetErrors(string propertyName)
+ IEnumerable INotifyDataErrorInfo.GetErrors(string? propertyName)
{
return _validations.GetErrors(propertyName);
}

fix warnings from validation code.