Skip to content

Fix code review findings and AOT audit#299

Merged
JusterZhu merged 1 commit into
masterfrom
fix/code-review-findings-issue-298
May 23, 2026
Merged

Fix code review findings and AOT audit#299
JusterZhu merged 1 commit into
masterfrom
fix/code-review-findings-issue-298

Conversation

@JusterZhu
Copy link
Copy Markdown
Collaborator

Summary

Address all findings from the 9-PR Drivelution code review and AOT audit.

AOT Audit

No new AOT/trimming warnings introduced. Only pre-existing warning: GeneralTracer.StackFrame.GetMethod (IL2026).

P0 (Critical)

  • RetryPolicy: extract duplicate delay logic, exception semantics unified
  • Rollback: uses CancellationToken.None to prevent timeout from killing rollback
  • BatchUpdateAsync: fix broken Interlocked.CompareExchange pattern for progress
  • VerifyInstallationAsync: pnputil non-zero exit treated as non-fatal

P1 (Medium)

  • CommandRunner: kill process on cancellation to prevent zombie processes
  • DrivelutionFactory: CreateValidator/CreateBackup return macOS implementations
  • Factory error message: includes macOS
  • BackupAsync: try-catch for consistency

P2 (Low)

  • Remove dead ReportProgress/OnProgress
  • Merge QuickUpdateAsync overloads
  • PipelineResult.Exception propagated to ErrorInfo

Closes #298

…gress, cleanup

P0 fixes:
- RetryPolicy: extract duplicate delay logic, improve exception capture on last retry
- BaseDriverUpdater: rollback uses CancellationToken.None (prevent timeout cancellation)
- BatchUpdateAsync: fix Interlocked.CompareExchange → Interlocked.Increment pattern for progress
- Windows VerifyInstallationAsync: treat pnputil non-zero exit as non-fatal (don't trigger rollback)

P1 fixes:
- CommandRunner: kill process on cancellation token (prevent zombie processes)
- DrivelutionFactory: CreateValidator/CreateBackup now return macOS implementations
- DrivelutionFactory: error message includes macOS
- BaseDriverUpdater.BackupAsync: add try-catch for consistency with ValidateAsync

P2 fixes:
- Remove dead ReportProgress method and OnProgress event
- Merge QuickUpdateAsync overloads into single method with optional strategy
- PipelineResult.Exception now propagated to ErrorInfo.Details/StackTrace

Closes #298
Copilot AI review requested due to automatic review settings May 23, 2026 11:38
@JusterZhu JusterZhu merged commit acaa63a into master May 23, 2026
1 check failed
@JusterZhu JusterZhu deleted the fix/code-review-findings-issue-298 branch May 23, 2026 11:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request addresses findings from the Drivelution code review and AOT audit by tightening cancellation/retry behavior, improving rollback/verification semantics, and cleaning up/aligning factory and public API surfaces.

Changes:

  • Adjusts pipeline error/rollback behavior (propagate exception details; rollback not cancelled by timeout; fixes batch progress calculation; wraps backup in try/catch).
  • Updates execution and platform plumbing (kill external processes on cancellation; factory now returns macOS validator/backup implementations and updates supported-platform messaging).
  • Tweaks top-level API and Windows verification behavior (merge QuickUpdateAsync overloads; treat pnputil /enum-drivers failures as non-fatal).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs Treats pnputil verification failures as non-fatal to avoid unnecessary rollbacks.
src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs Merges QuickUpdateAsync overloads and introduces optional strategy parameter.
src/c#/GeneralUpdate.Drivelution/Core/Pipeline/RetryPolicy.cs Refactors retry delay logic and adjusts exception/cancellation handling documentation/behavior.
src/c#/GeneralUpdate.Drivelution/Core/Pipeline/BaseDriverUpdater.cs Improves error detail propagation, rollback token usage, backup error handling, and batch progress reporting; removes dead progress event API.
src/c#/GeneralUpdate.Drivelution/Core/Execution/CommandRunner.cs Ensures spawned processes are killed when callers cancel.
src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs Updates supported platform error message and returns macOS validator/backup implementations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


await process.WaitForExitAsync(cancellationToken);
// Ensure the process is killed if the caller cancels the wait
await using (cancellationToken.Register(() =>
Comment on lines 60 to 63
/// <summary>
/// Executes an asynchronous operation with retry logic.
/// On the last retry, the exception is wrapped in a descriptive AggregateException rather than escaping raw.
/// </summary>
Comment on lines +175 to +176
// Use a fresh CancellationToken for rollback — the linked token may be cancelled by timeout
var rolledBack = await TryRollbackAsync(backupPath, CancellationToken.None);
try
{
return await _backup.BackupAsync(driverInfo.FilePath, backupPath, cancellationToken);
}
Comment on lines 63 to 67
public static async Task<UpdateResult> QuickUpdateAsync(
DriverInfo driverInfo,
DriverInfo driverInfo,
UpdateStrategy? strategy = null,
IProgress<UpdateProgress>? progress = null,
CancellationToken cancellationToken = default)
Comment on lines 488 to 493
/// <summary>
/// Raised when the entire update process completes.
/// </summary>
public event Action<UpdateResult>? OnUpdateCompleted;

/// <summary>
/// Raised to report progress (percentage, message).
/// </summary>
public event Action<int, string>? OnProgress;

// ─── Helpers ───────────────────────────────────────────────────────
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.

Fix code review findings: retry semantics, rollback token, batch progress, and clean up

2 participants