Skip to content

Refactor batchTimer to use CompositeDisposable instead of manual finally block disposal#272

Merged
HowardvanRooijen merged 2 commits intofeature/dotnet-10-updatefrom
copilot/sub-pr-267-one-more-time
Nov 29, 2025
Merged

Refactor batchTimer to use CompositeDisposable instead of manual finally block disposal#272
HowardvanRooijen merged 2 commits intofeature/dotnet-10-updatefrom
copilot/sub-pr-267-one-more-time

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 29, 2025

Addresses review feedback about manual disposal in finally blocks - batchTimer should use proper C# resource management patterns.

Changes

  • Removed nullable Timer? batchTimer = null; declaration at method scope
  • Added Timer to CompositeDisposable subscriptions collection for automatic cleanup via using statement
  • Removed manual batchTimer?.Dispose(); from finally block
// Before: Manual disposal in finally block
Timer? batchTimer = null;
// ...
batchTimer = new Timer(...);
// ...
finally
{
    batchTimer?.Dispose();
}

// After: Managed by CompositeDisposable with using statement
using CompositeDisposable subscriptions = [];
// ...
Timer batchTimer = new(...);
subscriptions.Add(batchTimer);

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Nov 29, 2025
…lly block disposal

Co-authored-by: HowardvanRooijen <128664+HowardvanRooijen@users.noreply.github.com>
Copilot AI changed the title [WIP] Create stacked PR to address review feedback on .NET 10 Refactor batchTimer to use CompositeDisposable instead of manual finally block disposal Nov 29, 2025
@HowardvanRooijen HowardvanRooijen marked this pull request as ready for review November 29, 2025 10:50
Copilot AI review requested due to automatic review settings November 29, 2025 10:50
@HowardvanRooijen HowardvanRooijen merged commit b15a402 into feature/dotnet-10-update Nov 29, 2025
1 check passed
@HowardvanRooijen HowardvanRooijen deleted the copilot/sub-pr-267-one-more-time branch November 29, 2025 10:50
Copy link
Copy Markdown

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 PR refactors resource management in ReceiveCommand.cs by moving batchTimer disposal from a manual finally block pattern to the CompositeDisposable pattern using a using statement for automatic cleanup.

Key Changes

  • Removed nullable Timer? batchTimer declaration at method scope and converted it to a local variable scoped within the storage configuration block
  • Added batchTimer to the existing CompositeDisposable subscriptions collection for automatic disposal
  • Removed manual batchTimer?.Dispose() call from the finally block

Reviewed changes

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

File Description
Solutions/Ais.Net.Receiver.Host.Console/Ais/Net/Receiver/Host/Console/Commands/ReceiveCommand.cs Refactored batchTimer to use CompositeDisposable for automatic resource management instead of manual disposal in finally block
Solutions/Ais.Net.Receiver.Host.Console/packages.lock.json Removed Roslynator.Analyzers and StyleCop.Analyzers entries - appears unintentional and requires dotnet restore to regenerate
Comments suppressed due to low confidence (1)

Solutions/Ais.Net.Receiver.Host.Console/packages.lock.json:158

  • The removal of Roslynator.Analyzers and StyleCop.Analyzers from packages.lock.json appears unintentional. The .csproj file at line 67 still contains <PackageReference Update="Roslynator.Analyzers" Version="4.14.1" />, but the analyzer is no longer present in the lock file. This suggests that dotnet restore needs to be run to properly regenerate the packages.lock.json file with the updated analyzer versions.

Consider running dotnet restore to ensure the lock file is properly synchronized with the project file dependencies.

      "Spectre.Console": {
        "type": "Direct",
        "requested": "[0.54.0, )",
        "resolved": "0.54.0",
        "contentHash": "StDXCFayfy0yB1xzUHT2tgEpV1/HFTiS4JgsAQS49EYTfMixSwwucaQs/bIOCwXjWwIQTMuxjUIxcB5XsJkFJA=="
      },

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

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.

3 participants