Skip to content
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

Update MongoDB.Bson to 2.19.1 #3393

Merged
merged 3 commits into from
Jul 26, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Realm/Realm/Helpers/SerializationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using MongoDB.Bson;
using MongoDB.Bson.IO;
Expand Down Expand Up @@ -142,8 +143,20 @@ private class RealmSerializationProvider : IBsonSerializationProvider
_ when type == typeof(decimal) => new DecimalSerializer(BsonType.Decimal128, new RepresentationConverter(allowOverflow: false, allowTruncation: false)),
_ when type == typeof(Guid) => new GuidSerializer(GuidRepresentation.Standard),
_ when type == typeof(DateTimeOffset) => new DateTimeOffsetSerializer(BsonType.String),
_ when type == typeof(object) => new ObjectSerializer(
BsonSerializer.LookupDiscriminatorConvention(typeof(object)),
GuidRepresentation.Standard,
allowedSerializationTypes: _ => true,
allowedDeserializationTypes: type => ObjectSerializer.DefaultAllowedTypes(type) || IsAnonymousType(type)),
_ => null
};

// TODO: remove this when https://github.com/mongodb/mongo-csharp-driver/commit/e0c14c80e6c31f337439d2915b5dd90fe38f9562
// is released
private static bool IsAnonymousType(Type type) =>
type.GetCustomAttributes(false).Any(x => x is CompilerGeneratedAttribute) &&
type.IsGenericType &&
type.Name.Contains("Anon");
}
}
}
4 changes: 2 additions & 2 deletions Realm/Realm/Realm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="MongoDB.Bson" Version="2.11.3" />
<PackageReference Include="MongoDB.Bson" Version="2.19.1" />
<PackageReference Include="PolySharp" Version="1.12.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -33,7 +33,7 @@
</PackageReference>
<PackageReference Include="System.Buffers" Version="4.4.0" />
<PackageReference Include="System.Dynamic.Runtime" Version="4.3.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.3" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageReference Include="Remotion.Linq" Version="2.2.0" />
<ProjectReference Include="..\Realm.Fody\Realm.Fody.csproj" PrivateAssets="None">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions Tools/DeployApps/BaasClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Net;
Expand All @@ -30,6 +29,7 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Serializers;

namespace Baas
{
Expand Down Expand Up @@ -159,6 +159,11 @@ private string _shortDifferentiator

public string Differentiator { get; }

static BaasClient()
{
BsonSerializer.RegisterSerializer(new ObjectSerializer(type => true));
}

private BaasClient(Uri baseUri, string differentiator, TextWriter output, string? clusterName = null)
{
_client.BaseAddress = new Uri(baseUri, "api/admin/v3.0/");
Expand Down Expand Up @@ -815,7 +820,7 @@ public static (object Schema, object Rules) Foos(string partitionKeyType, string
#if !NETCOREAPP2_1_OR_GREATER
internal static class DictionaryExtensions
{
[return: NotNullIfNotNull("defaultValue")]
[return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull("defaultValue")]
public static T? GetValueOrDefault<T>(this IDictionary<string, T> dictionary, string key, T? defaultValue = default)
{
if (dictionary.TryGetValue(key, out var value))
Expand Down
2 changes: 1 addition & 1 deletion Tools/DeployApps/DeployApps.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MongoDB.Bson" Version="2.16.0" />
<PackageReference Include="MongoDB.Bson" Version="2.19.1" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="..\..\stylecop.json" />
Expand Down
Loading