Skip to content

DOCSP-45715: Sealed class v3.0 changes #345

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 5 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/fundamentals/serialization.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ The following code example shows a custom ``BsonRegularExpression`` serializer:

.. code-block:: csharp

class CustomRegularExpressionSerializer : SerializerBase<Regex>
class CustomRegularExpressionSerializer : IBsonSerializer<Regex>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't compile, so need to adapt the CustomRegularExpressionSerializer accordingly.

{
public override Regex Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
{
Expand Down
9 changes: 8 additions & 1 deletion source/upgrade/v3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,11 @@ Version 3.0 Breaking Changes
property instead.

- The driver removes individual cluster events from ``MongoClient.Cluster``. To listen for
cluster events, use `ClusterBuilder.Subscribe() <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Core.Configuration.ClusterBuilder.Subscribe.html>`__.
cluster events, use `ClusterBuilder.Subscribe() <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Core.Configuration.ClusterBuilder.Subscribe.html>`__.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We had some questions of "why" classes got sealed.
It's worth adding a general comment followed by these concrete examples:
Something like "Some of the types that were not designed for extension via inheritance became sealed. Starting with 3.0 we recommend using "composition over inheritance" approach for extending the driver functionality."

- The driver seals all concrete serializers. To implement a custom serializer, implement the
``IBsonSerializer`` interface.

- The driver seals the ``MongoClient``, ``MongoDatabase``, and ``MongoCollection`` classes.
We recommend using the ``IMongoClient``, ``IMongoDatabase``, and ``IMongoCollection``
interfaces directly.
Loading