Skip to content

Commit 0f872da

Browse files
committed
Fix code formatting in the SubqueryDefaultResultRewriter class
1 parent 7443e5a commit 0f872da

1 file changed

Lines changed: 18 additions & 27 deletions

File tree

Orm/Xtensive.Orm/Orm/Linq/Rewriters/SubqueryDefaultResultRewriter.cs

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,65 +13,56 @@ namespace Xtensive.Orm.Linq.Rewriters
1313
{
1414
internal sealed class SubqueryDefaultResultRewriter : ExpressionVisitor
1515
{
16-
private readonly Expression root;
17-
18-
protected override Expression VisitUnknown(Expression e)
19-
{
20-
return e;
21-
}
16+
protected override Expression VisitUnknown(Expression e) => e;
2217

2318
protected override Expression VisitBinary(BinaryExpression b)
2419
{
2520
var left = ApplyCorrection(Visit(b.Left));
2621
var right = ApplyCorrection(Visit(b.Right));
2722

28-
if (b.Left==left && b.Right==right)
23+
if (b.Left == left && b.Right == right) {
2924
return b;
25+
}
3026

3127
return Expression.MakeBinary(b.NodeType, left, right, b.IsLiftedToNull, b.Method);
3228
}
3329

34-
private Expression ApplyCorrection(Expression originalExpression)
30+
private static Expression ApplyCorrection(Expression originalExpression)
3531
{
3632
var expression = originalExpression;
37-
if (expression.NodeType==ExpressionType.Convert)
33+
if (expression.NodeType == ExpressionType.Convert) {
3834
expression = ((UnaryExpression) expression).Operand;
35+
}
3936

4037
var methodCall = expression as MethodCallExpression;
41-
if (methodCall==null || !IsDefaultingMethod(methodCall.Method) || !HasNonNullDefault(methodCall.Type))
38+
if (methodCall == null || !IsDefaultingMethod(methodCall.Method) || !HasNonNullDefault(methodCall.Type)) {
4239
return originalExpression;
40+
}
4341

4442
var methodReturnType = methodCall.Type;
4543
expression = Expression.Coalesce(
4644
Expression.Convert(expression, methodReturnType.ToNullable()),
4745
Expression.Constant(Activator.CreateInstance(methodReturnType)));
4846

49-
if (expression.Type!=originalExpression.Type)
47+
if (expression.Type != originalExpression.Type) {
5048
expression = Expression.Convert(expression, originalExpression.Type);
49+
}
5150

5251
return expression;
5352
}
5453

55-
private bool HasNonNullDefault(Type type)
56-
{
57-
return type.IsValueType && !type.IsNullable();
58-
}
54+
private static bool HasNonNullDefault(Type type) => type.IsValueType && !type.IsNullable();
5955

60-
private bool IsDefaultingMethod(MethodInfo method)
61-
{
62-
return method.DeclaringType==WellKnownTypes.Queryable
63-
&& (method.Name==nameof(Queryable.FirstOrDefault)
64-
|| method.Name==nameof(Queryable.SingleOrDefault));
65-
}
56+
private static bool IsDefaultingMethod(MethodInfo method) =>
57+
method.DeclaringType == WellKnownTypes.Queryable
58+
&& (method.Name == nameof(Queryable.FirstOrDefault)
59+
|| method.Name == nameof(Queryable.SingleOrDefault));
6660

67-
public static Expression Rewrite(Expression expression)
68-
{
69-
return new SubqueryDefaultResultRewriter(expression).Visit(expression);
70-
}
61+
public static Expression Rewrite(Expression expression) =>
62+
new SubqueryDefaultResultRewriter().Visit(expression);
7163

72-
private SubqueryDefaultResultRewriter(Expression root)
64+
private SubqueryDefaultResultRewriter()
7365
{
74-
this.root = root;
7566
}
7667
}
7768
}

0 commit comments

Comments
 (0)