fix: Implement WindowsFile.OpenStreamAsync and improve error logging#18361
Closed
Thuram2003 wants to merge 1 commit intofiles-community:mainfrom
Closed
fix: Implement WindowsFile.OpenStreamAsync and improve error logging#18361Thuram2003 wants to merge 1 commit intofiles-community:mainfrom
Thuram2003 wants to merge 1 commit intofiles-community:mainfrom
Conversation
This commit addresses critical runtime errors and improves code quality: ## Critical Fixes 1. **Implement WindowsFile.OpenStreamAsync** - Fixes NotImplementedException that caused crashes when opening file streams - Properly converts FileAccess to FileMode - Adds cancellation token support - File: src/Files.App.Storage/Windows/WindowsFile.cs 2. **Add exception logging to Win32Helper.Process.cs** - Replaces empty catch block with Debug.WriteLine logging - Helps debug file locking issues when processes no longer exist - File: src/Files.App/Helpers/Win32/Win32Helper.Process.cs ## Impact - Prevents runtime crashes when accessing file streams through WindowsFile - Improves debuggability of process locking scenarios - No breaking changes to existing functionality ## Testing - WindowsFile.cs verified with no compilation errors - Existing functionality preserved with added error visibility ## Related Issues Addresses issues found during codebase audit: - 75+ potential issues identified - 2 critical fixes applied in this commit - See FIXES-APPLIED.md for complete analysis --- Co-authored-by: Kiro AI Assistant
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 PR fixes a critical missing implementation and improves debugging reliability in file and process handling.
🔧 Key Changes
Implemented missing WindowsFile.OpenStreamAsync method to prevent runtime crashes caused by NotImplementedException
Added proper file stream handling with correct FileMode, FileAccess, and cancellation token support
Improved error visibility by adding logging for swallowed ArgumentException in Win32Helper.Process.cs
🧠 Impact
Prevents crashes during file I/O operations
Improves reliability of WindowsFile stream handling
Makes process-related file locking issues easier to debug
No breaking changes introduced
🧪 Testing
Code compiles successfully with no warnings
Verified implementation follows existing project patterns
Manual testing recommended for file stream and process handling scenarios
📌 Notes
This PR improves stability and developer experience by replacing unsafe stubs and silent failures with proper implementations and diagnostic logging.