Skip to content

Commit 344bd71

Browse files
committed
add check for when BsonElement has no args, aka element name is null
1 parent 1dda26d commit 344bd71

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/MongoDB.Bson/Serialization/Conventions/NamedIdMemberConvention.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private bool IsValidIdMember(BsonClassMap classMap, MemberInfo member)
122122
}
123123

124124
var bsonElement = member.GetCustomAttribute<BsonElementAttribute>();
125-
if (bsonElement != null && bsonElement.ElementName != "_id")
125+
if (bsonElement != null && !string.IsNullOrEmpty(bsonElement.ElementName) && bsonElement.ElementName != "_id")
126126
{
127127
return false;
128128
}

0 commit comments

Comments
 (0)