Organize helpers in Gui
RENAME
WalletWasabi.Gui/Helpers/AvaloniaExtensions.cs
WalletWasabi.Gui/Helpers/AvalonStudioShellExtensions.cs
@@ -5,10 +5,12 @@ using System.Linq;
using System.Collections.Generic;
using System.Text;
using AvalonStudio.Extensibility;
+using Avalonia.Threading;
+using System.Threading.Tasks;
-namespace System
+namespace AvalonStudio.Shell
{
- public static class AvaloniaExtensions
+ public static class AvalonStudioShellExtensions
{
// Replacement of avalonia's https://github.com/VitalElement/AvalonStudio.Shell/blob/eaa708e6c1428afd142e364dc6dbbd7ff5ba69dc/src/AvalonStudio.Shell.Extensibility/Shell/IShellExtensions.cs
// because we want to use IoC to create T

ADD
WalletWasabi.Gui/Helpers/AvaloniaThreadingExtensions.cs
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Avalonia.Threading
+{
+ public static class AvaloniaThreadingExtensions
+ {
+ public static void PostLogException(this Dispatcher dispatcher, Func<Task> action, DispatcherPriority priority = DispatcherPriority.Normal)
+ {
+ dispatcher.Post(async () =>
+ {
+ try
+ {
+ await action();
+ }
+ catch (Exception ex)
+ {
+ WalletWasabi.Logging.Logger.LogDebug<Dispatcher>(ex);
+ }
+ }, priority);
+ }
+
+ public static void PostLogException(this Dispatcher dispatcher, Action action, DispatcherPriority priority = DispatcherPriority.Normal)
+ {
+ dispatcher.Post(() =>
+ {
+ try
+ {
+ action();
+ }
+ catch (Exception ex)
+ {
+ WalletWasabi.Logging.Logger.LogDebug<Dispatcher>(ex);
+ }
+ }, priority);
+ }
+ }
+}

ADD
WalletWasabi.Gui/Helpers/ShellExecuteResult.cs
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WalletWasabi.Gui.Helpers
+{
+ public struct ShellExecuteResult
+ {
+ public int ExitCode { get; set; }
+ public string Output { get; set; }
+ public string ErrorOutput { get; set; }
+ }
+}

ADD
WalletWasabi.Gui/Helpers/ShellType.cs
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WalletWasabi.Gui.Helpers
+{
+ public enum ShellType
+ {
+ Generic,
+ Windows,
+ Unix
+ }
+}

RENAME
WalletWasabi.Gui/Utils/ProcessUtils.cs
WalletWasabi.Gui/Helpers/ShellUtils.cs
@@ -5,48 +5,13 @@ using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
+using WalletWasabi.Gui.Models;
-namespace WalletWasabi.Gui
+namespace WalletWasabi.Gui.Helpers
{
- public enum ShellType
- {
- Generic,
- Windows,
- Unix
- }
-
- public struct ShellExecuteResult
- {
- public int ExitCode { get; set; }
- public string Output { get; set; }
- public string ErrorOutput { get; set; }
- }
-
- public static class Utils
- {
- public static bool DetectLLVMPipeRasterizer()
- {
- try
- {
- var shellResult = ShellUtils.ExecuteShellCommand("glxinfo | grep renderer", "");
-
- if (!string.IsNullOrWhiteSpace(shellResult.Output) && shellResult.Output.Contains("llvmpipe"))
- {
- return true;
- }
- }
- catch (Exception)
- {
- // do nothing
- }
-
- return false;
- }
- }
-
public static class ShellUtils
{
- private static ShellType ExecutorType = ShellType.Generic;
+ private static ShellType ExecutorType { get; } = ShellType.Generic;
static ShellUtils()
{

MODIFY
WalletWasabi.Gui/Helpers/Utils.cs
WalletWasabi.Gui/Helpers/Utils.cs
@@ -4,38 +4,27 @@ using System.IO;
using System.Threading.Tasks;
using WalletWasabi.Hwi.Models;
-namespace WalletWasabi.Gui
+namespace WalletWasabi.Gui.Helpers
{
public static class Utils
{
- public static void PostLogException(this Dispatcher dispatcher, Func<Task> action, DispatcherPriority priority = DispatcherPriority.Normal)
- {
- dispatcher.Post(async () =>
+ public static bool DetectLLVMPipeRasterizer()
{
try
{
- await action();
- }
- catch (Exception ex)
- {
- Logging.Logger.LogDebug<Dispatcher>(ex);
- }
- }, priority);
- }
+ var shellResult = ShellUtils.ExecuteShellCommand("glxinfo | grep renderer", "");
- public static void PostLogException(this Dispatcher dispatcher, Action action, DispatcherPriority priority = DispatcherPriority.Normal)
+ if (!string.IsNullOrWhiteSpace(shellResult.Output) && shellResult.Output.Contains("llvmpipe"))
{
- dispatcher.Post(() =>
- {
- try
- {
- action();
+ return true;
}
- catch (Exception ex)
+ }
+ catch (Exception)
{
- Logging.Logger.LogDebug<Dispatcher>(ex);
+ // do nothing
}
- }, priority);
+
+ return false;
}
}
}

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -103,7 +103,7 @@ namespace WalletWasabi.Gui
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
- if(Utils.DetectLLVMPipeRasterizer())
+ if (Helpers.Utils.DetectLLVMPipeRasterizer())
{
useGpuLinux = false;
}

MODIFY
WalletWasabi.Gui/Tabs/AboutViewModel.cs
WalletWasabi.Gui/Tabs/AboutViewModel.cs
@@ -10,7 +10,7 @@ namespace WalletWasabi.Gui.Tabs
{
public AboutViewModel(Global global) : base(global, "About")
{
- Version = Helpers.Constants.ClientVersion;
+ Version = WalletWasabi.Helpers.Constants.ClientVersion;
}
public Version Version { get; }

Organize helpers in Gui