@@ -25,7 +25,7 @@ namespace MongoDB.Bson
2525 /// </summary>
2626 public static class BsonExtensionMethods
2727 {
28- //DOMAIN-API We should remove this and use the version with the domain.
28+ //DOMAIN-API We should remove all the methods that do not take a serialization domain.
2929 //QUESTION: Do we want to do something now about this...? It's used also internally, but it seems in most cases it's used for "default serialization", so it should be ok.
3030 /// <summary>
3131 /// Serializes an object to a BSON byte array.
@@ -43,29 +43,23 @@ public static byte[] ToBson<TNominalType>(
4343 IBsonSerializer < TNominalType > serializer = null ,
4444 BsonBinaryWriterSettings writerSettings = null ,
4545 Action < BsonSerializationContext . Builder > configurator = null ,
46- BsonSerializationArgs args = default ( BsonSerializationArgs ) ,
47- int estimatedBsonSize = 0 )
48- {
49- args . SetOrValidateNominalType ( typeof ( TNominalType ) , "<TNominalType>" ) ;
50-
51- return ToBson ( obj , typeof ( TNominalType ) , writerSettings , serializer , configurator , args , estimatedBsonSize ) ;
52- }
46+ BsonSerializationArgs args = default ,
47+ int estimatedBsonSize = 0 ) => ToBson ( obj , BsonSerializer . DefaultSerializationDomain , serializer , writerSettings , configurator , args , estimatedBsonSize ) ;
5348
54- internal static byte [ ] ToBson < TNominalType > (
49+ private static byte [ ] ToBson < TNominalType > (
5550 this TNominalType obj ,
5651 IBsonSerializationDomain serializationDomain ,
5752 IBsonSerializer < TNominalType > serializer = null ,
5853 BsonBinaryWriterSettings writerSettings = null ,
5954 Action < BsonSerializationContext . Builder > configurator = null ,
60- BsonSerializationArgs args = default ( BsonSerializationArgs ) ,
55+ BsonSerializationArgs args = default ,
6156 int estimatedBsonSize = 0 )
6257 {
6358 args . SetOrValidateNominalType ( typeof ( TNominalType ) , "<TNominalType>" ) ;
6459
6560 return ToBson ( obj , typeof ( TNominalType ) , serializationDomain , writerSettings , serializer , configurator , args , estimatedBsonSize ) ;
6661 }
6762
68- //DOMAIN-API We should remove this and use the version with the domain.
6963 /// <summary>
7064 /// Serializes an object to a BSON byte array.
7165 /// </summary>
@@ -89,14 +83,14 @@ public static byte[] ToBson(
8983 int estimatedBsonSize = 0 ) => ToBson ( obj , nominalType , BsonSerializer . DefaultSerializationDomain , writerSettings ,
9084 serializer , configurator , args , estimatedBsonSize ) ;
9185
92- internal static byte [ ] ToBson (
86+ private static byte [ ] ToBson (
9387 this object obj ,
9488 Type nominalType ,
9589 IBsonSerializationDomain serializationDomain ,
9690 BsonBinaryWriterSettings writerSettings = null ,
9791 IBsonSerializer serializer = null ,
9892 Action < BsonSerializationContext . Builder > configurator = null ,
99- BsonSerializationArgs args = default ( BsonSerializationArgs ) ,
93+ BsonSerializationArgs args = default ,
10094 int estimatedBsonSize = 0 )
10195 {
10296 if ( estimatedBsonSize < 0 )
@@ -144,7 +138,7 @@ public static BsonDocument ToBsonDocument<TNominalType>(
144138 this TNominalType obj ,
145139 IBsonSerializer < TNominalType > serializer = null ,
146140 Action < BsonSerializationContext . Builder > configurator = null ,
147- BsonSerializationArgs args = default ( BsonSerializationArgs ) )
141+ BsonSerializationArgs args = default )
148142 {
149143 args . SetOrValidateNominalType ( typeof ( TNominalType ) , "<TNominalType>" ) ;
150144 return ToBsonDocument ( obj , typeof ( TNominalType ) , serializer , configurator , args ) ;
@@ -169,7 +163,7 @@ public static BsonDocument ToBsonDocument(
169163 BsonSerializationArgs args = default ) => ToBsonDocument ( obj , nominalType ,
170164 BsonSerializer . DefaultSerializationDomain , serializer , configurator , args ) ;
171165
172- internal static BsonDocument ToBsonDocument (
166+ private static BsonDocument ToBsonDocument (
173167 this object obj ,
174168 Type nominalType ,
175169 IBsonSerializationDomain serializationDomain ,
@@ -237,7 +231,7 @@ public static string ToJson<TNominalType>(
237231 JsonWriterSettings writerSettings = null ,
238232 IBsonSerializer < TNominalType > serializer = null ,
239233 Action < BsonSerializationContext . Builder > configurator = null ,
240- BsonSerializationArgs args = default ( BsonSerializationArgs ) )
234+ BsonSerializationArgs args = default )
241235 {
242236 args . SetOrValidateNominalType ( typeof ( TNominalType ) , "<TNominalType>" ) ;
243237 return ToJson ( obj , typeof ( TNominalType ) , writerSettings , serializer , configurator , args ) ;
@@ -266,14 +260,14 @@ public static string ToJson(
266260 BsonSerializationArgs args = default )
267261 => ToJson ( obj , nominalType , BsonSerializer . DefaultSerializationDomain , writerSettings , serializer , configurator , args ) ;
268262
269- internal static string ToJson (
263+ private static string ToJson (
270264 this object obj ,
271265 Type nominalType ,
272266 IBsonSerializationDomain domain ,
273267 JsonWriterSettings writerSettings = null ,
274268 IBsonSerializer serializer = null ,
275269 Action < BsonSerializationContext . Builder > configurator = null ,
276- BsonSerializationArgs args = default ( BsonSerializationArgs ) )
270+ BsonSerializationArgs args = default )
277271 {
278272 if ( nominalType == null )
279273 {
0 commit comments