-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Enforce Async-only methods in StreamConformanceTests #121842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Tagging subscribers to this area: @dotnet/area-meta |
There was a problem hiding this 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 enforces async-only methods in StreamConformanceTests to ensure that async operations in wrapper streams (SslStream, compression streams, crypto streams) don't perform blocking IO calls. The changes introduce an AsyncOnlyStream wrapper that throws when synchronous methods are called, and update tests to use async operations when testing async code paths.
Key changes:
- Introduced
AsyncOnlyStreamwrapper to enforce async-only operations during testing - Updated test methods to use async disposal patterns and wrap streams appropriately based on async mode
- Converted synchronous IO operations to async in SslStream tests to avoid blocking
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamConformanceTests.cs | Converted sync Read/Write calls to async ReadAsync/WriteAsync to avoid blocking during TLS 1.3 handshake flush |
| src/libraries/Common/tests/StreamConformanceTests/System/IO/StreamConformanceTests.cs | Added AsyncOnlyStream wrapper class, CreateWrappedStreamsAsync helper, IsAsync helper, updated test disposal patterns to use async, and added IAsyncDisposable to StreamPair |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
src/libraries/Common/tests/StreamConformanceTests/System/IO/StreamConformanceTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/tests/StreamConformanceTests/System/IO/StreamConformanceTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/tests/StreamConformanceTests/System/IO/StreamConformanceTests.cs
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
For stream which wrap another stream (SslStream, compression streams, crypto streams, ....), we can test if async methods are calling only async methods. This should root out cases where we may be mistakenly doing blocking IO calls as part of async stack.