Skip to content

Commit 631be11

Browse files
committed
CSHARP-5628: Requested changes.
1 parent 56a5854 commit 631be11

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/MongoDB.Driver/Linq/Linq3Implementation/Misc/PartialEvaluator.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public override Expression Visit(Expression expression)
7676
protected override Expression VisitBinary(BinaryExpression node)
7777
{
7878
var leftExpression = node.Left;
79-
var rightExpression = node.Right;
79+
var rightExpression = node.Right;
8080

8181
if (leftExpression.Type == typeof(bool) && rightExpression.Type == typeof(bool))
8282
{
@@ -138,7 +138,7 @@ protected override Expression VisitConditional(ConditionalExpression node)
138138
}
139139

140140
var ifTrue = Visit(node.IfTrue);
141-
var ifFalse = Visit(node.IfFalse);
141+
var ifFalse = Visit(node.IfFalse);
142142

143143
if (BothAreConstant<bool>(ifTrue, ifFalse, out var ifTrueValue, out var ifFalseValue))
144144
{
@@ -155,16 +155,16 @@ protected override Expression VisitConditional(ConditionalExpression node)
155155
// T ? true : Q => T || Q
156156
// T ? false : Q => !T && Q
157157
return ifTrueValue
158-
? Visit(Expression.Or(test, ifFalse))
159-
: Visit(Expression.And(Expression.Not(test), ifFalse));
158+
? Visit(Expression.OrElse(test, ifFalse))
159+
: Visit(Expression.AndAlso(Expression.Not(test), ifFalse));
160160
}
161161
else if (IsConstant<bool>(ifFalse, out ifFalseValue))
162162
{
163163
// T ? P : true => !T || P
164164
// T ? P : false => T && P
165165
return ifFalseValue
166-
? Visit(Expression.Or(Expression.Not(test), ifTrue))
167-
: Visit(Expression.And(test, ifTrue));
166+
? Visit(Expression.OrElse(Expression.Not(test), ifTrue))
167+
: Visit(Expression.AndAlso(test, ifTrue));
168168
}
169169

170170
return node.Update(test, ifTrue, ifFalse);

tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Jira/CSharp5628Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void Where_simplifications_should_work(int testCase, string expectedStage
129129
var collection = Fixture.Collection;
130130

131131
// see: https://codeql.github.com/codeql-query-help/csharp/cs-simplifiable-boolean-expression/#recommendation
132-
// not all simplifciations listed there are safe for a database (because of possibly missing fields or tri-valued logic)
132+
// not all simplifications listed there are safe for a database (because of possibly missing fields or tri-valued logic)
133133
var queryable = testCase switch
134134
{
135135
1 => collection.AsQueryable().Where(x => x.P == true), // not safe

0 commit comments

Comments
 (0)