Simplify and fix namespaces
MODIFY
WalletWasabi.Fluent.Desktop/Program.cs
WalletWasabi.Fluent.Desktop/Program.cs
@@ -7,10 +7,10 @@ using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
+using WalletWasabi.CrashReport;
using WalletWasabi.Fluent.Helpers;
using WalletWasabi.Gui;
using WalletWasabi.Gui.CommandLine;
-using WalletWasabi.Gui.CrashReport;
using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
@@ -48,16 +48,11 @@ namespace WalletWasabi.Fluent.Desktop
if (CrashReporter.TryProcessCliArgs(args))
{
+ Console.WriteLine("TODO Implement crash reporting.");
}
runGui = ProcessCliCommands(args);
- if (CrashReporter.IsReport)
- {
- Console.WriteLine("TODO Implement crash reporting.");
- return;
- }
-
if (runGui)
{
Logger.LogSoftwareStarted("Wasabi GUI");
@@ -134,11 +129,8 @@ namespace WalletWasabi.Fluent.Desktop
mainViewModel.Dispose();
}
- if (CrashReporter.IsInvokeRequired is true)
- {
// Trigger the CrashReport process.
CrashReporter.TryInvokeCrashReport();
- }
if (Global is { } global)
{

MODIFY
WalletWasabi.Gui/CrashReport/ViewModels/CrashReportWindowViewModel.cs
WalletWasabi.Gui/CrashReport/ViewModels/CrashReportWindowViewModel.cs
@@ -3,6 +3,7 @@ using Splat;
using System;
using System.Reactive;
using System.Reactive.Linq;
+using WalletWasabi.CrashReport;
using WalletWasabi.Gui.Helpers;
using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Logging;

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -11,6 +11,7 @@ using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
+using WalletWasabi.CrashReport;
using WalletWasabi.Gui.CommandLine;
using WalletWasabi.Gui.CrashReport;
using WalletWasabi.Gui.ViewModels;
@@ -53,11 +54,7 @@ namespace WalletWasabi.Gui
runGui = ProcessCliCommands(args);
- if (CrashReporter.IsReport)
- {
- StartCrashReporter(args);
- }
- else if (runGui)
+ if (runGui)
{
Logger.LogSoftwareStarted("Wasabi GUI");
BuildAvaloniaApp().StartShellApp("Wasabi Wallet", AppMainAsync, args);
@@ -153,12 +150,6 @@ namespace WalletWasabi.Gui
mainViewModel.Dispose();
}
- if (CrashReporter.IsInvokeRequired is true)
- {
- // Trigger the CrashReport process.
- CrashReporter.TryInvokeCrashReport();
- }
-
if (Global is { } global)
{
await global.DisposeAsync().ConfigureAwait(false);
@@ -183,30 +174,6 @@ namespace WalletWasabi.Gui
Logger.LogWarning(e?.ExceptionObject as Exception);
}
- private static void StartCrashReporter(string[] args)
- {
- var result = AppBuilder.Configure<CrashReportApp>().UseReactiveUI();
-
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
- {
- result
- .UseWin32()
- .UseSkia();
- }
- else
- {
- result.UsePlatformDetect();
- }
-
- result
- .With(new Win32PlatformOptions { AllowEglInitialization = false, UseDeferredRendering = true })
- .With(new X11PlatformOptions { UseGpu = false, WmClass = "Wasabi Wallet Crash Reporting" })
- .With(new AvaloniaNativePlatformOptions { UseDeferredRendering = true, UseGpu = false })
- .With(new MacOSPlatformOptions { ShowInDock = true });
-
- result.StartShellApp("Wasabi Wallet", _ => SetTheme(), args);
- }
-
private static AppBuilder BuildAvaloniaApp()
{
bool useGpuLinux = true;

MODIFY
WalletWasabi.Tests/UnitTests/Clients/CrashReportTests.cs
WalletWasabi.Tests/UnitTests/Clients/CrashReportTests.cs
using System;
-using WalletWasabi.Gui.CrashReport;
+using WalletWasabi.CrashReport;
using Xunit;
namespace WalletWasabi.Tests.UnitTests.Clients
@@ -32,7 +32,6 @@ namespace WalletWasabi.Tests.UnitTests.Clients
// Args are split by space and passed to Main IRL.
Assert.True(reporting.TryProcessCliArgs(args.Split(' ')));
- Assert.True(reporting.IsReport);
Assert.Equal(reporting.SerializedException, ex.ToSerializableException());
}
}

MODIFY
WalletWasabi/CrashReport/CrashReporter.cs
WalletWasabi/CrashReport/CrashReporter.cs
@@ -4,20 +4,23 @@ using WalletWasabi.Logging;
using WalletWasabi.Microservices;
using WalletWasabi.Models;
-namespace WalletWasabi.Gui.CrashReport
+namespace WalletWasabi.CrashReport
{
public class CrashReporter
{
private const int MaxRecursiveCalls = 5;
public int Attempts { get; private set; }
public string? Base64ExceptionString { get; private set; } = null;
- public bool IsReport { get; private set; }
public bool HadException { get; private set; }
- public bool IsInvokeRequired => !IsReport && HadException;
public SerializableException? SerializedException { get; private set; }
public void TryInvokeCrashReport()
{
+ if (!HadException)
+ {
+ return;
+ }
+
try
{
if (Attempts >= MaxRecursiveCalls)
@@ -68,7 +71,6 @@ namespace WalletWasabi.Gui.CrashReport
Attempts = int.Parse(attemptString);
Base64ExceptionString = exceptionString;
SerializedException = SerializableException.FromBase64String(exceptionString);
- IsReport = true;
return true;
}

Simplify and fix namespaces