-
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
57
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
57 commits
Select commit
Hold shift + click to select a range
217c292
Rebase commit
papafe 65cddb7
Corrected type
papafe fafcafa
Various improvements, and added test for discriminators.
papafe e2f6dda
Removed comment.
papafe 1ad919f
Small corrections.
papafe cb812a2
Small correction.
papafe e35467c
Corrected test
papafe 0f2d592
Correction for test
papafe ae07d28
Correction
papafe fb36fbb
Removed new tests untul refactoring
papafe d8a65b1
Added domain to MongoQueryProvider
papafe b014fda
Small fix
papafe 8acb837
Corrected freeze
papafe 08365aa
Small correction
papafe f1e2a32
Fixed BsonClassMap.Freeze and Convention Apply
papafe 753468e
Small fix.
papafe d7c7841
Corrected test
papafe 42528ce
Made conventions internal
papafe d08f243
Corrected accessibility
papafe 63a8af3
Fixed discriminator method
papafe e1703dc
Simplified
papafe 0c65ea1
Hide IBsonReader settings
papafe ef75731
Other improvements
papafe 29dd24b
Added constructor to avoid api compat issue
papafe 3eb7b41
Correct
papafe d15e736
Small fixes
papafe 4e3c66b
Various fixes
papafe 81f73e6
Added BsonDefaults to domain
papafe 798f53c
Various fixes to hide API
papafe 40ca99d
Small things
papafe 4fb39ce
Builders example
papafe c9c1282
Removed references to certain parts of BsonDefaults.
papafe 73e5b98
Various fixes
papafe 13c322b
Moved to internal 1
papafe a7942fd
More internal
papafe 77163d7
Removed final internal
papafe 17031c1
Improvements
papafe 7634e48
Small comments
papafe bffe921
Some comments
papafe 87bf081
Added getDiscriminatorInternal
papafe f2d6e4c
Merged IBsonSerializationDomainInternal into IBsonSerializationDomain…
papafe 6caf45e
Missing piece.
papafe 08a7537
Fix for getDicriminatorConvention and IBsonIdProvider
papafe e793b66
Big serializer check
papafe 67495b3
Fix for testing
papafe 74136c0
Added comment
papafe a59ad0f
Small fix
papafe 0ba1861
Various fixes about RenderArgs plus new tests
papafe 5ea195a
Small fix
papafe 823b2ad
Simplified tests
papafe acb03b9
Small fixes
papafe c41c30c
Removed example builder and tests
papafe 01df61f
Various test fixes
papafe 3bbe170
Various improvements
papafe bcc84b6
Added copyright
papafe d1905f3
Fixed registry
papafe 18e98e6
Removed unused
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.