[CSHARP-4012] Remove checks for session been passed as null Created: 11/Jan/22  Updated: 27/Oct/23  Resolved: 20/Jan/22

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Unknown
Reporter: Jason Singleton Assignee: Dmitry Lukyanov (Inactive)
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Currently most calls that take a session validate its been passed though and don't accept null.

This seems redundant on the session parameter. As on a users side we have to check if we have a session or not and call with different arguments when internally you accept null anyway.

For an example the Find extensions methods require IClientSession but internally it just makes an instance of FindFluent which doesn't have the same restriction. 

So we can actually just make an instance of this and bypass the extension but shouldn't the extension methods have the same restrictions?

 



 Comments   
Comment by Dmitry Lukyanov (Inactive) [ 20/Jan/22 ]

Hello j.singleton7887@gmail.com ,

The API was deliberately designed to validate that the application does not pass a null session by mistake.
A session is mandatory. The overloads that don't take a session are maintained for backward compatibility and create an implied session before calling the overload that does take a session.
We think passing null to the overloads that take a session should not be supported.

Comment by Boris Dogadov [ 14/Jan/22 ]

Thank you j.singleton7887@gmail.com for your suggestion. We will look into this, and will update this ticket with our findings.

Generated at Wed Feb 07 21:46:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.