From 19f22d2d9728f80bc66655b1cec520209de5bdfc Mon Sep 17 00:00:00 2001 From: mika kuns Date: Fri, 29 May 2026 14:25:44 +0200 Subject: [PATCH] chore(ui): clear build warnings - Guard Windows-only ServiceController/registry calls behind SupportedOSPlatform and OperatingSystem.IsWindows() (CA1416) - Initialize test-only ctor fields with null! (CS8618) - Migrate obsolete Avalonia APIs: Watermark -> PlaceholderText, SystemDecorations -> WindowDecorations Co-Authored-By: Claude Opus 4.7 --- src/ClaudeDo.Ui/Services/InstallerLocator.cs | 3 +- .../ViewModels/IslandsShellViewModel.cs | 29 ++++++++++--------- .../Views/Controls/ThemedDatePicker.axaml | 2 +- .../Views/Islands/TasksIslandView.axaml | 2 +- src/ClaudeDo.Ui/Views/MainWindow.axaml | 2 +- .../Views/Modals/DiffModalView.axaml | 2 +- .../Views/Modals/ListSettingsModalView.axaml | 4 +-- .../Views/Modals/MergeModalView.axaml | 2 +- .../Views/Modals/SettingsModalView.axaml | 6 ++-- .../Modals/UnfinishedPlanningModalView.axaml | 2 +- .../Views/Modals/WorktreeModalView.axaml | 2 +- .../Modals/WorktreesOverviewModalView.axaml | 2 +- .../Planning/ConflictResolutionView.axaml | 2 +- .../Views/Planning/PlanningDiffView.axaml | 2 +- 14 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/ClaudeDo.Ui/Services/InstallerLocator.cs b/src/ClaudeDo.Ui/Services/InstallerLocator.cs index de15542..9651810 100644 --- a/src/ClaudeDo.Ui/Services/InstallerLocator.cs +++ b/src/ClaudeDo.Ui/Services/InstallerLocator.cs @@ -7,7 +7,8 @@ public sealed class InstallerLocator private const string UninstallerSubdir = "uninstaller"; public string? Find() - => FindByWalkingUp(AppContext.BaseDirectory) ?? FindByRegistry(); + => FindByWalkingUp(AppContext.BaseDirectory) + ?? (OperatingSystem.IsWindows() ? FindByRegistry() : null); public string? FindByWalkingUp(string startDir) { diff --git a/src/ClaudeDo.Ui/ViewModels/IslandsShellViewModel.cs b/src/ClaudeDo.Ui/ViewModels/IslandsShellViewModel.cs index 739ded8..1048584 100644 --- a/src/ClaudeDo.Ui/ViewModels/IslandsShellViewModel.cs +++ b/src/ClaudeDo.Ui/ViewModels/IslandsShellViewModel.cs @@ -29,8 +29,8 @@ public sealed partial class IslandsShellViewModel : ViewModelBase public bool IsOffline => Worker?.IsConnected != true && Worker?.IsReconnecting != true; - private readonly UpdateCheckService _updateCheck; - private readonly InstallerLocator _installerLocator; + private readonly UpdateCheckService _updateCheck = null!; + private readonly InstallerLocator _installerLocator = null!; private readonly IDbContextFactory? _dbFactory; private readonly Func _worktreesOverviewVmFactory = () => null!; private readonly Func _mergeVmFactory = () => null!; @@ -297,17 +297,7 @@ public sealed partial class IslandsShellViewModel : ViewModelBase RestartWorkerStatus = "Restarting worker…"; try { - await Task.Run(() => - { - using var sc = new System.ServiceProcess.ServiceController("ClaudeDoWorker"); - if (sc.Status != System.ServiceProcess.ServiceControllerStatus.Stopped) - { - sc.Stop(); - sc.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(20)); - } - sc.Start(); - sc.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Running, TimeSpan.FromSeconds(20)); - }); + await Task.Run(RestartWorkerService); await FlashRestartStatusAsync("Worker restarted."); } catch (InvalidOperationException) @@ -321,6 +311,19 @@ public sealed partial class IslandsShellViewModel : ViewModelBase } } + [System.Runtime.Versioning.SupportedOSPlatform("windows")] + private static void RestartWorkerService() + { + using var sc = new System.ServiceProcess.ServiceController("ClaudeDoWorker"); + if (sc.Status != System.ServiceProcess.ServiceControllerStatus.Stopped) + { + sc.Stop(); + sc.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(20)); + } + sc.Start(); + sc.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Running, TimeSpan.FromSeconds(20)); + } + private async Task FlashRestartStatusAsync(string text) { RestartWorkerStatus = text; diff --git a/src/ClaudeDo.Ui/Views/Controls/ThemedDatePicker.axaml b/src/ClaudeDo.Ui/Views/Controls/ThemedDatePicker.axaml index f20d154..115a0f2 100644 --- a/src/ClaudeDo.Ui/Views/Controls/ThemedDatePicker.axaml +++ b/src/ClaudeDo.Ui/Views/Controls/ThemedDatePicker.axaml @@ -154,7 +154,7 @@ Foreground="{DynamicResource TextDimBrush}" Margin="0,0,8,0"/>