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
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
You can’t perform that action at this time.
0 commit comments