fix nullability warnings in helpers.
MODIFY
WalletWasabi.Fluent/Helpers/AssetHelpers.cs
WalletWasabi.Fluent/Helpers/AssetHelpers.cs
@@ -6,16 +6,21 @@ namespace WalletWasabi.Fluent.Helpers;
public static class AssetHelpers
{
- public static Bitmap GetBitmapAsset(Uri uri)
+ public static Bitmap? GetBitmapAsset(Uri uri)
{
var assets = AvaloniaLocator.Current.GetService<IAssetLoader>();
+
+ if (assets is { })
+ {
using var image = assets.Open(uri);
return new Bitmap(image);
}
- public static Bitmap GetBitmapAsset(string path)
+ return null;
+ }
+
+ public static Bitmap? GetBitmapAsset(string path)
{
- Uri uri = new(path);
- return GetBitmapAsset(uri);
+ return GetBitmapAsset(new Uri(path));
}
}

MODIFY
WalletWasabi.Fluent/Helpers/FileDialogHelper.cs
WalletWasabi.Fluent/Helpers/FileDialogHelper.cs
@@ -44,18 +44,26 @@ public static class FileDialogHelper
private static async Task<string?> GetDialogResultAsync(OpenFileDialog ofd)
{
- var window = ((IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime).MainWindow;
- var selected = await ofd.ShowAsync(window);
+ if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime lifetime &&
+ lifetime.MainWindow is { })
+ {
+ var selected = await ofd.ShowAsync(lifetime.MainWindow);
return selected?.FirstOrDefault();
}
+ return null;
+ }
+
private static async Task<string?> GetDialogResultAsync(SaveFileDialog sfd)
{
- var window = ((IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime).MainWindow;
- var selected = await sfd.ShowAsync(window);
+ if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime lifetime &&
+ lifetime.MainWindow is { })
+ {
+ return await sfd.ShowAsync(lifetime.MainWindow);
+ }
- return selected;
+ return null;
}
private static OpenFileDialog CreateOpenFileDialog(string title)

MODIFY
WalletWasabi.Fluent/Helpers/FileHelpers.cs
WalletWasabi.Fluent/Helpers/FileHelpers.cs
@@ -40,7 +40,7 @@ public static class FileHelpers
if (openWithNotepad)
{
// Open file using Notepad.
- using Process notepadProcess = Process.Start(new ProcessStartInfo
+ using var notepadProcess = Process.Start(new ProcessStartInfo
{
FileName = "notepad.exe",
Arguments = filePath,
@@ -52,7 +52,7 @@ public static class FileHelpers
}
// Open file with the default editor.
- using Process defaultEditorProcess = Process.Start(new ProcessStartInfo
+ using var defaultEditorProcess = Process.Start(new ProcessStartInfo
{
FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? filePath : "open",
Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? $"-e {filePath}" : "",

MODIFY
WalletWasabi.Fluent/Helpers/ThemeHelper.cs
WalletWasabi.Fluent/Helpers/ThemeHelper.cs
@@ -16,7 +16,10 @@ public static class ThemeHelper
public static void ApplyTheme(Theme theme)
{
- var currentTheme = Application.Current.Styles.Select(x => (StyleInclude)x).FirstOrDefault(x => x.Source is { } && x.Source.AbsolutePath.Contains("Themes"));
+ if (Application.Current is { })
+ {
+ var currentTheme = Application.Current.Styles.Select(x => (StyleInclude)x)
+ .FirstOrDefault(x => x.Source is { } && x.Source.AbsolutePath.Contains("Themes"));
if (currentTheme is { })
{
@@ -32,3 +35,4 @@ public static class ThemeHelper
}
}
}
+}

MODIFY
WalletWasabi.Fluent/Helpers/TransactionHelpers.cs
WalletWasabi.Fluent/Helpers/TransactionHelpers.cs
@@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Authorization.Infrastructure;
using NBitcoin;
using WalletWasabi.Blockchain.Analysis.Clustering;
using WalletWasabi.Blockchain.TransactionBuilding;
@@ -60,6 +61,11 @@ public static class TransactionHelpers
public static BuildTransactionResult BuildTransaction(Wallet wallet, TransactionInfo transactionInfo, bool isPayJoin = false)
{
+ if (transactionInfo.Address is null)
+ {
+ throw new NullReferenceException();
+ }
+
if (transactionInfo.IsOptimized)
{
return BuildChangelessTransaction(

fix nullability warnings in helpers.