-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CSHARP-3985: Support multiple SerializerRegistries #1592
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
Open
papafe
wants to merge
53
commits into
mongodb:main
Choose a base branch
from
papafe:csharp3985
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
3c99f6d
Rebase commit
papafe d087b6c
Corrected type
papafe 975545a
Various improvements, and added test for discriminators.
papafe ecd84a8
Removed comment.
papafe a4d92cc
Small corrections.
papafe 7280ac5
Small correction.
papafe 27ccb7b
Corrected test
papafe e589695
Correction for test
papafe 5efa4da
Correction
papafe 962861f
Removed new tests untul refactoring
papafe 0b92d63
Added domain to MongoQueryProvider
papafe 6d5fb86
Small fix
papafe d1585d1
Corrected freeze
papafe 5e6931c
Small correction
papafe e6b8b35
Fixed BsonClassMap.Freeze and Convention Apply
papafe 818dc7e
Small fix.
papafe 543c396
Corrected test
papafe f07be62
Made conventions internal
papafe f845894
Corrected accessibility
papafe a3afabb
Fixed discriminator method
papafe 1791906
Simplified
papafe 3a2b361
Hide IBsonReader settings
papafe fe78c71
Other improvements
papafe 63a8b64
Added constructor to avoid api compat issue
papafe a641602
Correct
papafe ef7a962
Small fixes
papafe b489c38
Various fixes
papafe cacf077
Added BsonDefaults to domain
papafe 6ccc864
Various fixes to hide API
papafe 4a5220a
Small things
papafe 697784b
Builders example
papafe 97fd948
Removed references to certain parts of BsonDefaults.
papafe ecf6f92
Various fixes
papafe 7271903
Moved to internal 1
papafe e513938
More internal
papafe 4c5bdcc
Removed final internal
papafe 714c419
Improvements
papafe c796201
Small comments
papafe 0f7cc7b
Some comments
papafe c56f972
Added getDiscriminatorInternal
papafe 83ad951
Merged IBsonSerializationDomainInternal into IBsonSerializationDomain…
papafe 34dce8a
Missing piece.
papafe 7311b35
Fix for getDicriminatorConvention and IBsonIdProvider
papafe e9511c0
Big serializer check
papafe a783914
Fix for testing
papafe 4c7d7ac
Added comment
papafe ee4410a
Small fix
papafe a31265a
Various fixes about RenderArgs plus new tests
papafe ef6d8bd
Small fix
papafe e7a703e
Simplified tests
papafe b86494b
Small fixes
papafe d32b3ac
Removed example builder and tests
papafe 61ec09c
Various test fixes
papafe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* Copyright 2010-present MongoDB Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System.Collections.Generic; | ||
using System.Dynamic; | ||
using MongoDB.Bson.Serialization; | ||
|
||
namespace MongoDB.Bson | ||
{ | ||
internal class BsonDefaultsDomain : IBsonDefaults | ||
{ | ||
private IBsonSerializationDomain _serializationDomain; | ||
private bool _dynamicArraySerializerWasSet; | ||
private IBsonSerializer _dynamicArraySerializer; | ||
private bool _dynamicDocumentSerializerWasSet; | ||
private IBsonSerializer _dynamicDocumentSerializer; | ||
|
||
public BsonDefaultsDomain(IBsonSerializationDomain serializationDomain) | ||
{ | ||
_serializationDomain = serializationDomain; | ||
} | ||
|
||
public IBsonSerializer DynamicArraySerializer | ||
{ | ||
get | ||
{ | ||
if (!_dynamicArraySerializerWasSet) | ||
{ | ||
_dynamicArraySerializer = _serializationDomain.LookupSerializer<List<object>>(); | ||
} | ||
return _dynamicArraySerializer; | ||
} | ||
set | ||
{ | ||
_dynamicArraySerializerWasSet = true; | ||
_dynamicArraySerializer = value; | ||
} | ||
} | ||
|
||
public IBsonSerializer DynamicDocumentSerializer | ||
{ | ||
get | ||
{ | ||
if (!_dynamicDocumentSerializerWasSet) | ||
{ | ||
_dynamicDocumentSerializer = _serializationDomain.LookupSerializer<ExpandoObject>(); | ||
} | ||
return _dynamicDocumentSerializer; | ||
} | ||
set | ||
{ | ||
_dynamicDocumentSerializerWasSet = true; | ||
_dynamicDocumentSerializer = value; | ||
} | ||
} | ||
|
||
public int MaxDocumentSize { get; set; } = int.MaxValue; | ||
|
||
public int MaxSerializationDepth { get; set; } = 100; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* Copyright 2010-present MongoDB Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using MongoDB.Bson.Serialization; | ||
|
||
namespace MongoDB.Bson | ||
{ | ||
internal interface IBsonDefaults | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
IBsonSerializer DynamicArraySerializer { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
IBsonSerializer DynamicDocumentSerializer { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
int MaxDocumentSize { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
int MaxSerializationDepth { get; set; } | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
*/ | ||
|
||
using System; | ||
using MongoDB.Bson.Serialization; | ||
|
||
namespace MongoDB.Bson.IO | ||
{ | ||
|
@@ -24,6 +25,7 @@ public abstract class BsonReaderSettings | |
{ | ||
// private fields | ||
private bool _isFrozen; | ||
private IBsonSerializationDomain _serializationDomain; | ||
|
||
// constructors | ||
/// <summary> | ||
|
@@ -77,6 +79,16 @@ public BsonReaderSettings FrozenCopy() | |
} | ||
} | ||
|
||
internal IBsonSerializationDomain SerializationDomain | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be a reader setting. Classes in this directory are low level I/O classes that just do I/O. Serialization is one level up and is built on TOP of these I/O classes. |
||
{ | ||
get => _serializationDomain; | ||
set | ||
{ | ||
if (_isFrozen) { ThrowFrozenException(); } | ||
_serializationDomain = value; | ||
} | ||
} | ||
|
||
// protected methods | ||
/// <summary> | ||
/// Creates a clone of the settings. | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IBsonReaderInternal not needed.