Skip to content

CSHARP-6133: Validate cursor argument in IAsyncCursor/IAsyncCursorSource Extensions terminal operators - #2097

Open
adelinowona wants to merge 1 commit into
mongodb:mainfrom
adelinowona:csharp6133
Open

CSHARP-6133: Validate cursor argument in IAsyncCursor/IAsyncCursorSource Extensions terminal operators#2097
adelinowona wants to merge 1 commit into
mongodb:mainfrom
adelinowona:csharp6133

Conversation

@adelinowona

Copy link
Copy Markdown
Contributor

No description provided.

@adelinowona
adelinowona requested a review from a team as a code owner August 11, 2026 15:03
@adelinowona
adelinowona requested review from ajcvickers and a lite review from Copilot August 11, 2026 15:03
@adelinowona adelinowona added the maintenance Non-code maintenance (deps, docs, configs, etc.). label Aug 11, 2026
@adelinowona
adelinowona requested review from BorisDog and sanych-sun and removed request for ajcvickers August 11, 2026 15:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 to IAsyncCursorSourceExtensions terminal operators and ForEachAsync overloads so null source/processor is rejected early.
  • Added Ensure.IsNotNull(...) checks to IAsyncCursorExtensions terminal operators, and adjusted ForEachAsync to preserve async-dispose behavior even when processor is null.
  • Added/expanded unit tests covering null argument behavior for cursor/cursor-source terminal operators and ForEachAsync overload 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Non-code maintenance (deps, docs, configs, etc.).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants