@@ -1268,13 +1268,13 @@ private Func<object> GetCreator()
12681268 }
12691269 else
12701270 {
1271- #if NET45
1271+ #if NETSTANDARD16
1272+ var message = $ "Type '{ _classType . GetType ( ) . Name } ' does not have a default constructor.";
1273+ throw new BsonSerializationException ( message ) ;
1274+ #else
12721275 // lambdaExpression = () => FormatterServices.GetUninitializedObject(classType)
12731276 var getUnitializedObjectMethodInfo = typeof ( FormatterServices ) . GetMethod ( "GetUninitializedObject" , BindingFlags . Public | BindingFlags . Static ) ;
12741277 body = Expression . Call ( getUnitializedObjectMethodInfo , Expression . Constant ( _classType ) ) ;
1275- #else
1276- var message = $ "Type '{ _classType . GetType ( ) . Name } ' does not have a default constructor.";
1277- throw new BsonSerializationException ( message ) ;
12781278#endif
12791279 }
12801280 var lambdaExpression = Expression . Lambda < Func < object > > ( body ) ;
@@ -1537,9 +1537,7 @@ public void UnmapProperty<TMember>(Expression<Func<TClass, TMember>> propertyLam
15371537 // private static methods
15381538 private static MethodInfo [ ] GetPropertyAccessors ( PropertyInfo propertyInfo )
15391539 {
1540- #if NET45
1541- return propertyInfo . GetAccessors ( true ) ;
1542- #else
1540+ #if NETSTANDARD16
15431541 var accessors = new List < MethodInfo > ( ) ;
15441542 if ( propertyInfo . GetMethod != null )
15451543 {
@@ -1550,6 +1548,8 @@ private static MethodInfo[] GetPropertyAccessors(PropertyInfo propertyInfo)
15501548 accessors . Add ( propertyInfo . SetMethod ) ;
15511549 }
15521550 return accessors . ToArray ( ) ;
1551+ #else
1552+ return propertyInfo . GetAccessors ( true ) ;
15531553#endif
15541554 }
15551555
@@ -1593,7 +1593,7 @@ private static PropertyInfo FindPropertyImplementation(PropertyInfo interfacePro
15931593 {
15941594 var interfaceType = interfacePropertyInfo . DeclaringType ;
15951595
1596- #if NETCORE
1596+ #if NETSTANDARD16
15971597 var actualTypeInfo = actualType . GetTypeInfo ( ) ;
15981598 var bindingFlags = BindingFlags . Instance | BindingFlags . NonPublic | BindingFlags . Public ;
15991599 var actualTypePropertyInfos = actualTypeInfo . GetMembers ( bindingFlags ) . OfType < PropertyInfo > ( ) ;
0 commit comments