refactor: use collection expressions for empty list initializers#849
Merged
Conversation
Replaced 'var x = new List<T>()' with 'List<T> x = []' across 7 files (8 sites: WingetTableParser, FileShredderService, TemperatureService x2, WindowsUpdateService, BulkInstallerViewModel, LogsViewModel, TracerouteViewModel). Pure .NET 10 idiom modernization — the collection expression compiles to the same List<T> construction, so behavior is byte-identical. The explicit type is required because a collection expression needs a target type (can't infer from var).
laurentiu021
added a commit
that referenced
this pull request
Jun 11, 2026
…al count) (#850) GetIcon_SamePath_UsesCachedResult and ClearCache_ResetsCount asserted on the global CacheCount of the shared static icon cache. That cache is touched by tests in OTHER collections (via VMs that call GetIcon), running in parallel, so an entry added between the test's two count reads broke the assertion. The SamePath test failed once in PR #849's CI for exactly this reason — unrelated to that PR's change. Added an internal IconExtractorService.IsCached(path) that checks one normalized key, and rewrote both tests to assert per-key caching (cached after first call, dropped after ClearCache) instead of the global count. Deterministic regardless of what other parallel tests do to the shared cache. Production behavior unchanged (the helper is additive; InternalsVisibleTo already declared). Co-authored-by: laurentiu021 <laurentiu021@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Audit Round 8 (.NET 10 modernization). Replaced
var x = new List<T>()withList<T> x = []across 7 files (8 sites): WingetTableParser, FileShredderService, TemperatureService (×2), WindowsUpdateService, BulkInstallerViewModel, LogsViewModel, TracerouteViewModel.Behavior guarantee (Protocol Q)
Byte-identical. A collection expression
[]for aList<T>target compiles to the samenew List<T>()construction — pure compiler sugar. The declaration uses an explicit type because a collection expression needs a target type (it can't be inferred fromvar).Scope note
I deliberately limited this to the unambiguous empty-list initializers. The blanket
catch (Exception)clauses (also in the R8 backlog) are not included — converting those changes which exceptions are caught and needs per-site judgement (many are intentional top-of-command catch-alls that keep the UI from crashing), so they don't belong in a mechanical, behavior-identical sweep.Verification
Notes
refactor:— no version bump, no release, no CHANGELOG entry required.