Skip to content

Commit

Permalink
CSHARP-4362: TestEmptySortedSet test failing on net6.
Browse files Browse the repository at this point in the history
  • Loading branch information
rstam committed Oct 13, 2022
1 parent 664d96c commit 5585012
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/MongoDB.Bson/Serialization/TypeNameDiscriminator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,25 @@ namespace MongoDB.Bson.Serialization
public static class TypeNameDiscriminator
{
// private static fields
private static Assembly[] __wellKnownAssemblies;
private static readonly HashSet<Assembly> __wellKnownAssemblies = new HashSet<Assembly>();

// static constructor
static TypeNameDiscriminator()
{
__wellKnownAssemblies = new Assembly[]
var representativeTypes = new Type[]
{
typeof(object).GetTypeInfo().Assembly, // mscorlib
typeof(Queue<>).GetTypeInfo().Assembly, // System
typeof(HashSet<>).GetTypeInfo().Assembly // System.Core
// the actual locations of these types varies depending on the target framework
typeof(object),
typeof(Queue<>),
typeof(HashSet<>),
typeof(SortedSet<>)
};

foreach (var type in representativeTypes)
{
var assembly = type.GetTypeInfo().Assembly;
__wellKnownAssemblies.Add(assembly);
}
}

// public static methods
Expand Down

0 comments on commit 5585012

Please sign in to comment.