Skip to content

refactor: modernize single-element JSON handling and log previously-silent catches#967

Merged
laurentiu021 merged 2 commits into
mainfrom
refactor/collection-expressions
Jun 22, 2026
Merged

refactor: modernize single-element JSON handling and log previously-silent catches#967
laurentiu021 merged 2 commits into
mainfrom
refactor/collection-expressions

Conversation

@laurentiu021

Copy link
Copy Markdown
Owner

Summary

Modernization sweep — code idiom + exception-handling uniformity. refactor:, behavior-preserving, no release.

Changes

  • Collection expression for single-element JSON (DriversViewModel, WindowsUpdateViewModel): new[] { root }.AsEnumerable() -> [root] with an explicit IEnumerable<JsonElement> target type. Same result, idiomatic .NET 10.
  • Log previously-silent catches: FileShredderService.EnumerateFilesSafe and AboutViewModel's build-date reader had empty catch (IOException)/(UnauthorizedAccessException) blocks. They now Log.Debug(...) like the rest of the codebase (Protocol I: empty catches must log at Debug minimum). Both run once per directory / once per call, so no log flooding.

Notes from the audit (deliberately NOT applied)

  • Many .Where(...).ToList() -> [.. ...] suggestions were skipped: they force a var -> explicit-type rewrite for no real gain and .ToList() is already fine.
  • LatencySeries.ToList().FindIndex(...) was left as-is: ObservableCollection<T> has no FindIndex, so the audit's proposed .FindIndex would not compile, and the .ToList() is on a cold path.
  • LargeFileScanner's per-directory empty catches were left silent intentionally — that loop walks an entire drive and logging every access-denied would flood the log.

Verification

  • dotnet build (app + tests): 0 warnings, 0 errors.

@laurentiu021 laurentiu021 merged commit 5ace728 into main Jun 22, 2026
4 checks passed
@laurentiu021 laurentiu021 deleted the refactor/collection-expressions branch June 22, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant