Skip to content

refactor: use [GeneratedRegex] for SFC/DISM/speedtest literal patterns#852

Merged
laurentiu021 merged 1 commit into
mainfrom
refactor/r8-generated-regex
Jun 11, 2026
Merged

refactor: use [GeneratedRegex] for SFC/DISM/speedtest literal patterns#852
laurentiu021 merged 1 commit into
mainfrom
refactor/r8-generated-regex

Conversation

@laurentiu021

Copy link
Copy Markdown
Owner

Summary

Converts the three remaining literal-pattern Regex.Match call sites to
source-generated [GeneratedRegex] partial methods. The pattern strings are
unchanged, so matching behavior is byte-identical — [GeneratedRegex] just moves
compilation from runtime to build time (no startup Regex construction, no
per-call interpreter overhead).

Changes

  • ViewModels/CleanupViewModel.cs
    • SFC progress: Regex.Match(l.Text, @"(\d+)\s*%")SfcPercentRegex().Match(...)
    • DISM progress: Regex.Match(l.Text, @"([\d.]+)%")DismPercentRegex().Match(...)
  • ViewModels/SpeedTestViewModel.cs
    • Server-id parse: Regex.Match(option, @"ID:\s*(\d+)")ServerIdRegex().Match(...)
    • Added using System.Text.RegularExpressions; (was fully-qualified before).

Not converted (deliberately)

  • LogService line 33 builds its regex from an interpolated pattern
    ($@"(?i)({escaped})...") — a runtime value, so it cannot be source-generated.
    It stays a runtime Regex. The constant fallback pattern there was already
    converted in the earlier [GeneratedRegex] PR.

Verification

  • Pattern strings verified identical old→new (diff-checked, no character changed).
  • Both VMs are already sealed partial class — the prerequisite for [GeneratedRegex].
  • Build: main + Tests + IntegrationTests all 0 warnings / 0 errors.

Behavior identical (Protocol Q). refactor: → no release.

@laurentiu021 laurentiu021 merged commit 4ec3b4b into main Jun 11, 2026
4 checks passed
@laurentiu021 laurentiu021 deleted the refactor/r8-generated-regex branch June 11, 2026 12:53
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