CSHARP-6133: Validate cursor argument in IAsyncCursor/IAsyncCursorSource Extensions terminal operators - #2097
Open
adelinowona wants to merge 1 commit into
Open
CSHARP-6133: Validate cursor argument in IAsyncCursor/IAsyncCursorSource Extensions terminal operators#2097adelinowona wants to merge 1 commit into
adelinowona wants to merge 1 commit into
Conversation
…rce Extensions terminal operators
adelinowona
requested review from
BorisDog and
sanych-sun
and removed request for
ajcvickers
August 11, 2026 15:04
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens argument validation for IAsyncCursor and IAsyncCursorSource extension “terminal operators” (and related ForEachAsync overloads), ensuring ArgumentNullException is thrown with consistent parameter names and that invalid inputs don’t trigger unnecessary work.
Changes:
- Added
Ensure.IsNotNull(...)checks toIAsyncCursorSourceExtensionsterminal operators andForEachAsyncoverloads so nullsource/processoris rejected early. - Added
Ensure.IsNotNull(...)checks toIAsyncCursorExtensionsterminal operators, and adjustedForEachAsyncto preserve async-dispose behavior even whenprocessoris null. - Added/expanded unit tests covering null argument behavior for cursor/cursor-source terminal operators and
ForEachAsyncoverload variants.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/MongoDB.Driver.Tests/Core/IAsyncCursorSourceExtensionsTests.cs | Adds coverage asserting null source/processor behavior and ensuring queries aren’t executed when processor is null. |
| tests/MongoDB.Driver.Tests/Core/IAsyncCursorExtensionsTests.cs | Adds coverage asserting null cursor behavior and verifies disposal behavior when processor is null. |
| src/MongoDB.Driver/Core/IAsyncCursorSource.cs | Introduces explicit null checks for cursor-source terminal operators and ForEachAsync overloads. |
| src/MongoDB.Driver/Core/IAsyncCursor.cs | Introduces explicit null checks for cursor terminal operators and refines ForEachAsync null-processor handling to preserve disposal semantics. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
No description provided.