Skip to content

Commit 5c54752

Browse files
committed
CSHARP-5137: Coverity analysis defect 127478: Null value leads to thrown exception.
1 parent abbd53d commit 5c54752

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/MongoDB.Driver/Linq/Linq3Implementation/Ast/Expressions/AstSortArrayExpression.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ public AstSortArrayExpression Update(AstExpression input, AstSortFields fields,
6767
return this;
6868
}
6969

70-
if (fields != null && order != null)
70+
return (fields, order) switch
7171
{
72-
throw new ArgumentException("fields and order arguments are mutually exclusive.");
73-
}
74-
75-
return order == null ? new AstSortArrayExpression(input, fields) : new AstSortArrayExpression(input, order);
72+
(null, null) => throw new ArgumentException("fields and order arguments cannot both be null."),
73+
(_, null) => new AstSortArrayExpression(input, fields),
74+
(null, _) => new AstSortArrayExpression(input, order),
75+
(_, _) => throw new ArgumentException("fields and order arguments are mutually exclusive.")
76+
};
7677
}
7778
}
7879
}

0 commit comments

Comments
 (0)