[CSHARP-1809] Consider allowing to implement the GridFSUploadStream[<>] and GridFSDownloadStream[<>] Created: 25/Oct/16  Updated: 27/Jan/22  Resolved: 27/Jan/22

Status: Closed
Project: C# Driver
Component/s: API, GridFS
Affects Version/s: 2.3
Fix Version/s: 2.15.0

Type: Improvement Priority: Major - P3
Reporter: Aristarkh Zagorodnikov Assignee: James Kovacs
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by CSHARP-1878 Make GridFSDownloadStream and GridFSU... Closed
Backwards Compatibility: Fully Compatible

 Description   

Currently, the IGridFSBucket[<>] interfaces expose methods that return instances of the GridFSUploadStream[<>] and GridFSDownloadStream[<>] abstract classes. Unfortunately, their constructors are internal, so decoration of IGridFSBucket[<>] that requires decoration of returned streams is impossible, because one cannot inherit from a class with an internal constructor. This is disappointing, especially given that other interfaces (collection, database, client, etc.) are very much decoratable and look carefully desigined. While I understand that there might be compelling reasons for this, that are unknown to me, I ask you to consider removing the internal constructor to allow inheritance and, hence, decoration of the GridFS-related interfaces, especially since this does not look like a breaking change.



 Comments   
Comment by James Kovacs [ 27/Jan/22 ]

Please note that we do not recommend or encourage mocking third-party dependencies such as the driver. Much has been written on the subject by TDD/BDD practitioners over the years and why it is considered an anti-pattern. If you feel the need to mock a third-party dependency, it is often better to wrap it in an adapter allowing you to mock the adapter (which you do own) and integration test the adapter with the actual dependency.

Comment by Githook User [ 27/Jan/22 ]

Author:

{'name': 'Brian Pickens', 'email': '3659859+brian-pickens@users.noreply.github.com', 'username': 'brian-pickens'}

Message: CSHARP-1809: Allow GridFSUploadStream to be mockable
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/292a56c1f9eebd816a68ac9983d7ef3d94853493

Comment by Githook User [ 27/Jan/22 ]

Author:

{'name': 'Brian Pickens', 'email': '3659859+brian-pickens@users.noreply.github.com', 'username': 'brian-pickens'}

Message: CSHARP-1809: Enable GridGFDownloadStream to be mockable
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/446c29e0d13d6eaf6c71688f43a29bbc3369f266

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