Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unindent blocks within switch cases #17039

Merged
merged 1 commit into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ csharp_new_line_between_query_expression_clauses = true
# Identation options
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents_when_block = true
csharp_indent_case_contents_when_block = false
csharp_indent_switch_labels = true
csharp_indent_case_contents = true
csharp_indent_labels = no_change
Expand Down Expand Up @@ -253,4 +253,4 @@ dotnet_naming_symbols.everything_else.applicable_accessibilities = *

dotnet_naming_rule.everything_else_naming.symbols = everything_else
dotnet_naming_rule.everything_else_naming.style = camel_case_style
dotnet_naming_rule.everything_else_naming.severity = suggestion
dotnet_naming_rule.everything_else_naming.severity = suggestion
Original file line number Diff line number Diff line change
Expand Up @@ -303,19 +303,19 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
nullable: true);

case ObjectArrayProjectionExpression objectArrayProjectionExpression:
{
var innerShaperExpression = new EntityShaperExpression(
navigation.GetTargetType(),
Expression.Convert(
Expression.Convert(objectArrayProjectionExpression.InnerProjection, typeof(object)), typeof(ValueBuffer)),
nullable: true);

return new CollectionShaperExpression(
objectArrayProjectionExpression,
innerShaperExpression,
navigation,
innerShaperExpression.EntityType.ClrType);
}
{
var innerShaperExpression = new EntityShaperExpression(
navigation.GetTargetType(),
Expression.Convert(
Expression.Convert(objectArrayProjectionExpression.InnerProjection, typeof(object)), typeof(ValueBuffer)),
nullable: true);

return new CollectionShaperExpression(
objectArrayProjectionExpression,
innerShaperExpression,
navigation,
innerShaperExpression.EntityType.ClrType);
}

default:
throw new InvalidOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1056,39 +1056,39 @@ public override Expression Visit(Expression expression)
switch (inExpression.Values)
{
case SqlConstantExpression sqlConstant:
{
typeMapping = sqlConstant.TypeMapping;
var values = (IEnumerable)sqlConstant.Value;
foreach (var value in values)
{
typeMapping = sqlConstant.TypeMapping;
var values = (IEnumerable)sqlConstant.Value;
foreach (var value in values)
if (value == null)
{
if (value == null)
{
hasNullValue = true;
continue;
}

inValues.Add(value);
hasNullValue = true;
continue;
}

inValues.Add(value);
}
break;
}
break;

case SqlParameterExpression sqlParameter:
{
typeMapping = sqlParameter.TypeMapping;
var values = (IEnumerable)_parametersValues[sqlParameter.Name];
foreach (var value in values)
{
typeMapping = sqlParameter.TypeMapping;
var values = (IEnumerable)_parametersValues[sqlParameter.Name];
foreach (var value in values)
if (value == null)
{
if (value == null)
{
hasNullValue = true;
continue;
}

inValues.Add(value);
hasNullValue = true;
continue;
}

inValues.Add(value);
}
break;
}
}
break;
}

var updatedInExpression = inValues.Count > 0
? _sqlExpressionFactory.In(
Expand Down
38 changes: 19 additions & 19 deletions src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,22 @@ private SqlExpression ApplyTypeMappingOnSqlBinary(
case ExpressionType.LessThan:
case ExpressionType.LessThanOrEqual:
case ExpressionType.NotEqual:
{
inferredTypeMapping = ExpressionExtensions.InferTypeMapping(left, right)
?? _typeMappingSource.FindMapping(left.Type);
resultType = typeof(bool);
resultTypeMapping = _boolTypeMapping;
}
break;
{
inferredTypeMapping = ExpressionExtensions.InferTypeMapping(left, right)
?? _typeMappingSource.FindMapping(left.Type);
resultType = typeof(bool);
resultTypeMapping = _boolTypeMapping;
}
break;

case ExpressionType.AndAlso:
case ExpressionType.OrElse:
{
inferredTypeMapping = _boolTypeMapping;
resultType = typeof(bool);
resultTypeMapping = _boolTypeMapping;
}
break;
{
inferredTypeMapping = _boolTypeMapping;
resultType = typeof(bool);
resultTypeMapping = _boolTypeMapping;
}
break;

case ExpressionType.Add:
case ExpressionType.Subtract:
Expand All @@ -175,12 +175,12 @@ private SqlExpression ApplyTypeMappingOnSqlBinary(
case ExpressionType.Coalesce:
case ExpressionType.And:
case ExpressionType.Or:
{
inferredTypeMapping = typeMapping ?? ExpressionExtensions.InferTypeMapping(left, right);
resultType = left.Type;
resultTypeMapping = inferredTypeMapping;
}
break;
{
inferredTypeMapping = typeMapping ?? ExpressionExtensions.InferTypeMapping(left, right);
resultType = left.Type;
resultTypeMapping = inferredTypeMapping;
}
break;

default:
throw new InvalidOperationException("Incorrect operatorType for SqlBinaryExpression");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,13 @@ protected override Expression VisitExtension(Expression extensionExpression)
.GetMappedProjection(projectionBindingExpression.ProjectionMember);

case NullConditionalExpression nullConditionalExpression:
{
var translation = Visit(nullConditionalExpression.AccessOperation);
{
var translation = Visit(nullConditionalExpression.AccessOperation);

return translation.Type == nullConditionalExpression.Type
? translation
: Expression.Convert(translation, nullConditionalExpression.Type);
}
return translation.Type == nullConditionalExpression.Type
? translation
: Expression.Convert(translation, nullConditionalExpression.Type);
}

default:
throw new InvalidOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,32 +90,32 @@ public override Expression Visit(Expression expression)
throw new NotImplementedException();

case MethodCallExpression methodCallExpression:
{
if (methodCallExpression.Method.IsGenericMethod
&& methodCallExpression.Method.DeclaringType == typeof(Enumerable)
&& methodCallExpression.Method.Name == nameof(Enumerable.ToList))
{
if (methodCallExpression.Method.IsGenericMethod
&& methodCallExpression.Method.DeclaringType == typeof(Enumerable)
&& methodCallExpression.Method.Name == nameof(Enumerable.ToList))
{
//var elementType = methodCallExpression.Method.GetGenericArguments()[0];

//var result = _queryableMethodTranslatingExpressionVisitor.TranslateSubquery(methodCallExpression.Arguments[0]);

//return _selectExpression.AddCollectionProjection(result, null, elementType);
throw new NotImplementedException();
}

var subquery = _queryableMethodTranslatingExpressionVisitor.TranslateSubquery(methodCallExpression);

if (subquery != null)
{
//if (subquery.ResultType == ResultType.Enumerable)
//{
// return _selectExpression.AddCollectionProjection(subquery, null, subquery.ShaperExpression.Type);
//}
throw new NotImplementedException();
}

break;
//var elementType = methodCallExpression.Method.GetGenericArguments()[0];

//var result = _queryableMethodTranslatingExpressionVisitor.TranslateSubquery(methodCallExpression.Arguments[0]);

//return _selectExpression.AddCollectionProjection(result, null, elementType);
throw new NotImplementedException();
}

var subquery = _queryableMethodTranslatingExpressionVisitor.TranslateSubquery(methodCallExpression);

if (subquery != null)
{
//if (subquery.ResultType == ResultType.Enumerable)
//{
// return _selectExpression.AddCollectionProjection(subquery, null, subquery.ShaperExpression.Type);
//}
throw new NotImplementedException();
}

break;
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,38 @@ public override Expression Visit(Expression expression)
switch (inExpression.Values)
{
case SqlConstantExpression sqlConstant:
{
typeMapping = sqlConstant.TypeMapping;
var values = (IEnumerable)sqlConstant.Value;
foreach (var value in values)
{
typeMapping = sqlConstant.TypeMapping;
var values = (IEnumerable)sqlConstant.Value;
foreach (var value in values)
if (value == null)
{
if (value == null)
{
hasNullValue = true;
continue;
}

inValues.Add(value);
hasNullValue = true;
continue;
}

inValues.Add(value);
}
break;
}
break;

case SqlParameterExpression sqlParameter:
{
typeMapping = sqlParameter.TypeMapping;
var values = (IEnumerable)_parametersValues[sqlParameter.Name];
foreach (var value in values)
{
typeMapping = sqlParameter.TypeMapping;
var values = (IEnumerable)_parametersValues[sqlParameter.Name];
foreach (var value in values)
if (value == null)
{
if (value == null)
{
hasNullValue = true;
continue;
}

inValues.Add(value);
hasNullValue = true;
continue;
}

inValues.Add(value);
}
break;
}
break;
}

var updatedInExpression = inValues.Count > 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,30 @@ public override Expression Visit(Expression expression)
materializeCollectionNavigationExpression.Navigation, null);

case MethodCallExpression methodCallExpression:
{
if (methodCallExpression.Method.IsGenericMethod
&& methodCallExpression.Method.DeclaringType == typeof(Enumerable)
&& methodCallExpression.Method.Name == nameof(Enumerable.ToList))
{
if (methodCallExpression.Method.IsGenericMethod
&& methodCallExpression.Method.DeclaringType == typeof(Enumerable)
&& methodCallExpression.Method.Name == nameof(Enumerable.ToList))
{
var elementType = methodCallExpression.Method.GetGenericArguments()[0];
var elementType = methodCallExpression.Method.GetGenericArguments()[0];

var result = _queryableMethodTranslatingExpressionVisitor.TranslateSubquery(methodCallExpression.Arguments[0]);
var result = _queryableMethodTranslatingExpressionVisitor.TranslateSubquery(methodCallExpression.Arguments[0]);

return _selectExpression.AddCollectionProjection(result, null, elementType);
}
return _selectExpression.AddCollectionProjection(result, null, elementType);
}

var subquery = _queryableMethodTranslatingExpressionVisitor.TranslateSubquery(methodCallExpression);
var subquery = _queryableMethodTranslatingExpressionVisitor.TranslateSubquery(methodCallExpression);

if (subquery != null)
if (subquery != null)
{
if (subquery.ResultCardinality == ResultCardinality.Enumerable)
{
if (subquery.ResultCardinality == ResultCardinality.Enumerable)
{
return _selectExpression.AddCollectionProjection(subquery, null, subquery.ShaperExpression.Type);
}
return _selectExpression.AddCollectionProjection(subquery, null, subquery.ShaperExpression.Type);
}

break;
}

break;
}
}

var translation = _sqlTranslator.Translate(expression);
Expand Down
Loading