Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion benchmarks/MongoDB.Driver.Benchmarks/BenchmarkHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ public static IMongoClient CreateClient(string databaseToDrop = PerfTestDatabase
return client;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void Setup()
_writer = new BsonBinaryWriter(_stream);
_context = BsonSerializationContext.CreateRoot(_writer);
_document = ReadExtendedJson(BenchmarkData.FilePath);
_documentPoco = BsonSerializer.Deserialize(_document, BenchmarkData.PocoType);
_documentPoco = BsonSerializer.Deserialize(_document, BenchmarkData.PocoType);
_pocoSerializer = BsonSerializer.LookupSerializer(BenchmarkData.PocoType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ private static void WriteScoreToResults(JsonWriter jsonWriter, string name, doub

jsonWriter.WriteEndDocument();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ private static void WriteScore(StreamWriter writer, string benchName, double sco
? $"Executed {benchName}, score: {score:F3} {unit}"
: $"Skipped {benchName}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void Setup()
[Benchmark]
public void FindManyAndEmptyCursor()
{
_ = _collection.Find(Builders<BsonDocument>.Filter.Empty).ToList();
_ = _collection.Find(Builders<BsonDocument>.Filter.Empty).ToList();
}

[Benchmark]
Expand Down
2 changes: 1 addition & 1 deletion src/MongoDB.Bson/IBsonDefaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ internal interface IBsonDefaults
/// <summary>Gets or sets the maximum allowed serialization depth.</summary>
int MaxSerializationDepth { get; set; }
}
}
}
6 changes: 3 additions & 3 deletions src/MongoDB.Bson/IO/BsonBinaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -794,13 +794,13 @@ private string GenerateDottedElementName(BsonBinaryReaderContext[] contexts, int

if (context.ContextType == ContextType.Document)
{
return GenerateDottedElementName(contexts, nextIndex, (context.ElementName ?? "?") + "." + elementName);
return GenerateDottedElementName(contexts, nextIndex, (context.ElementName ?? "?") + "." + elementName);
}

if (context.ContextType == ContextType.Array)
{
var indexElementName = context.ArrayIndex.ToString(NumberFormatInfo.InvariantInfo);
return GenerateDottedElementName(contexts, nextIndex, indexElementName + "." + elementName);
return GenerateDottedElementName(contexts, nextIndex, indexElementName + "." + elementName);
}

if (nextIndex < contexts.Length)
Expand Down Expand Up @@ -834,7 +834,7 @@ private void PopContext()
throw new FormatException($"Expected size to be {_context.Size}, not {actualSize}.");
}

_context =_contextStack.Pop();
_context = _contextStack.Pop();
}

private void PushContext(BsonBinaryReaderContext newContext)
Expand Down
4 changes: 2 additions & 2 deletions src/MongoDB.Bson/ObjectModel/Decimal128.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ public int Compare(Decimal128 x, Decimal128 y)
{
var xType = GetDecimal128Type(x);
var yType = GetDecimal128Type(y);
// .NET Framework lacks some optimizations for enums that would result in boxing and lookup overhead for the default comparer
// .NET Framework lacks some optimizations for enums that would result in boxing and lookup overhead for the default comparer
#if NET6_0_OR_GREATER
var result = Comparer<Decimal128Type>.Default.Compare(xType, yType);
#else
Expand Down Expand Up @@ -1967,7 +1967,7 @@ private int CompareNumbers(Decimal128 x, Decimal128 y)
{
var xClass = GetNumberClass(x);
var yClass = GetNumberClass(y);
// .NET Framework lacks some optimizations for enums that would result in boxing and lookup overhead for the default comparer
// .NET Framework lacks some optimizations for enums that would result in boxing and lookup overhead for the default comparer
#if NET6_0_OR_GREATER
var result = Comparer<NumberClass>.Default.Compare(xClass, yClass);
#else
Expand Down
4 changes: 2 additions & 2 deletions src/MongoDB.Bson/Serialization/BsonClassMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public static BsonClassMap LookupClassMap(Type classType) =>
/// </summary>
/// <typeparam name="TClass">The class.</typeparam>
/// <returns>The class map.</returns>
public static BsonClassMap<TClass> RegisterClassMap<TClass>()=>
public static BsonClassMap<TClass> RegisterClassMap<TClass>() =>
BsonSerializationDomain.Default.ClassMapRegistry.RegisterClassMap<TClass>();

/// <summary>
Expand Down Expand Up @@ -400,7 +400,7 @@ public override bool Equals(object obj)
return
GetType().Equals(obj.GetType()) &&
obj is BsonClassMap other &&
_frozen.Equals(true) && other._frozen.Equals(true) && // BsonClassMaps should only be equal if they are frozen
_frozen.Equals(true) && other._frozen.Equals(true) && // BsonClassMaps should only be equal if they are frozen
object.Equals(_baseClassMap, other._baseClassMap) &&
object.Equals(_classType, other._classType) &&
object.Equals(_creator, other._creator) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override IBsonSerializer GetSerializer(Type type, IBsonSerializerRegistry
var classMap = _serializationDomain.ClassMapRegistry.LookupClassMap(type);
var classMapSerializerDefinition = typeof(BsonClassMapSerializer<>);
var classMapSerializerType = classMapSerializerDefinition.MakeGenericType(type);
var bindingAttr = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
var bindingAttr = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
return (IBsonSerializer)Activator.CreateInstance(classMapSerializerType, bindingAttr, binder: null, args: [_serializationDomain, classMap], culture: null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class EnumRepresentationConvention : ConventionBase, IMemberMapConvention
/// <param name="representation">The serialization representation. 0 is used to detect representation
/// from the enum itself.</param>
public EnumRepresentationConvention(BsonType representation)
:this(representation, true)
: this(representation, true)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ bool PropertyMatchesSomeConstructorParameter(ConstructorInfo constructorInfo)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public ObjectSerializerAllowedTypesConvention(IEnumerable<Type> allowedTypes)
{
var allowedTypesArray = allowedTypes.ToArray();

_allowedDeserializationTypes = allowedTypesArray.Contains;
_allowedDeserializationTypes = allowedTypesArray.Contains;
_allowedSerializationTypes = allowedTypesArray.Contains;
}

Expand Down Expand Up @@ -210,4 +210,4 @@ private IBsonSerializer Reconfigure(IBsonSerializer serializer)
return null;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void RegisterGenericSerializerDefinition(
/// </summary>
bool UseZeroIdChecker { get; set; }

/// <summary>
/// <summary>
/// Deserializes an object from a BsonDocument.
/// </summary>
/// <typeparam name="TNominalType">The nominal type of the object.</typeparam>
Expand Down
8 changes: 4 additions & 4 deletions src/MongoDB.Bson/Serialization/IBsonSerializerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ public static IDiscriminatorConvention GetDiscriminatorConvention(this IBsonSeri
case IHasDiscriminatorConvention hasDiscriminatorConvention:
return hasDiscriminatorConvention.DiscriminatorConvention;
case IHasSerializationDomain hasSerializationDomain:
{
var serializationDomain = hasSerializationDomain.SerializationDomain;
return serializationDomain.LookupDiscriminatorConvention(serializer.ValueType);
}
{
var serializationDomain = hasSerializationDomain.SerializationDomain;
return serializationDomain.LookupDiscriminatorConvention(serializer.ValueType);
}
default:
return BsonSerializationDomain.Default.LookupDiscriminatorConvention(serializer.ValueType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ public interface IMultipleChildSerializersConfigurable
/// <returns>The reconfigured serializer.</returns>
IBsonSerializer WithChildSerializers(IBsonSerializer[] childSerializers);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ public enum DateOnlyDocumentFormat
/// </summary>
YearMonthDay
}
}
}
2 changes: 1 addition & 1 deletion src/MongoDB.Bson/Serialization/Options/TimeOnlyUnits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ public enum TimeOnlyUnits
/// </summary>
Nanoseconds
}
}
}
34 changes: 17 additions & 17 deletions src/MongoDB.Bson/Serialization/SerializerConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,30 @@ internal static IBsonSerializer ReconfigureSerializerRecursively(
{
// check IMultipleChildSerializersConfigurableSerializer first because some serializers implement both interfaces
case IMultipleChildSerializersConfigurable multipleChildSerializerConfigurable:
{
var anyChildSerializerWasReconfigured = false;
var reconfiguredChildSerializers = new List<IBsonSerializer>();

foreach (var childSerializer in multipleChildSerializerConfigurable.ChildSerializers)
{
var reconfiguredChildSerializer = ReconfigureSerializerRecursively(childSerializer, reconfigure);
anyChildSerializerWasReconfigured |= reconfiguredChildSerializer != null;
reconfiguredChildSerializers.Add(reconfiguredChildSerializer ?? childSerializer);
}
var anyChildSerializerWasReconfigured = false;
var reconfiguredChildSerializers = new List<IBsonSerializer>();

foreach (var childSerializer in multipleChildSerializerConfigurable.ChildSerializers)
{
var reconfiguredChildSerializer = ReconfigureSerializerRecursively(childSerializer, reconfigure);
anyChildSerializerWasReconfigured |= reconfiguredChildSerializer != null;
reconfiguredChildSerializers.Add(reconfiguredChildSerializer ?? childSerializer);
}

return anyChildSerializerWasReconfigured ? multipleChildSerializerConfigurable.WithChildSerializers(reconfiguredChildSerializers.ToArray()) : null;
}
return anyChildSerializerWasReconfigured ? multipleChildSerializerConfigurable.WithChildSerializers(reconfiguredChildSerializers.ToArray()) : null;
}

case IChildSerializerConfigurable childSerializerConfigurable:
{
var childSerializer = childSerializerConfigurable.ChildSerializer;
var reconfiguredChildSerializer = ReconfigureSerializerRecursively(childSerializer, reconfigure);
return reconfiguredChildSerializer != null ? childSerializerConfigurable.WithChildSerializer(reconfiguredChildSerializer) : null;
}
{
var childSerializer = childSerializerConfigurable.ChildSerializer;
var reconfiguredChildSerializer = ReconfigureSerializerRecursively(childSerializer, reconfigure);
return reconfiguredChildSerializer != null ? childSerializerConfigurable.WithChildSerializer(reconfiguredChildSerializer) : null;
}

default:
return reconfigure(serializer);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public sealed class DiscriminatedInterfaceSerializer<TInterface> :
IBsonDocumentSerializer,
IDiscriminatedInterfaceSerializer,
IHasSerializationDomain
// where TInterface is an interface
// where TInterface is an interface
{
#region static
private static IBsonSerializer<TInterface> CreateInterfaceSerializer()
Expand Down Expand Up @@ -137,7 +137,7 @@ internal DiscriminatedInterfaceSerializer(IBsonSerializationDomain serialization
}

_interfaceType = typeof(TInterface);
_serializationDomain = serializationDomain;
_serializationDomain = serializationDomain;
_discriminatorConvention = discriminatorConvention ?? interfaceSerializer.GetDiscriminatorConvention();
_interfaceSerializer = interfaceSerializer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,4 @@ IBsonSerializer IRepresentationConfigurable.WithRepresentation(BsonType represen
}
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ protected override ImmutableArray<T> FinalizeResult(object accumulator)
}
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ protected override ImmutableDictionary<TKey, TValue> FinalizeAccumulator(ICollec
}
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ protected override ImmutableHashSet<T> FinalizeResult(object accumulator)
}
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ protected override ImmutableList<T> FinalizeResult(object accumulator)
}
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ protected override ImmutableQueue<T> FinalizeResult(object accumulator)
}
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ protected override ImmutableSortedDictionary<TKey, TValue> FinalizeAccumulator(I
}
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ protected override ImmutableSortedSet<T> FinalizeResult(object accumulator)
}
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ protected override ImmutableStack<T> FinalizeResult(object accumulator)
}
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface IKeyValuePairSerializer
/// <summary>
/// Gets the representation.
/// </summary>
BsonType Representation { get; }
BsonType Representation { get; }
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ private static (Func<IBsonReader, TItem[]> reader, Action<IBsonWriter, Memory<TI
break;
default:
throw new NotSupportedException($"Not supported memory type {typeof(TItem)}. Only primitive numeric types are supported.");
};
}
;

return (readItems, writeItems);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ private static T[] ReadBsonArray<T>(
var array = bsonReader.ReadRawBsonArray();
using var buffer = ThreadStaticBuffer.RentBuffer(array.Length);

var bytes = buffer.Bytes;
array.GetBytes(0, bytes, 0, array.Length);
var bytes = buffer.Bytes;
array.GetBytes(0, bytes, 0, array.Length);
var span = bytes.AsSpan();

var result = new List<T>();
Expand Down Expand Up @@ -112,7 +112,7 @@ private static T[] ReadBsonArray<T>(
case ConversionType.Decimal128ToDecimal128:
{
var lowBits = BinaryPrimitives.ReadUInt64LittleEndian(span.Slice(index));
var highBits = BinaryPrimitives.ReadUInt64LittleEndian(span.Slice(index + 8));
var highBits = BinaryPrimitives.ReadUInt64LittleEndian(span.Slice(index + 8));
var v = Decimal128.ToDecimal(Decimal128.FromIEEEBits(highBits, lowBits));

value = Unsafe.As<decimal, T>(ref v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ IBsonSerializer IMultipleChildSerializersConfigurable.WithChildSerializers(IBson
throw new Exception("Wrong number of child serializers passed.");
}

var newKeySerializer = (IBsonSerializer<TKey>)childSerializers[0];
var newValueSerializer = (IBsonSerializer<TValue>)childSerializers[1];
var newKeySerializer = (IBsonSerializer<TKey>)childSerializers[0];
var newValueSerializer = (IBsonSerializer<TValue>)childSerializers[1];

return newKeySerializer.Equals(KeySerializer) && newValueSerializer.Equals(ValueSerializer)
? this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,4 @@ IBsonSerializer IRepresentationConfigurable.WithRepresentation(BsonType represen
}
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace MongoDB.Driver.Authentication.AWS.SaslSteps
{
internal sealed class AWSLastSaslStep : ISaslStep
{
private static readonly ISet<string> __serverResponseExpectedNames = new HashSet<string>(new []{ "h", "s" });
private static readonly ISet<string> __serverResponseExpectedNames = new HashSet<string>(new[] { "h", "s" });

private readonly IClock _clock;
private readonly IAWSCredentialsSource _credentialsSource;
Expand Down
2 changes: 1 addition & 1 deletion src/MongoDB.Driver.Encryption/Binary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,5 @@ protected virtual void Dispose(bool disposing)
}
}
#endregion
}
}
}
Loading