Skip to content

DOCSP-49876: Add IBsonReader and IBsonWriter info #641

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

Merged
merged 8 commits into from
May 30, 2025

Conversation

mcmorisi
Copy link
Collaborator

@mcmorisi mcmorisi commented May 28, 2025

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-49876

Staging Links

  • data-formats/bson
  • Self-Review Checklist

    • Is this free of any warnings or errors in the RST?
    • Did you run a spell-check?
    • Did you run a grammar-check?
    • Are all the links working?
    • Are the facets and meta keywords accurate?

    Copy link

    netlify bot commented May 28, 2025

    Deploy Preview for docs-csharp ready!

    Name Link
    🔨 Latest commit 3302d29
    🔍 Latest deploy log https://app.netlify.com/projects/docs-csharp/deploys/6839ef674f27d800086300e3
    😎 Deploy Preview https://deploy-preview-641--docs-csharp.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify project configuration.

    Copy link
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    do you know what this file is?

    Copy link
    Collaborator Author

    @mcmorisi mcmorisi May 28, 2025

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Hm, strange – I think I created that file when I was thinking of taking the ConnectionString task that you ended up grabbing.

    Copy link
    Collaborator

    @mongoKart mongoKart left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    looks great w/ 1 question

    @mcmorisi mcmorisi requested a review from rstam May 28, 2025 19:13
    @@ -212,6 +216,41 @@ BSON document stored in ``myFile.bson``:
    ``System.IO.Stream`` object. This means that you can read or write any location
    that can be accessed by a stream.

    Implement a Custom BSON Reader and Writer
    Copy link
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    I don't think any user would (or should) ever want to implement a custom IBsonReader or IBsonWriter.

    If we want to document anything at all about these interfaces it should be:

    1. That IBsonReader/IBsonWriter interfaces can be used to read "documents" represented in several formats
    2. The we have readers and writers for 3 formats: BSON, JSON and in-memory BsonDocument

    The three sets of standard readers and writers are:

    1. BsonBinaryReader and BsonBinaryWriter
    2. JsonReader and JsonWriter
    3. BsonDocumentReader and BsonDocumentWriter

    They all implement the same interfaces.

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Will take another crack at this section!

    ``BsonBinaryReader`` and ``BsonBinaryWriter`` classes. However, you can also implement a
    custom reader and writer by implementing the
    ``IBsonReader`` and ``IBsonWriter`` interfaces. This is useful when you want to define
    a custom serializer or if you want to directly read or write BSON or JSON data without
    Copy link
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    While writing a custom serializer is an expected (if rare) thing for a user to do, there is no need for custom readers and writers.

    Custom serializers use the standard reader and writer interfaces to Deserialize and Serialize values.

    @mcmorisi mcmorisi requested a review from rstam May 29, 2025 18:51
    Copy link
    Collaborator

    @rstam rstam left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    LGTM

    @mcmorisi mcmorisi requested a review from mongoKart May 30, 2025 17:44
    Copy link
    Collaborator

    @mongoKart mongoKart left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    LGTM + 1 change

    Comment on lines 228 to 230
    - ``JsonReader`` and ``JsonWriter``: Read and write JSON data.
    - ``BsonDocumentReader`` and ``BsonDocumentWriter``: Read and write BSON data
    contained in a ``BsonDocument`` object.
    Copy link
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggested change
    - ``JsonReader`` and ``JsonWriter``: Read and write JSON data.
    - ``BsonDocumentReader`` and ``BsonDocumentWriter``: Read and write BSON data
    contained in a ``BsonDocument`` object.
    - ``JsonReader`` and ``JsonWriter``: Read and write JSON data
    - ``BsonDocumentReader`` and ``BsonDocumentWriter``: Read and write BSON data
    contained in a ``BsonDocument`` object

    @mcmorisi mcmorisi merged commit 4e6c7ba into mongodb:docsp-45382-comp-cvg May 30, 2025
    4 of 5 checks passed
    @mcmorisi mcmorisi deleted the DOCSP-49876-bson-fix branch May 30, 2025 17:49
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    3 participants