Refactor batchTimer to use CompositeDisposable instead of manual finally block disposal#272
Merged
HowardvanRooijen merged 2 commits intofeature/dotnet-10-updatefrom Nov 29, 2025
Conversation
…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
approved these changes
Nov 29, 2025
There was a problem hiding this comment.
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? batchTimerdeclaration at method scope and converted it to a local variable scoped within the storage configuration block - Added
batchTimerto the existingCompositeDisposablesubscriptions 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.AnalyzersandStyleCop.Analyzersfrom 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 thatdotnet restoreneeds 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.
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.
Addresses review feedback about manual disposal in finally blocks -
batchTimershould use proper C# resource management patterns.Changes
Timer? batchTimer = null;declaration at method scopeCompositeDisposablesubscriptions collection for automatic cleanup viausingstatementbatchTimer?.Dispose();from finally block✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.