Fix some obvious null warnings
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterViewModel.cs
@@ -192,7 +192,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
}
- private async Task<string> OpenDialogAsync()
+ private async Task<string?> OpenDialogAsync()
{
var ofd = new OpenFileDialog
{
@@ -214,7 +214,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
ofd.Directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
}
- var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).MainWindow;
+ var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
var selected = await ofd.ShowAsync(window, fallBack: true);
return selected?.FirstOrDefault();
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/TransactionViewerViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/TransactionViewerViewModel.cs
@@ -68,7 +68,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
sfd.Directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
}
- var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).MainWindow;
+ var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
string fileFullName = await sfd.ShowAsync(window, fallBack: true);
if (!string.IsNullOrWhiteSpace(fileFullName))
{

MODIFY
WalletWasabi.Gui/Dialogs/AvaloniaControlsExtensions.cs
WalletWasabi.Gui/Dialogs/AvaloniaControlsExtensions.cs
@@ -12,18 +12,18 @@ namespace Avalonia.Controls
{
public static class AvaloniaControlsExtensions
{
- public static async Task<string> ShowAsync(this SaveFileDialog me, Window parent, bool fallBack)
+ public static async Task<string> ShowAsync(this SaveFileDialog me, Window? parent, bool fallBack)
{
var ret = await ShowAsync(me as FileDialog, parent, fallBack);
return Guard.Correct(ret?.FirstOrDefault());
}
- public static async Task<string[]> ShowAsync(this OpenFileDialog me, Window parent, bool fallBack)
+ public static async Task<string[]> ShowAsync(this OpenFileDialog me, Window? parent, bool fallBack)
{
return await ShowAsync(me as FileDialog, parent, fallBack);
}
- private static async Task<string[]> ShowAsync(this FileDialog me, Window parent, bool fallBack)
+ private static async Task<string[]> ShowAsync(this FileDialog me, Window? parent, bool fallBack)
{
if (fallBack)
{
@@ -83,7 +83,7 @@ namespace Avalonia.Controls
}
}
- private static async Task<string[]> ShowOpenSaveFileDialogAsync(FileDialog me, Window parent)
+ private static async Task<string[]> ShowOpenSaveFileDialogAsync(FileDialog me, Window? parent)
{
if (me is OpenFileDialog ofd)
{

MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -670,7 +670,7 @@ namespace WalletWasabi.Gui
Dispatcher.UIThread.PostLogException(() =>
{
- var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).MainWindow;
+ var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
window?.Close();
});

MODIFY
WalletWasabi.Gui/Shell/Commands/SystemCommands.cs
WalletWasabi.Gui/Shell/Commands/SystemCommands.cs
@@ -45,7 +45,7 @@ namespace WalletWasabi.Gui.Shell.Commands
private void OnExit()
{
- (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).MainWindow.Close();
+ (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow.Close();
}
}
}

MODIFY
WalletWasabi.Gui/Shell/Commands/ToolCommands.cs
WalletWasabi.Gui/Shell/Commands/ToolCommands.cs
@@ -31,7 +31,7 @@ namespace WalletWasabi.Gui.Shell.Commands
#if DEBUG
var devToolsCommand = ReactiveCommand.Create(() =>
- DevToolsExtensions.OpenDevTools((Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).MainWindow));
+ DevToolsExtensions.OpenDevTools((Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow));
#endif
Observable
.Merge(walletManagerCommand.ThrownExceptions)

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/HardwareWallets/ConnectHardwareWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/HardwareWallets/ConnectHardwareWalletViewModel.cs
@@ -85,7 +85,7 @@ namespace WalletWasabi.Gui.Tabs.WalletManager.HardwareWallets
ofd.Directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
}
- var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).MainWindow;
+ var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
var selected = await ofd.ShowAsync(window, fallBack: true);
if (selected is { } && selected.Any())
{

Fix some obvious null warnings