File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
src/MongoDB.Bson/Serialization Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -27,17 +27,25 @@ namespace MongoDB.Bson.Serialization
27
27
public static class TypeNameDiscriminator
28
28
{
29
29
// private static fields
30
- private static Assembly [ ] __wellKnownAssemblies ;
30
+ private static readonly HashSet < Assembly > __wellKnownAssemblies = new HashSet < Assembly > ( ) ;
31
31
32
32
// static constructor
33
33
static TypeNameDiscriminator ( )
34
34
{
35
- __wellKnownAssemblies = new Assembly [ ]
35
+ var representativeTypes = new Type [ ]
36
36
{
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 < > )
40
42
} ;
43
+
44
+ foreach ( var type in representativeTypes )
45
+ {
46
+ var assembly = type . GetTypeInfo ( ) . Assembly ;
47
+ __wellKnownAssemblies . Add ( assembly ) ;
48
+ }
41
49
}
42
50
43
51
// public static methods
You can’t perform that action at this time.
0 commit comments