Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the SvcCommIo helper class to use RAII patterns, significantly simplifying the code and improving maintainability. The changes replace a monolithic implementation with well-structured RAII wrapper classes (ConsoleInput and ConsoleOutput) that automatically manage console state restoration.
Key changes:
- Introduced ConsoleInput and ConsoleOutput RAII wrapper classes with factory methods
- Eliminated manual cleanup code by leveraging RAII destructors
- Reduced code length and complexity through better separation of concerns
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/windows/common/svccommio.hpp | Adds ConsoleInput and ConsoleOutput RAII wrapper class declarations; updates SvcCommIo to use these wrappers instead of manual state tracking |
| src/windows/common/svccommio.cpp | Implements RAII wrappers with factory methods; refactors SvcCommIo constructor to use the new wrappers; removes manual cleanup code replaced by RAII destructors |
OneBlue
reviewed
Dec 10, 2025
9a845e8 to
fb985df
Compare
OneBlue
reviewed
Dec 18, 2025
OneBlue
approved these changes
Dec 19, 2025
|
H |
OneBlue
reviewed
Jan 6, 2026
src/windows/common/svccommio.cpp
Outdated
| } | ||
|
|
||
| wsl::windows::common::SvcCommIo::~SvcCommIo() | ||
| ConsoleOutput::ConsoleOutput(wil::unique_hfile ConsoleHandle, DWORD SavedMode) : |
Collaborator
There was a problem hiding this comment.
I'm surprised that this works since unique_hfile isn't copyable. (I'd expect something like wil::unique_hfile&& ConsoleHandle) here
OneBlue
approved these changes
Jan 14, 2026
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.
This helper class has always been a bit of a mess, this change reimplements the class using RAII classes and reduces complexity and code length.