Skip to content

chore: modern C# — GeneratedRegex, sealed classes (#313 partial)#369

Merged
laurentiu021 merged 1 commit into
mainfrom
chore/modern-csharp-313
May 15, 2026
Merged

chore: modern C# — GeneratedRegex, sealed classes (#313 partial)#369
laurentiu021 merged 1 commit into
mainfrom
chore/modern-csharp-313

Conversation

@laurentiu021

@laurentiu021 laurentiu021 commented May 15, 2026

Copy link
Copy Markdown
Owner

Summary

Continues #313 (Modern C#). Addresses MODERN-001 and MODERN-005.

Changes

MODERN-001: GeneratedRegex

  • ServiceManagerService — runtime Regex.IsMatch replaced with [GeneratedRegex] source generator
  • AppBlockerService — 2x runtime Regex.IsMatch replaced with [GeneratedRegex]

MODERN-005: sealed classes

  • ServiceManagerService — sealed
  • NetworkRepairService — sealed
  • PerformanceService — sealed
  • PowerShellRunner — sealed
  • SystemInfoService — sealed

None of these classes are inherited anywhere in the codebase.

Remaining for #313

  • MODERN-002: LibraryImport (complex, separate PR)
  • MODERN-004: sealed records
  • MODERN-006: SystemSnapshot mutable List

No release triggered

chore: prefix — no version bump.

Summary by CodeRabbit

  • Refactor
    • Internal optimization of service components to improve code maintainability and reliability.
    • Enhanced validation mechanisms across services with performance-focused improvements.
    • Strengthened service architecture design patterns for better stability.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cca28bc8-c4c2-4db9-b77d-ae4c162d6764

📥 Commits

Reviewing files that changed from the base of the PR and between 46bdc9b and 8768e70.

📒 Files selected for processing (6)
  • SysManager/SysManager/Services/AppBlockerService.cs
  • SysManager/SysManager/Services/NetworkRepairService.cs
  • SysManager/SysManager/Services/PerformanceService.cs
  • SysManager/SysManager/Services/PowerShellRunner.cs
  • SysManager/SysManager/Services/ServiceManagerService.cs
  • SysManager/SysManager/Services/SystemInfoService.cs
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (csharp)
  • GitHub Check: Build & unit tests
🔇 Additional comments (6)
SysManager/SysManager/Services/NetworkRepairService.cs (1)

13-13: LGTM!

SysManager/SysManager/Services/PerformanceService.cs (1)

27-27: LGTM!

SysManager/SysManager/Services/PowerShellRunner.cs (1)

22-22: LGTM!

SysManager/SysManager/Services/SystemInfoService.cs (1)

13-13: LGTM!

SysManager/SysManager/Services/AppBlockerService.cs (1)

20-20: LGTM!

Also applies to: 36-36, 81-81, 194-195

SysManager/SysManager/Services/ServiceManagerService.cs (1)

14-14: LGTM!

Also applies to: 131-131, 166-167


📝 Walkthrough

Walkthrough

Six service classes are refactored to improve encapsulation and performance: NetworkRepairService, PerformanceService, PowerShellRunner, and SystemInfoService are sealed to prevent inheritance. AppBlockerService and ServiceManagerService are additionally converted to sealed partial classes with source-generated regex patterns replacing inline regex validation calls.

Changes

Service Class Sealing and Regex Code Generation

Layer / File(s) Summary
Seal remaining service classes
SysManager/SysManager/Services/NetworkRepairService.cs, SysManager/SysManager/Services/PerformanceService.cs, SysManager/SysManager/Services/PowerShellRunner.cs, SysManager/SysManager/Services/SystemInfoService.cs
NetworkRepairService, PerformanceService, PowerShellRunner, and SystemInfoService are declared sealed, preventing inheritance by external code.
AppBlockerService sealed partial and generated regex validation
SysManager/SysManager/Services/AppBlockerService.cs
AppBlockerService becomes sealed partial and refactors executable-name validation from inline Regex.IsMatch calls to a new ExeNamePattern() helper method decorated with [GeneratedRegex]. Both BlockApp and UnblockApp methods use the generated regex.
ServiceManagerService sealed partial and generated regex validation
SysManager/SysManager/Services/ServiceManagerService.cs
ServiceManagerService becomes sealed partial and refactors service-name validation in SetStartupTypeAsync from inline Regex.IsMatch to a new ServiceNamePattern() helper method decorated with [GeneratedRegex].

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Six services sealed with care so tight,
Regex patterns born at build-time light,
Generated code, no runtime strain,
Encapsulation flows through every vein,
Performance blooms in the SysManager lane! 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and specifically describes the main changes: modernizing C# code by introducing GeneratedRegex source generators and sealing classes, which aligns perfectly with the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/modern-csharp-313

Comment @coderabbitai help to get the list of available commands and usage tips.

@laurentiu021
laurentiu021 merged commit 8167322 into main May 15, 2026
5 checks passed
@laurentiu021
laurentiu021 deleted the chore/modern-csharp-313 branch May 15, 2026 06:25
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ysManager/SysManager/Services/AppBlockerService.cs 0.00% 1 Missing and 1 partial ⚠️
...nager/SysManager/Services/ServiceManagerService.cs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

laurentiu021 added a commit that referenced this pull request May 22, 2026
Add CHANGELOG entries for four releases from the code audit sessions:

- **v0.28.10**: Critical fixes (deadlock, COM leak, 50MB alloc, input
validation)
- **v0.28.11**: ViewModel lifecycle cleanup (IDisposable, event
handlers, fire-and-forget)
- **v0.28.12**: CodeQL catch-of-all-exceptions (12 files, ~22 alerts)
- **v0.28.13**: CodeQL remaining (DuplicateFileService, App.xaml.cs,
StartupService)

Co-authored-by: laurentiu021 <laurentiu021@users.noreply.github.com>
laurentiu021 added a commit that referenced this pull request May 22, 2026
Co-authored-by: laurentiu021 <laurentiu021@users.noreply.github.com>
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.

2 participants