Skip to content

Commit aa842e9

Browse files
author
rstam
committed
CSHARP-767: Changed new SetDefaultValue overload to check if the member map is frozen.
1 parent 934b076 commit aa842e9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

MongoDB.Bson/Serialization/BsonMemberMap.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,11 @@ public BsonMemberMap Reset()
338338
/// <returns>The member map.</returns>
339339
public BsonMemberMap SetDefaultValue(Func<object> defaultValueCreator)
340340
{
341+
if (defaultValueCreator == null)
342+
{
343+
throw new ArgumentNullException("defaultValueCreator");
344+
}
345+
if (_frozen) { ThrowFrozenException(); }
341346
_defaultValue = defaultValueCreator(); // need an instance to compare against
342347
_defaultValueCreator = defaultValueCreator;
343348
_defaultValueSpecified = true;

0 commit comments

Comments
 (0)