Fix error descriptors.
MODIFY
WalletWasabi.Gui/Converters/ErrorDescriptorToBorderColorConverter.cs
WalletWasabi.Gui/Converters/ErrorDescriptorToBorderColorConverter.cs
@@ -12,14 +12,12 @@ namespace WalletWasabi.Gui.Converters
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- if (value is ErrorDescriptors descriptors)
+ if (value is IEnumerable<object> rawObj)
{
+ var descriptors = new ErrorDescriptors();
+ descriptors.AddRange(rawObj.Cast<ErrorDescriptor>());
return GetColorFromDescriptors(descriptors);
}
- else if (value is IEnumerable<Exception> exList)
- {
- return GetColorFromDescriptors(ErrorDescriptorsJsonConverter.ExceptionListToErrorDescriptor(exList));
- }
return null;
}

DELETE
WalletWasabi.Gui/Converters/ErrorDescriptorsJsonConverter.cs
-using Avalonia;
-using Avalonia.Data.Converters;
-using NBitcoin;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using WalletWasabi.Models;
-
-namespace WalletWasabi.Gui.Converters
-{
- public class ErrorDescriptorsJsonConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is null)
- {
- return ErrorDescriptors.Empty;
- }
-
- if (value is IEnumerable<Exception> exList)
- {
- return ExceptionListToErrorDescriptor(exList);
- }
-
- return ErrorDescriptors.Empty;
- }
-
- internal static ErrorDescriptors ExceptionListToErrorDescriptor(IEnumerable<Exception> exList)
- {
- var errors = new ErrorDescriptors();
-
- foreach (var exMsg in exList.Select(p => p.Message).Where(p => p != null))
- {
- try
- {
- errors.AddRange(JsonConvert.DeserializeObject<ErrorDescriptors>(exMsg));
- }
- catch (Exception e)
- {
- errors.Add(new ErrorDescriptor(ErrorSeverity.Error, e.Message));
- errors.Add(new ErrorDescriptor(ErrorSeverity.Error, exMsg));
- }
- }
-
- return errors;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return null;
- }
- }
-}

MODIFY
WalletWasabi.Gui/Styles/Styles.xaml
WalletWasabi.Gui/Styles/Styles.xaml
<sys:Double x:Key="FontSizeNormal">14</sys:Double>
<sys:Double x:Key="FontSizeLarge">16</sys:Double>
<FontFamily x:Key="MonospacedFont">avares://WalletWasabi.Gui/Assets#Cascadia Code</FontFamily>
- <converters:ErrorDescriptorsJsonConverter x:Key="ErrorDescriptorsJsonConverter" />
<converters:ErrorSeverityColorConverter x:Key="ErrorSeverityColorConverter" />
<converters:ErrorDescriptorToBorderColorConverter x:Key="ErrorDescriptorToBorderColorConverter" />
</Style.Resources>
DockPanel.Dock="Bottom"
ContentTemplate="{TemplateBinding ErrorTemplate}"
DataContext="{TemplateBinding Owner}"
- Content="{Binding (DataValidationErrors.Errors), Converter={StaticResource ErrorDescriptorsJsonConverter}}"
+ Content="{Binding (DataValidationErrors.Errors)}"
IsVisible="{Binding (DataValidationErrors.HasErrors)}" />
<ContentPresenter
Name="PART_ContentPresenter"

MODIFY
WalletWasabi.Gui/ViewModels/ViewModelBase.cs
WalletWasabi.Gui/ViewModels/ViewModelBase.cs
@@ -34,12 +34,12 @@ namespace WalletWasabi.Gui.ViewModels
{
var error = Validator.ValidateProperty(this, propertyName, ValidationMethodCache);
- // HACK: Need to serialize this in order to pass through IndeiValidationPlugin on Avalonia 0.8.2.
- // Should be removed when Avalonia has the hotfix update.
if (error.HasErrors)
{
- yield return JsonConvert.SerializeObject(error);
+ return error;
}
+
+ return ErrorDescriptors.Empty;
}
protected void NotifyErrorsChanged(string propertyName)

MODIFY
WalletWasabi.Tests/UnitTests/ValidateMethodTests.cs
WalletWasabi.Tests/UnitTests/ValidateMethodTests.cs
@@ -35,37 +35,5 @@ namespace WalletWasabi.Tests.UnitTests
var validator = Validator.PropertiesWithValidation(testClass);
Assert.Equal(2, validator.Count());
}
-
- [Fact]
- public void ErrorDescriptorsTest()
- {
- ErrorDescriptors eds = new ErrorDescriptors()
- {
- new ErrorDescriptor(ErrorSeverity.Default,"My default error descriptor"),
- new ErrorDescriptor(ErrorSeverity.Info,"My info error descriptor"),
- new ErrorDescriptor(ErrorSeverity.Warning,"My warning error descriptor"),
- new ErrorDescriptor(ErrorSeverity.Error,"My error descriptor")
- };
-
- // Constructor tests
-
- Assert.Equal("My info error descriptor", eds[1].Message);
- Assert.Equal(ErrorSeverity.Info, eds[1].Severity);
-
- // Serialize and de-serialize test
-
- var serialized = JsonConvert.SerializeObject(eds);
-
- var converter = new ErrorDescriptorsJsonConverter();
-
- var deserialized = (ErrorDescriptors)converter.Convert(new[] { new Exception(serialized) }, eds.GetType(), null, CultureInfo.InvariantCulture);
-
- Assert.Equal(4, deserialized.Count());
-
- for (int i = 0; i < eds.Count; i++)
- {
- Assert.Equal(eds[i], deserialized[i]);
- }
- }
}
}

Fix error descriptors.