Skip to content

Commit 8b14426

Browse files
committed
Added comments
1 parent d2e1746 commit 8b14426

26 files changed

+46
-37
lines changed

src/MongoDB.Bson/BsonDefaults.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ public static class BsonDefaults
3434

3535
// public static properties
3636
/// <summary>
37-
/// Gets or sets the dynamic array serializer. //TODO What to we do with this?
37+
/// Gets or sets the dynamic array serializer.
3838
/// </summary>
3939
public static IBsonSerializer DynamicArraySerializer
4040
{
4141
get
4242
{
4343
if (!__dynamicArraySerializerWasSet)
4444
{
45-
__dynamicArraySerializer = BsonSerializer.LookupSerializer<List<object>>();
45+
__dynamicArraySerializer = BsonSerializer.LookupSerializer<List<object>>(); //TODO I think we could keep this as is
4646
}
4747
return __dynamicArraySerializer;
4848
}
@@ -62,7 +62,7 @@ public static IBsonSerializer DynamicDocumentSerializer
6262
{
6363
if (!__dynamicDocumentSerializerWasSet)
6464
{
65-
__dynamicDocumentSerializer = BsonSerializer.LookupSerializer<ExpandoObject>();
65+
__dynamicDocumentSerializer = BsonSerializer.LookupSerializer<ExpandoObject>(); //TODO I think we could keep this as is
6666
}
6767
return __dynamicDocumentSerializer;
6868
}

src/MongoDB.Bson/BsonExtensionMethods.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static byte[] ToBson(
8484

8585
if (serializer == null)
8686
{
87-
serializer = BsonSerializer.LookupSerializer(nominalType);
87+
serializer = BsonSerializer.LookupSerializer(nominalType); //TODO I think we need another method with the domain as input
8888
}
8989
if (serializer.ValueType != nominalType)
9090
{
@@ -165,7 +165,7 @@ public static BsonDocument ToBsonDocument(
165165
return convertibleToBsonDocument.ToBsonDocument(); // use the provided ToBsonDocument method
166166
}
167167

168-
serializer = BsonSerializer.LookupSerializer(nominalType);
168+
serializer = BsonSerializer.LookupSerializer(nominalType); //TODO I think we need another method with the domain as input
169169
}
170170
if (serializer.ValueType != nominalType)
171171
{
@@ -236,7 +236,7 @@ public static string ToJson(
236236

237237
if (serializer == null)
238238
{
239-
serializer = BsonSerializer.LookupSerializer(nominalType);
239+
serializer = BsonSerializer.LookupSerializer(nominalType); //TODO I think we need another method with the domain as input
240240
}
241241
if (serializer.ValueType != nominalType)
242242
{

src/MongoDB.Bson/Serialization/BsonClassMap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public static Type GetMemberInfoType(MemberInfo memberInfo)
284284
/// <returns>All registered class maps.</returns>
285285
public static IEnumerable<BsonClassMap> GetRegisteredClassMaps()
286286
{
287-
BsonSerializer.ConfigLock.EnterReadLock();
287+
BsonSerializer.ConfigLock.EnterReadLock(); //TODO It would make sense to look at this after the PR by Robert is merged
288288
try
289289
{
290290
return __classMaps.Values.ToList(); // return a copy for thread safety

src/MongoDB.Bson/Serialization/BsonMemberMap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public IBsonSerializer GetSerializer()
301301
// return special serializer for BsonValue members that handles the _csharpnull representation
302302
if (_memberTypeIsBsonValue)
303303
{
304-
var wrappedSerializer = BsonSerializer.LookupSerializer(_memberType);
304+
var wrappedSerializer = BsonSerializer.LookupSerializer(_memberType); //TODO We need another version of this with the domain as input
305305
var isBsonArraySerializer = wrappedSerializer is IBsonArraySerializer;
306306
var isBsonDocumentSerializer = wrappedSerializer is IBsonDocumentSerializer;
307307

src/MongoDB.Bson/Serialization/BsonSerializationProviderBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace MongoDB.Bson.Serialization
2424
public abstract class BsonSerializationProviderBase : IRegistryAwareBsonSerializationProvider
2525
{
2626
/// <inheritdoc/>
27-
public virtual IBsonSerializer GetSerializer(Type type)
27+
public virtual IBsonSerializer GetSerializer(Type type) //TODO Need to make another version with the domain as input
2828
{
2929
return GetSerializer(type, BsonSerializer.SerializerRegistry);
3030
}
@@ -38,7 +38,7 @@ public virtual IBsonSerializer GetSerializer(Type type)
3838
/// <param name="serializerTypeDefinition">The serializer type definition.</param>
3939
/// <param name="typeArguments">The type arguments.</param>
4040
/// <returns>A serializer.</returns>
41-
protected virtual IBsonSerializer CreateGenericSerializer(Type serializerTypeDefinition, params Type[] typeArguments)
41+
protected virtual IBsonSerializer CreateGenericSerializer(Type serializerTypeDefinition, params Type[] typeArguments) //TODO We need another version of this with the domain as input
4242
{
4343
return CreateGenericSerializer(serializerTypeDefinition, typeArguments, BsonSerializer.SerializerRegistry);
4444
}
@@ -65,7 +65,7 @@ protected virtual IBsonSerializer CreateGenericSerializer(Type serializerTypeDef
6565
/// <returns>A serializer.</returns>
6666
protected virtual IBsonSerializer CreateSerializer(Type serializerType)
6767
{
68-
return CreateSerializer(serializerType, BsonSerializer.SerializerRegistry);
68+
return CreateSerializer(serializerType, BsonSerializer.SerializerRegistry); //TODO We need another version of this with the domain as input
6969
}
7070

7171
/// <summary>

src/MongoDB.Bson/Serialization/Conventions/ConventionRegistry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace MongoDB.Bson.Serialization.Conventions
2121
/// <summary>
2222
/// Represents a registry of conventions.
2323
/// </summary>
24-
public static class ConventionRegistry
24+
public static class ConventionRegistry //TODO Probably this should get the same treatment as BsonSerializer....
2525
{
2626
// private static fields
2727
private readonly static List<ConventionPackContainer> __conventionPacks = new List<ConventionPackContainer>();

src/MongoDB.Bson/Serialization/Conventions/LookupIdGeneratorConvention.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public void PostProcess(BsonClassMap classMap)
3535
{
3636
if (idMemberMap.IdGenerator == null)
3737
{
38+
//TODO For this, we either add a new PostProcess method to the IPostProcessingConvention that takes the domain
39+
//or we pass the domain to the BsonClassMap. The first probably makes more sense, but it's messier.
3840
var idGenerator = BsonSerializer.LookupIdGenerator(idMemberMap.MemberType);
3941
if (idGenerator != null)
4042
{

src/MongoDB.Bson/Serialization/Conventions/ObjectDiscriminatorConvention.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public Type GetActualType(IBsonReader bsonReader, Type nominalType)
135135
{
136136
discriminator = discriminator.AsBsonArray.Last(); // last item is leaf class discriminator
137137
}
138-
actualType = BsonSerializer.LookupActualType(nominalType, discriminator);
138+
actualType = BsonSerializer.LookupActualType(nominalType, discriminator); //TODO For this (and other discriminator conventions) we need to add methods to IDiscriminatorConvention to pass the domain
139139
}
140140
bsonReader.ReturnToBookmark(bookmark);
141141
return actualType;

src/MongoDB.Bson/Serialization/Conventions/StringIdStoredAsObjectIdConvention.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void Apply(BsonMemberMap memberMap)
3838
return;
3939
}
4040

41-
var defaultStringSerializer = BsonSerializer.LookupSerializer(typeof(string));
41+
var defaultStringSerializer = BsonSerializer.LookupSerializer(typeof(string)); //TODO For this we'd need to add a new Apply(memberMap, domain) method to IMemberMapConvention
4242
if (memberMap.GetSerializer() != defaultStringSerializer)
4343
{
4444
return;

src/MongoDB.Bson/Serialization/IBsonSerializerExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static TValue Deserialize<TValue>(this IBsonSerializer<TValue> serializer
5858
public static IDiscriminatorConvention GetDiscriminatorConvention(this IBsonSerializer serializer) =>
5959
serializer is IHasDiscriminatorConvention hasDiscriminatorConvention
6060
? hasDiscriminatorConvention.DiscriminatorConvention
61-
: BsonSerializer.LookupDiscriminatorConvention(serializer.ValueType);
61+
: BsonSerializer.LookupDiscriminatorConvention(serializer.ValueType); //TODO We need another version of this with the domain as input
6262

6363
/// <summary>
6464
/// Serializes a value.

0 commit comments

Comments
 (0)