Skip to content

Commit 5585012

Browse files
committed
CSHARP-4362: TestEmptySortedSet test failing on net6.
1 parent 664d96c commit 5585012

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/MongoDB.Bson/Serialization/TypeNameDiscriminator.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,25 @@ namespace MongoDB.Bson.Serialization
2727
public static class TypeNameDiscriminator
2828
{
2929
// private static fields
30-
private static Assembly[] __wellKnownAssemblies;
30+
private static readonly HashSet<Assembly> __wellKnownAssemblies = new HashSet<Assembly>();
3131

3232
// static constructor
3333
static TypeNameDiscriminator()
3434
{
35-
__wellKnownAssemblies = new Assembly[]
35+
var representativeTypes = new Type[]
3636
{
37-
typeof(object).GetTypeInfo().Assembly, // mscorlib
38-
typeof(Queue<>).GetTypeInfo().Assembly, // System
39-
typeof(HashSet<>).GetTypeInfo().Assembly // System.Core
37+
// the actual locations of these types varies depending on the target framework
38+
typeof(object),
39+
typeof(Queue<>),
40+
typeof(HashSet<>),
41+
typeof(SortedSet<>)
4042
};
43+
44+
foreach (var type in representativeTypes)
45+
{
46+
var assembly = type.GetTypeInfo().Assembly;
47+
__wellKnownAssemblies.Add(assembly);
48+
}
4149
}
4250

4351
// public static methods

0 commit comments

Comments
 (0)