diff --git a/src/MongoDB.Bson/Exceptions/BsonException.cs b/src/MongoDB.Bson/Exceptions/BsonException.cs
index 3d2c363bb36..186e94e0d14 100644
--- a/src/MongoDB.Bson/Exceptions/BsonException.cs
+++ b/src/MongoDB.Bson/Exceptions/BsonException.cs
@@ -14,7 +14,7 @@
*/
using System;
-#if NET452
+#if NET452 || NETSTANDARD2_0
using System.Runtime.Serialization;
#endif
@@ -23,7 +23,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON exception.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonException : Exception
@@ -66,7 +66,7 @@ public BsonException(string format, params object[] args)
{
}
-#if NET452
+#if NET452 || NETSTANDARD2_0
///
/// Initializes a new instance of the BsonException class (this overload used by deserialization).
///
diff --git a/src/MongoDB.Bson/Exceptions/BsonInternalException.cs b/src/MongoDB.Bson/Exceptions/BsonInternalException.cs
index 5c71f7edb2a..9cf49ad95b1 100644
--- a/src/MongoDB.Bson/Exceptions/BsonInternalException.cs
+++ b/src/MongoDB.Bson/Exceptions/BsonInternalException.cs
@@ -14,7 +14,7 @@
*/
using System;
-#if NET452
+#if NET452 || NETSTANDARD2_0
using System.Runtime.Serialization;
#endif
@@ -23,7 +23,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON internal exception (almost surely the result of a bug).
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonInternalException : BsonException
@@ -56,7 +56,7 @@ public BsonInternalException(string message, Exception innerException)
{
}
-#if NET452
+#if NET452 || NETSTANDARD2_0
///
/// Initializes a new instance of the BsonInternalException class (this overload used by deserialization).
///
diff --git a/src/MongoDB.Bson/Exceptions/BsonSerializationException.cs b/src/MongoDB.Bson/Exceptions/BsonSerializationException.cs
index d09dd7ebacd..6c472257d74 100644
--- a/src/MongoDB.Bson/Exceptions/BsonSerializationException.cs
+++ b/src/MongoDB.Bson/Exceptions/BsonSerializationException.cs
@@ -14,7 +14,7 @@
*/
using System;
-#if NET452
+#if NET452 || NETSTANDARD2_0
using System.Runtime.Serialization;
#endif
@@ -23,7 +23,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON serialization exception.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonSerializationException : BsonException
@@ -56,7 +56,7 @@ public BsonSerializationException(string message, Exception innerException)
{
}
-#if NET452
+#if NET452 || NETSTANDARD2_0
///
/// Initializes a new instance of the BsonSerializationException class (this overload used by deserialization).
///
diff --git a/src/MongoDB.Bson/Exceptions/DuplicateBsonMemberMapAttributeException.cs b/src/MongoDB.Bson/Exceptions/DuplicateBsonMemberMapAttributeException.cs
index 8145f2da61b..f241d26833f 100644
--- a/src/MongoDB.Bson/Exceptions/DuplicateBsonMemberMapAttributeException.cs
+++ b/src/MongoDB.Bson/Exceptions/DuplicateBsonMemberMapAttributeException.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson
///
/// Indicates that an attribute restricted to one member has been applied to multiple members.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class DuplicateBsonMemberMapAttributeException : BsonException
@@ -45,7 +45,7 @@ public DuplicateBsonMemberMapAttributeException(string message, Exception inner)
{
}
-#if NET452
+#if NET452 || NETSTANDARD2_0
///
/// Initializes a new instance of the class.
///
diff --git a/src/MongoDB.Bson/Exceptions/TruncationException.cs b/src/MongoDB.Bson/Exceptions/TruncationException.cs
index 324a200ff32..0745b53ddeb 100644
--- a/src/MongoDB.Bson/Exceptions/TruncationException.cs
+++ b/src/MongoDB.Bson/Exceptions/TruncationException.cs
@@ -14,7 +14,7 @@
*/
using System;
-#if NET452
+#if NET452 || NETSTANDARD2_0
using System.Runtime.Serialization;
#endif
@@ -23,7 +23,7 @@ namespace MongoDB.Bson
///
/// Represents a truncation exception.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class TruncationException : BsonException
@@ -56,7 +56,7 @@ public TruncationException(string message, Exception innerException)
{
}
-#if NET452
+#if NET452 || NETSTANDARD2_0
///
/// Initializes a new instance of the TruncationException class (this overload used by deserialization).
///
diff --git a/src/MongoDB.Bson/IO/BsonBinaryReaderSettings.cs b/src/MongoDB.Bson/IO/BsonBinaryReaderSettings.cs
index 8bb8df3e1f2..8da090bc31b 100644
--- a/src/MongoDB.Bson/IO/BsonBinaryReaderSettings.cs
+++ b/src/MongoDB.Bson/IO/BsonBinaryReaderSettings.cs
@@ -21,7 +21,7 @@ namespace MongoDB.Bson.IO
///
/// Represents settings for a BsonBinaryReader.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonBinaryReaderSettings : BsonReaderSettings
diff --git a/src/MongoDB.Bson/IO/BsonBinaryWriterSettings.cs b/src/MongoDB.Bson/IO/BsonBinaryWriterSettings.cs
index 7300698fb10..1598327d60c 100644
--- a/src/MongoDB.Bson/IO/BsonBinaryWriterSettings.cs
+++ b/src/MongoDB.Bson/IO/BsonBinaryWriterSettings.cs
@@ -21,7 +21,7 @@ namespace MongoDB.Bson.IO
///
/// Represents settings for a BsonBinaryWriter.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonBinaryWriterSettings : BsonWriterSettings
diff --git a/src/MongoDB.Bson/IO/BsonDocumentReaderSettings.cs b/src/MongoDB.Bson/IO/BsonDocumentReaderSettings.cs
index 44596dea42f..7d5ddfcdfcf 100644
--- a/src/MongoDB.Bson/IO/BsonDocumentReaderSettings.cs
+++ b/src/MongoDB.Bson/IO/BsonDocumentReaderSettings.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson.IO
///
/// Represents settings for a BsonDocumentReader.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonDocumentReaderSettings : BsonReaderSettings
diff --git a/src/MongoDB.Bson/IO/BsonDocumentWriterSettings.cs b/src/MongoDB.Bson/IO/BsonDocumentWriterSettings.cs
index d88d6a2d69d..ecd0813997c 100644
--- a/src/MongoDB.Bson/IO/BsonDocumentWriterSettings.cs
+++ b/src/MongoDB.Bson/IO/BsonDocumentWriterSettings.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson.IO
///
/// Represents settings for a BsonDocumentWriter.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonDocumentWriterSettings : BsonWriterSettings
diff --git a/src/MongoDB.Bson/IO/BsonReaderSettings.cs b/src/MongoDB.Bson/IO/BsonReaderSettings.cs
index 9ae4cb6910f..202a16a7d96 100644
--- a/src/MongoDB.Bson/IO/BsonReaderSettings.cs
+++ b/src/MongoDB.Bson/IO/BsonReaderSettings.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson.IO
///
/// Represents settings for a BsonReader.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public abstract class BsonReaderSettings
diff --git a/src/MongoDB.Bson/IO/BsonStreamAdapter.cs b/src/MongoDB.Bson/IO/BsonStreamAdapter.cs
index 5b8181e9451..7950a94d41f 100644
--- a/src/MongoDB.Bson/IO/BsonStreamAdapter.cs
+++ b/src/MongoDB.Bson/IO/BsonStreamAdapter.cs
@@ -164,7 +164,7 @@ public override int WriteTimeout
}
// methods
-#if NET452
+#if NET452 || NETSTANDARD2_0
///
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
@@ -173,7 +173,7 @@ public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, Asy
}
#endif
-#if NET452
+#if NET452 || NETSTANDARD2_0
///
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
@@ -182,7 +182,7 @@ public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, As
}
#endif
-#if NET452
+#if NET452 || NETSTANDARD2_0
///
public override void Close()
{
@@ -214,7 +214,7 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}
-#if NET452
+#if NET452 || NETSTANDARD2_0
///
public override int EndRead(IAsyncResult asyncResult)
{
@@ -223,7 +223,7 @@ public override int EndRead(IAsyncResult asyncResult)
}
#endif
-#if NET452
+#if NET452 || NETSTANDARD2_0
///
public override void EndWrite(IAsyncResult asyncResult)
{
diff --git a/src/MongoDB.Bson/IO/BsonWriterSettings.cs b/src/MongoDB.Bson/IO/BsonWriterSettings.cs
index ad7425b87b9..38b666d9789 100644
--- a/src/MongoDB.Bson/IO/BsonWriterSettings.cs
+++ b/src/MongoDB.Bson/IO/BsonWriterSettings.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson.IO
///
/// Represents settings for a BsonWriter.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public abstract class BsonWriterSettings
diff --git a/src/MongoDB.Bson/IO/JsonReaderSettings.cs b/src/MongoDB.Bson/IO/JsonReaderSettings.cs
index b66d532bde1..9d91dd31032 100644
--- a/src/MongoDB.Bson/IO/JsonReaderSettings.cs
+++ b/src/MongoDB.Bson/IO/JsonReaderSettings.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson.IO
///
/// Represents settings for a JsonReader.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class JsonReaderSettings : BsonReaderSettings
diff --git a/src/MongoDB.Bson/IO/JsonWriterSettings.cs b/src/MongoDB.Bson/IO/JsonWriterSettings.cs
index e640dd7fa00..5b3d7b9b772 100644
--- a/src/MongoDB.Bson/IO/JsonWriterSettings.cs
+++ b/src/MongoDB.Bson/IO/JsonWriterSettings.cs
@@ -21,7 +21,7 @@ namespace MongoDB.Bson.IO
///
/// Represents settings for a JsonWriter.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class JsonWriterSettings : BsonWriterSettings
diff --git a/src/MongoDB.Bson/MongoDB.Bson.csproj b/src/MongoDB.Bson/MongoDB.Bson.csproj
index 02d084b4744..743218c644b 100644
--- a/src/MongoDB.Bson/MongoDB.Bson.csproj
+++ b/src/MongoDB.Bson/MongoDB.Bson.csproj
@@ -1,7 +1,7 @@
- netstandard1.5;net452
+ netstandard2.0;netstandard1.5;net452
7.3
true
diff --git a/src/MongoDB.Bson/ObjectModel/BsonArray.cs b/src/MongoDB.Bson/ObjectModel/BsonArray.cs
index ff4243eff2e..68fc5a2b322 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonArray.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonArray.cs
@@ -25,7 +25,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON array.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonArray : BsonValue, IComparable, IEquatable, IList
diff --git a/src/MongoDB.Bson/ObjectModel/BsonBinaryData.cs b/src/MongoDB.Bson/ObjectModel/BsonBinaryData.cs
index f01bc37e926..a48a56f37f6 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonBinaryData.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonBinaryData.cs
@@ -21,7 +21,7 @@ namespace MongoDB.Bson
///
/// Represents BSON binary data.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonBinaryData : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonBinarySubType.cs b/src/MongoDB.Bson/ObjectModel/BsonBinarySubType.cs
index eb617e0c010..489120bdbb5 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonBinarySubType.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonBinarySubType.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson
///
/// Represents the binary data subtype of a BsonBinaryData.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public enum BsonBinarySubType
diff --git a/src/MongoDB.Bson/ObjectModel/BsonBoolean.cs b/src/MongoDB.Bson/ObjectModel/BsonBoolean.cs
index 6f7c990f933..db650e501b0 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonBoolean.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonBoolean.cs
@@ -21,7 +21,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON boolean value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonBoolean : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonDateTime.cs b/src/MongoDB.Bson/ObjectModel/BsonDateTime.cs
index 6d43d09318c..2ea423d58c0 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonDateTime.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonDateTime.cs
@@ -21,7 +21,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON DateTime value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonDateTime : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonDecimal128.cs b/src/MongoDB.Bson/ObjectModel/BsonDecimal128.cs
index 95a330695ca..46acce124d3 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonDecimal128.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonDecimal128.cs
@@ -22,7 +22,7 @@ namespace MongoDB.Bson
/// Represents a BSON Decimal128 value.
///
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonDecimal128 : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonDocument.cs b/src/MongoDB.Bson/ObjectModel/BsonDocument.cs
index c831fd6da0c..4b5de30d26c 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonDocument.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonDocument.cs
@@ -28,7 +28,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON document.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonDocument : BsonValue, IComparable, IConvertibleToBsonDocument, IEnumerable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonDouble.cs b/src/MongoDB.Bson/ObjectModel/BsonDouble.cs
index 706daf390bb..62742611581 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonDouble.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonDouble.cs
@@ -23,7 +23,7 @@ namespace MongoDB.Bson
/// Represents a BSON double value.
///
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonDouble : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonElement.cs b/src/MongoDB.Bson/ObjectModel/BsonElement.cs
index 4059cc98544..ac8823f8e76 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonElement.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonElement.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON element.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public struct BsonElement : IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonInt32.cs b/src/MongoDB.Bson/ObjectModel/BsonInt32.cs
index f24569941fe..a4da800eea2 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonInt32.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonInt32.cs
@@ -21,7 +21,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON int value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonInt32 : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonInt64.cs b/src/MongoDB.Bson/ObjectModel/BsonInt64.cs
index 4c4b2f0db5d..6cab4567709 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonInt64.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonInt64.cs
@@ -21,7 +21,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON long value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonInt64 : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonJavaScript.cs b/src/MongoDB.Bson/ObjectModel/BsonJavaScript.cs
index 1c54fdbde2f..333d8f9171b 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonJavaScript.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonJavaScript.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON JavaScript value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonJavaScript : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonJavaScriptWithScope.cs b/src/MongoDB.Bson/ObjectModel/BsonJavaScriptWithScope.cs
index 4dbd078cc3f..1b245b5910d 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonJavaScriptWithScope.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonJavaScriptWithScope.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON JavaScript value with a scope.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonJavaScriptWithScope : BsonJavaScript, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonMaxKey.cs b/src/MongoDB.Bson/ObjectModel/BsonMaxKey.cs
index f16bbc0ef0a..169fb9e37f0 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonMaxKey.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonMaxKey.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson
///
/// Represents the BSON MaxKey value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonMaxKey : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonMinKey.cs b/src/MongoDB.Bson/ObjectModel/BsonMinKey.cs
index 14f8e083b3e..c253d39d2cc 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonMinKey.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonMinKey.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson
///
/// Represents the BSON MinKey value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonMinKey : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonNull.cs b/src/MongoDB.Bson/ObjectModel/BsonNull.cs
index d38574d1dd3..b0db4c3a381 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonNull.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonNull.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson
///
/// Represents the BSON Null value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonNull : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonObjectId.cs b/src/MongoDB.Bson/ObjectModel/BsonObjectId.cs
index 4a4ad0448ce..3d6d6a720fb 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonObjectId.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonObjectId.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON ObjectId value (see also ObjectId).
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonObjectId : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonRegularExpression.cs b/src/MongoDB.Bson/ObjectModel/BsonRegularExpression.cs
index 3c4961c9309..96494539a87 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonRegularExpression.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonRegularExpression.cs
@@ -21,7 +21,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON regular expression value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonRegularExpression : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonString.cs b/src/MongoDB.Bson/ObjectModel/BsonString.cs
index 415af80d700..38f7fc083b6 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonString.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonString.cs
@@ -21,7 +21,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON string value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonString : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonTimestamp.cs b/src/MongoDB.Bson/ObjectModel/BsonTimestamp.cs
index b0160d6266d..01b03402035 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonTimestamp.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonTimestamp.cs
@@ -21,7 +21,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON timestamp value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonTimestamp : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonType.cs b/src/MongoDB.Bson/ObjectModel/BsonType.cs
index cfe337b6382..c877e7c8916 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonType.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonType.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson
///
/// Represents the type of a BSON element.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public enum BsonType
diff --git a/src/MongoDB.Bson/ObjectModel/BsonUndefined.cs b/src/MongoDB.Bson/ObjectModel/BsonUndefined.cs
index 963100db1ba..94a894fbe32 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonUndefined.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonUndefined.cs
@@ -20,7 +20,7 @@ namespace MongoDB.Bson
///
/// Represents the BSON undefined value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public class BsonUndefined : BsonValue, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/BsonValue.cs b/src/MongoDB.Bson/ObjectModel/BsonValue.cs
index c7be69d2b0b..5e57eb25e2f 100644
--- a/src/MongoDB.Bson/ObjectModel/BsonValue.cs
+++ b/src/MongoDB.Bson/ObjectModel/BsonValue.cs
@@ -22,7 +22,7 @@ namespace MongoDB.Bson
///
/// Represents a BSON value (this is an abstract class, see the various subclasses).
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public abstract class BsonValue : IComparable, IConvertible, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/Decimal128.cs b/src/MongoDB.Bson/ObjectModel/Decimal128.cs
index 0bdc46aecff..65c3ac5d7c9 100644
--- a/src/MongoDB.Bson/ObjectModel/Decimal128.cs
+++ b/src/MongoDB.Bson/ObjectModel/Decimal128.cs
@@ -24,7 +24,7 @@ namespace MongoDB.Bson
///
/// Represents a Decimal128 value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public struct Decimal128 : IConvertible, IComparable, IEquatable
diff --git a/src/MongoDB.Bson/ObjectModel/GuidRepresentation.cs b/src/MongoDB.Bson/ObjectModel/GuidRepresentation.cs
index 8b99d784c92..8bb011c7538 100644
--- a/src/MongoDB.Bson/ObjectModel/GuidRepresentation.cs
+++ b/src/MongoDB.Bson/ObjectModel/GuidRepresentation.cs
@@ -19,7 +19,7 @@ namespace MongoDB.Bson
///
/// Represents the representation to use when converting a Guid to a BSON binary value.
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public enum GuidRepresentation
diff --git a/src/MongoDB.Bson/ObjectModel/ObjectId.cs b/src/MongoDB.Bson/ObjectModel/ObjectId.cs
index 8f96fcfd61a..1b7ee4ea9c0 100644
--- a/src/MongoDB.Bson/ObjectModel/ObjectId.cs
+++ b/src/MongoDB.Bson/ObjectModel/ObjectId.cs
@@ -24,7 +24,7 @@ namespace MongoDB.Bson
///
/// Represents an ObjectId (see also BsonObjectId).
///
-#if NET452
+#if NET452 || NETSTANDARD2_0
[Serializable]
#endif
public struct ObjectId : IComparable, IEquatable, IConvertible
diff --git a/src/MongoDB.Bson/Serialization/BsonClassMap.cs b/src/MongoDB.Bson/Serialization/BsonClassMap.cs
index a970a2fa8a4..9cb50e4d56d 100644
--- a/src/MongoDB.Bson/Serialization/BsonClassMap.cs
+++ b/src/MongoDB.Bson/Serialization/BsonClassMap.cs
@@ -419,7 +419,7 @@ public static void RegisterClassMap(BsonClassMap classMap)
// private static methods
private static Type GetFormatterServicesType()
{
-#if NET452
+#if NET452 || NETSTANDARD2_0
return typeof(FormatterServices);
#else
// TODO: once we depend on newer versions of .NET Standard we should be able to do this without reflection
diff --git a/src/MongoDB.Bson/Serialization/BsonSerializer.cs b/src/MongoDB.Bson/Serialization/BsonSerializer.cs
index faf74dcbfda..e4ded8fcc41 100644
--- a/src/MongoDB.Bson/Serialization/BsonSerializer.cs
+++ b/src/MongoDB.Bson/Serialization/BsonSerializer.cs
@@ -693,7 +693,7 @@ internal static void EnsureKnownTypesAreRegistered(Type nominalType)
if (!__typesWithRegisteredKnownTypes.Contains(nominalType))
{
// only call LookupClassMap for classes with a BsonKnownTypesAttribute
-#if NET452
+#if NET452 || NETSTANDARD2_0
var knownTypesAttribute = nominalType.GetTypeInfo().GetCustomAttributes(typeof(BsonKnownTypesAttribute), false);
#else
var knownTypesAttribute = nominalType.GetTypeInfo().GetCustomAttributes(typeof(BsonKnownTypesAttribute), false).ToArray();
diff --git a/src/MongoDB.Bson/Serialization/Serializers/BsonClassMapSerializer.cs b/src/MongoDB.Bson/Serialization/Serializers/BsonClassMapSerializer.cs
index 5c0520043bc..69e88bdfa6d 100644
--- a/src/MongoDB.Bson/Serialization/Serializers/BsonClassMapSerializer.cs
+++ b/src/MongoDB.Bson/Serialization/Serializers/BsonClassMapSerializer.cs
@@ -155,7 +155,7 @@ public TClass DeserializeClass(BsonDeserializationContext context)
Dictionary values = null;
var document = default(TClass);
-#if NET452
+#if NET452 || NETSTANDARD2_0
ISupportInitialize supportsInitialization = null;
#endif
if (_classMap.HasCreatorMaps)
@@ -168,7 +168,7 @@ public TClass DeserializeClass(BsonDeserializationContext context)
// for mutable classes we deserialize the values directly into the result object
document = (TClass)_classMap.CreateInstance();
-#if NET452
+#if NET452 || NETSTANDARD2_0
supportsInitialization = document as ISupportInitialize;
if (supportsInitialization != null)
{
@@ -319,7 +319,7 @@ public TClass DeserializeClass(BsonDeserializationContext context)
if (document != null)
{
-#if NET452
+#if NET452 || NETSTANDARD2_0
if (supportsInitialization != null)
{
supportsInitialization.EndInit();
@@ -471,7 +471,7 @@ private TClass CreateInstanceUsingCreator(Dictionary values)
var creatorMap = ChooseBestCreator(values);
var document = creatorMap.CreateInstance(values); // removes values consumed
-#if NET452
+#if NET452 || NETSTANDARD2_0
var supportsInitialization = document as ISupportInitialize;
if (supportsInitialization != null)
{
@@ -491,7 +491,7 @@ private TClass CreateInstanceUsingCreator(Dictionary values)
}
}
-#if NET452
+#if NET452 || NETSTANDARD2_0
if (supportsInitialization != null)
{
supportsInitialization.EndInit();
diff --git a/src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj b/src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj
index 14c86725f75..017d340febe 100644
--- a/src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj
+++ b/src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj
@@ -1,7 +1,7 @@
- netstandard1.5;net452
+ netstandard2.0;netstandard1.5;net452
7.3
true
diff --git a/src/MongoDB.Driver.GridFS/MongoDB.Driver.GridFS.csproj b/src/MongoDB.Driver.GridFS/MongoDB.Driver.GridFS.csproj
index 76b94d72542..91c4e2bc24f 100644
--- a/src/MongoDB.Driver.GridFS/MongoDB.Driver.GridFS.csproj
+++ b/src/MongoDB.Driver.GridFS/MongoDB.Driver.GridFS.csproj
@@ -1,7 +1,7 @@
- netstandard1.5;net452
+ netstandard2.0;netstandard1.5;net452
7.3
true
diff --git a/src/MongoDB.Driver.Legacy/MongoDB.Driver.Legacy.csproj b/src/MongoDB.Driver.Legacy/MongoDB.Driver.Legacy.csproj
index c67db6af003..48178d10357 100644
--- a/src/MongoDB.Driver.Legacy/MongoDB.Driver.Legacy.csproj
+++ b/src/MongoDB.Driver.Legacy/MongoDB.Driver.Legacy.csproj
@@ -1,7 +1,7 @@
- netstandard1.5;net452
+ netstandard2.0;netstandard1.5;net452
7.3
true
diff --git a/src/MongoDB.Driver/MongoDB.Driver.csproj b/src/MongoDB.Driver/MongoDB.Driver.csproj
index 96f4583d0f0..f886f73c4ae 100644
--- a/src/MongoDB.Driver/MongoDB.Driver.csproj
+++ b/src/MongoDB.Driver/MongoDB.Driver.csproj
@@ -1,7 +1,7 @@
- netstandard1.5;net452
+ netstandard2.0;netstandard1.5;net452
7.3
true
diff --git a/tests/MongoDB.Bson.TestHelpers/MongoDB.Bson.TestHelpers.csproj b/tests/MongoDB.Bson.TestHelpers/MongoDB.Bson.TestHelpers.csproj
index f019083b447..2a3262551c5 100644
--- a/tests/MongoDB.Bson.TestHelpers/MongoDB.Bson.TestHelpers.csproj
+++ b/tests/MongoDB.Bson.TestHelpers/MongoDB.Bson.TestHelpers.csproj
@@ -1,7 +1,7 @@
- netstandard1.5;net452
+ netstandard2.0;netstandard1.5;net452
7.3
true
diff --git a/tests/MongoDB.Driver.Core.TestHelpers/MongoDB.Driver.Core.TestHelpers.csproj b/tests/MongoDB.Driver.Core.TestHelpers/MongoDB.Driver.Core.TestHelpers.csproj
index 51010849c8f..8301938b896 100644
--- a/tests/MongoDB.Driver.Core.TestHelpers/MongoDB.Driver.Core.TestHelpers.csproj
+++ b/tests/MongoDB.Driver.Core.TestHelpers/MongoDB.Driver.Core.TestHelpers.csproj
@@ -1,7 +1,7 @@
- netstandard1.5;net452
+ netstandard2.0;netstandard1.5;net452
7.3
true
diff --git a/tests/MongoDB.Driver.Legacy.TestHelpers/MongoDB.Driver.Legacy.TestHelpers.csproj b/tests/MongoDB.Driver.Legacy.TestHelpers/MongoDB.Driver.Legacy.TestHelpers.csproj
index 850d529ac46..58a9b22433e 100644
--- a/tests/MongoDB.Driver.Legacy.TestHelpers/MongoDB.Driver.Legacy.TestHelpers.csproj
+++ b/tests/MongoDB.Driver.Legacy.TestHelpers/MongoDB.Driver.Legacy.TestHelpers.csproj
@@ -1,7 +1,7 @@
- netstandard1.5;net452
+ netstandard2.0;netstandard1.5;net452
7.3
true
diff --git a/tests/MongoDB.Driver.TestHelpers/MongoDB.Driver.TestHelpers.csproj b/tests/MongoDB.Driver.TestHelpers/MongoDB.Driver.TestHelpers.csproj
index 3d7ad309e88..acbec771991 100644
--- a/tests/MongoDB.Driver.TestHelpers/MongoDB.Driver.TestHelpers.csproj
+++ b/tests/MongoDB.Driver.TestHelpers/MongoDB.Driver.TestHelpers.csproj
@@ -1,7 +1,7 @@
- netstandard1.5;net452
+ netstandard2.0;netstandard1.5;net452
7.3
true