fix nullable warnings in converters.
MODIFY
WalletWasabi.Fluent/Converters/EnumConverters.cs
WalletWasabi.Fluent/Converters/EnumConverters.cs
@@ -8,10 +8,10 @@ namespace WalletWasabi.Fluent.Converters;
public static class EnumConverters
{
public static readonly IValueConverter ToFriendlyName =
- new FuncValueConverter<Enum, string>(x => x.FriendlyName());
+ new FuncValueConverter<Enum, string>(x => x?.FriendlyName() ?? "");
public static readonly IValueConverter ToUpperCase =
- new FuncValueConverter<Enum, string>(x => x.ToString().ToUpper(CultureInfo.InvariantCulture));
+ new FuncValueConverter<Enum, string>(x => x?.ToString().ToUpper(CultureInfo.InvariantCulture) ?? "");
public static readonly IValueConverter ToCharset =
new FuncValueConverter<Enum, string>(x =>

MODIFY
WalletWasabi.Fluent/Converters/NegativeDoubleConverter.cs
WalletWasabi.Fluent/Converters/NegativeDoubleConverter.cs
@@ -11,7 +11,7 @@ public class NegativeDoubleConverter : IValueConverter
{
}
- object? IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ object? IValueConverter.Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is double d)
{
@@ -21,8 +21,8 @@ public class NegativeDoubleConverter : IValueConverter
return null;
}
- object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ object? IValueConverter.ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
- throw new NotImplementedException();
+ return null;
}
}

MODIFY
WalletWasabi.Fluent/Converters/StatusBarStateVisibilityConverter.cs
WalletWasabi.Fluent/Converters/StatusBarStateVisibilityConverter.cs
@@ -12,13 +12,18 @@ public class StatusBarStateVisibilityConverter : IValueConverter
{
}
- object? IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ object? IValueConverter.Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
- return (StatusBarState)value == (StatusBarState)parameter;
+ if (value is StatusBarState state && parameter is StatusBarState paramState)
+ {
+ return state == paramState;
+ }
+
+ return null;
}
- object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ object? IValueConverter.ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
- throw new NotImplementedException();
+ return null;
}
}

MODIFY
WalletWasabi.Fluent/Converters/WalletIconConverter.cs
WalletWasabi.Fluent/Converters/WalletIconConverter.cs
@@ -8,9 +8,9 @@ namespace WalletWasabi.Fluent.Converters;
public static class WalletIconConverter
{
public static readonly IValueConverter WalletTypeToImage =
- new FuncValueConverter<WalletType, Bitmap>(GetBitmap);
+ new FuncValueConverter<WalletType, Bitmap?>(GetBitmap);
- private static Bitmap GetBitmap(WalletType type)
+ private static Bitmap? GetBitmap(WalletType type)
{
Uri uri = new($"avares://WalletWasabi.Fluent/Assets/WalletIcons/{ThemeHelper.CurrentTheme}/generic.png");

MODIFY
WalletWasabi.Fluent/Converters/WidthTriggersConverter.cs
WalletWasabi.Fluent/Converters/WidthTriggersConverter.cs
@@ -14,7 +14,7 @@ public class WidthTriggersConverter : IValueConverter
{
}
- object? IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ object? IValueConverter.Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is AvaloniaList<double> widthTriggers)
{
@@ -24,7 +24,7 @@ public class WidthTriggersConverter : IValueConverter
return null;
}
- object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ object? IValueConverter.ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is string str)
{
@@ -33,13 +33,12 @@ public class WidthTriggersConverter : IValueConverter
foreach (var s in values)
{
- if (TypeUtilities.TryConvert(typeof(double), s, culture, out var v))
+ if (TypeUtilities.TryConvert(typeof(double), s, culture, out var v) && v is double vd)
{
- widthTriggers.Add((double)v);
+ widthTriggers.Add(vd);
}
else
{
- // throw new InvalidCastException($"Could not convert '{s}' to {typeof(double)}.");
return null;
}
}

MODIFY
WalletWasabi.Fluent/Converters/WindowStateAfterStartJsonConverter.cs
WalletWasabi.Fluent/Converters/WindowStateAfterStartJsonConverter.cs
@@ -12,7 +12,7 @@ public class WindowStateAfterStartJsonConverter : JsonConverter
}
/// <inheritdoc />
- public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
try
{
@@ -33,7 +33,7 @@ public class WindowStateAfterStartJsonConverter : JsonConverter
}
/// <inheritdoc />
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
writer.WriteValue(value);
}

fix nullable warnings in converters.