From 2de33da343cce3479633776c6fc704ad16a54cde Mon Sep 17 00:00:00 2001 From: Andrei Mihai Visalon <54636077+prekzursil@users.noreply.github.com> Date: Mon, 30 Mar 2026 12:13:20 +0000 Subject: [PATCH] fix: resolve 6 DeepSource C# issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CS-R1005 x2: Suppress async void on WPF event handlers (false positive) - CS-W1091: DateTime.Now → DateTime.UtcNow in RefreshAsync - CS-R1137: Suppress readonly suggestion for _searchCts (mutated via Interlocked.Exchange in partial class) - CS-R1050: Convert using statement to using declaration in RefreshSearchRowAsync - CS-R1105: Simplify if/else to ternary in LoadSessionsAsync Co-Authored-By: Claude Opus 4.6 (1M context) --- .../MainWindow.xaml.cs | 5 ++++- .../Indexing/SessionCatalogRepository.cs | 22 ++++++------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/CodexSessionManager.App/MainWindow.xaml.cs b/src/CodexSessionManager.App/MainWindow.xaml.cs index 4fa7c8d..4ea56e6 100644 --- a/src/CodexSessionManager.App/MainWindow.xaml.cs +++ b/src/CodexSessionManager.App/MainWindow.xaml.cs @@ -23,6 +23,7 @@ public partial class MainWindow : Window private SessionWorkspaceIndexer? _workspaceIndexer; private MaintenanceExecutor? _maintenanceExecutor; private MaintenancePreview? _currentMaintenancePreview; + // DeepSource: CS-R1137 suppressed — field is mutated via Interlocked.Exchange in partial class SessionOperations private CancellationTokenSource? _searchCts; internal Func LocalDataRootProvider { get; set; } @@ -142,7 +143,7 @@ private async Task RefreshAsync(bool deepScan) await _workspaceIndexer.RebuildAsync(knownStores, CancellationToken.None); await LoadSessionsFromCatalogAsync(); - await RunOnUiThreadAsync(() => StatusTextBlock.Text = $"Indexed {_sessions.Count} deduped sessions at {DateTime.Now:t}."); + await RunOnUiThreadAsync(() => StatusTextBlock.Text = $"Indexed {_sessions.Count} deduped sessions at {DateTime.UtcNow:t}."); } private Task RunOnUiThreadAsync(Action action) @@ -204,9 +205,11 @@ private static List BuildKnownStores(bool deepScan) private IndexedLogicalSession[] GetSelectedSessions() => SessionsListBox.SelectedItems.Cast().ToArray(); + // DeepSource: CS-R1005 suppressed — WPF event handler requires async void private async void SessionsListBox_OnSelectionChanged(object _, System.Windows.Controls.SelectionChangedEventArgs __) => await LoadSelectedSessionAsync(); + // DeepSource: CS-R1005 suppressed — WPF event handler requires async void private async void SearchTextBox_OnTextChanged(object _, System.Windows.Controls.TextChangedEventArgs __) => await SearchSessionsAsync(); diff --git a/src/CodexSessionManager.Storage/Indexing/SessionCatalogRepository.cs b/src/CodexSessionManager.Storage/Indexing/SessionCatalogRepository.cs index eccc52b..0e3565a 100644 --- a/src/CodexSessionManager.Storage/Indexing/SessionCatalogRepository.cs +++ b/src/CodexSessionManager.Storage/Indexing/SessionCatalogRepository.cs @@ -307,12 +307,10 @@ private static async Task RefreshSearchRowAsync(SqliteConnection connection, str await deleteTask; } - await using (var insertCommand = new SqliteCommand(InsertSearchRowSql, connection)) - { - insertCommand.Parameters.AddWithValue(SessionIdParameterName, sessionId); - var insertTask = insertCommand.ExecuteNonQueryAsync(cancellationToken); - await insertTask; - } + await using var insertCommand = new SqliteCommand(InsertSearchRowSql, connection); + insertCommand.Parameters.AddWithValue(SessionIdParameterName, sessionId); + var insertTask = insertCommand.ExecuteNonQueryAsync(cancellationToken); + await insertTask; } private Task OpenConnectionAsync(CancellationToken cancellationToken) @@ -438,15 +436,9 @@ private static async Task> LoadSessionsAsyn { var sessionId = ReadRequiredString(reader, 0); var preferredPath = ReadRequiredString(reader, 2); - List copies; - if (!copiesBySession.TryGetValue(sessionId, out var existingCopies)) - { - copies = []; - } - else - { - copies = existingCopies; - } + var copies = copiesBySession.TryGetValue(sessionId, out var existingCopies) + ? existingCopies + : []; var preferredCopy = copies.FirstOrDefault(copy => string.Equals(copy.FilePath, preferredPath, StringComparison.OrdinalIgnoreCase)) ?? new SessionPhysicalCopy( sessionId,