Skip to content

Commit

Permalink
Code cleanup (#29012)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajcvickers authored Sep 9, 2022
1 parent a7b82d0 commit 9262a34
Show file tree
Hide file tree
Showing 449 changed files with 3,192 additions and 2,785 deletions.
10 changes: 6 additions & 4 deletions All.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeModifiersOrder/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeNamespaceBody/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeObjectCreationWhenTypeEvident/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeRedundantParentheses/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeTypeMemberModifiers/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeTypeModifiers/@EntryIndexedValue">WARNING</s:String>
Expand Down Expand Up @@ -49,16 +50,16 @@
&amp;lt;inspection_tool class="WrongPropertyKeyValueDelimiter" enabled="false" level="WEAK WARNING" enabled_by_default="false" /&amp;gt;&#xD;
&amp;lt;/profile&amp;gt;&lt;/IDEA_SETTINGS&gt;&lt;RIDER_SETTINGS&gt;&amp;lt;profile&amp;gt;&#xD;
&amp;lt;Language id="CSS"&amp;gt;&#xD;
&amp;lt;Reformat&amp;gt;false&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;Rearrange&amp;gt;false&amp;lt;/Rearrange&amp;gt;&#xD;
&amp;lt;Reformat&amp;gt;false&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;/Language&amp;gt;&#xD;
&amp;lt;Language id="EditorConfig"&amp;gt;&#xD;
&amp;lt;Reformat&amp;gt;false&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;/Language&amp;gt;&#xD;
&amp;lt;Language id="HTML"&amp;gt;&#xD;
&amp;lt;Rearrange&amp;gt;false&amp;lt;/Rearrange&amp;gt;&#xD;
&amp;lt;Reformat&amp;gt;false&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;OptimizeImports&amp;gt;false&amp;lt;/OptimizeImports&amp;gt;&#xD;
&amp;lt;Rearrange&amp;gt;false&amp;lt;/Rearrange&amp;gt;&#xD;
&amp;lt;/Language&amp;gt;&#xD;
&amp;lt;Language id="HTTP Request"&amp;gt;&#xD;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;&#xD;
Expand All @@ -76,9 +77,9 @@
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;/Language&amp;gt;&#xD;
&amp;lt;Language id="JavaScript"&amp;gt;&#xD;
&amp;lt;Rearrange&amp;gt;false&amp;lt;/Rearrange&amp;gt;&#xD;
&amp;lt;Reformat&amp;gt;false&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;OptimizeImports&amp;gt;false&amp;lt;/OptimizeImports&amp;gt;&#xD;
&amp;lt;Rearrange&amp;gt;false&amp;lt;/Rearrange&amp;gt;&#xD;
&amp;lt;/Language&amp;gt;&#xD;
&amp;lt;Language id="Markdown"&amp;gt;&#xD;
&amp;lt;Reformat&amp;gt;false&amp;lt;/Reformat&amp;gt;&#xD;
Expand All @@ -93,9 +94,9 @@
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;/Language&amp;gt;&#xD;
&amp;lt;Language id="XML"&amp;gt;&#xD;
&amp;lt;Rearrange&amp;gt;false&amp;lt;/Rearrange&amp;gt;&#xD;
&amp;lt;Reformat&amp;gt;false&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;OptimizeImports&amp;gt;false&amp;lt;/OptimizeImports&amp;gt;&#xD;
&amp;lt;Rearrange&amp;gt;false&amp;lt;/Rearrange&amp;gt;&#xD;
&amp;lt;/Language&amp;gt;&#xD;
&amp;lt;Language id="yaml"&amp;gt;&#xD;
&amp;lt;Reformat&amp;gt;false&amp;lt;/Reformat&amp;gt;&#xD;
Expand All @@ -110,6 +111,7 @@
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOREACH/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_IFELSE/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_WHILE/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/OBJECT_CREATION_WHEN_TYPE_NOT_EVIDENT/@EntryValue">ExplicitlyTyped</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_LINQ_QUERY/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_ARGUMENT/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_ARRAY_AND_OBJECT_INITIALIZER/@EntryValue">False</s:Boolean>
Expand Down
6 changes: 4 additions & 2 deletions src/EFCore.Abstractions/DeleteBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public enum DeleteBehavior
ClientCascade,

/// <summary>
/// For entities being tracked by the context, the values of foreign key properties in dependent entities are set to null when the related principal is deleted.
/// For entities being tracked by the context, the values of foreign key properties in dependent entities are set to null when the related
/// principal is deleted.
/// This helps keep the graph of entities in a consistent state while they are being tracked, such that a
/// fully consistent graph can then be written to the database. If a property cannot be set to null because
/// it is not a nullable type, then an exception will be thrown when
Expand All @@ -126,7 +127,8 @@ public enum DeleteBehavior
/// </summary>
/// <remarks>
/// <para>
/// For entities being tracked by the context, the values of foreign key properties in dependent entities are not changed when the related principal entity is deleted.
/// For entities being tracked by the context, the values of foreign key properties in dependent entities are not changed when the
/// related principal entity is deleted.
/// This can result in an inconsistent graph of entities where the values of foreign key properties do
/// not match the relationships in the graph.
/// </para>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Abstractions/DeleteBehaviorAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed class DeleteBehaviorAttribute : Attribute
/// <param name="behavior">The <see cref="DeleteBehavior" /> to be configured.</param>
public DeleteBehaviorAttribute(DeleteBehavior behavior)
{
this.Behavior = behavior;
Behavior = behavior;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;

namespace Microsoft.EntityFrameworkCore.Cosmos.ChangeTracking.Internal;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;

namespace Microsoft.EntityFrameworkCore.Cosmos.ChangeTracking.Internal;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ protected virtual void ValidateSharedContainerCompatibility(
var ownership = entityType.FindOwnership();
if (ownership != null)
{
throw new InvalidOperationException(CosmosStrings.OwnedTypeDifferentContainer(
entityType.DisplayName(), ownership.PrincipalEntityType.DisplayName(), container));
throw new InvalidOperationException(
CosmosStrings.OwnedTypeDifferentContainer(
entityType.DisplayName(), ownership.PrincipalEntityType.DisplayName(), container));
}

if (entityType.GetContainingPropertyName() != null)
{
throw new InvalidOperationException(CosmosStrings.ContainerContainingPropertyConflict(
entityType.DisplayName(), container, entityType.GetContainingPropertyName()));
throw new InvalidOperationException(
CosmosStrings.ContainerContainingPropertyConflict(
entityType.DisplayName(), container, entityType.GetContainingPropertyName()));
}

if (!containers.TryGetValue(container, out var mappedTypes))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore.Metadata.Internal;

// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore.Metadata.Conventions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

// ReSharper disable once CheckNamespace

namespace Microsoft.EntityFrameworkCore.Metadata.Conventions;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal;

#nullable enable

using Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal;

namespace Microsoft.EntityFrameworkCore.Metadata.Conventions;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.EntityFrameworkCore.Cosmos.Internal;

#nullable disable

using Microsoft.EntityFrameworkCore.Cosmos.Internal;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore.Cosmos/Query/Internal/CosmosRegexTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public CosmosRegexTranslator(ISqlExpressionFactory sqlExpressionFactory)
return regexOptions == 0
? _sqlExpressionFactory.Function(
"RegexMatch",
new[] { input, pattern, _sqlExpressionFactory.Constant(modifier) },
typeof(bool))
new[] { input, pattern, _sqlExpressionFactory.Constant(modifier) },
typeof(bool))
: null; // TODO: Report unsupported RegexOption, #26410
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Newtonsoft.Json.Linq;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

public partial class CosmosShapedQueryCompilingExpressionVisitor
Expand Down Expand Up @@ -703,7 +703,7 @@ var body
}

Expression replaceExpression;
if (converter.ConvertsNulls == true)
if (converter.ConvertsNulls)
{
replaceExpression = ReplacingExpressionVisitor.Replace(
converter.ConvertFromProviderExpression.Parameters.Single(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;

#nullable disable

using System.Collections;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

public partial class CosmosShapedQueryCompilingExpressionVisitor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using Microsoft.EntityFrameworkCore.Query.Internal;
using Newtonsoft.Json.Linq;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

public partial class CosmosShapedQueryCompilingExpressionVisitor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using System.Collections;
using System.Text;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal;
using Newtonsoft.Json.Linq;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using System.Collections;
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
using Microsoft.EntityFrameworkCore.Internal;
using Newtonsoft.Json.Linq;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Newtonsoft.Json.Linq;

#nullable disable

using Newtonsoft.Json.Linq;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using System.Collections;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;

#nullable disable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

/// <summary>
Expand Down Expand Up @@ -33,7 +33,7 @@ private static readonly MethodInfo StringEqualsWithStringComparison
private static readonly MethodInfo StringEqualsWithStringComparisonStatic
= typeof(string).GetRuntimeMethod(nameof(string.Equals), new[] { typeof(string), typeof(string), typeof(StringComparison) });

private static readonly MethodInfo GetTypeMethodInfo = typeof(object).GetTypeInfo().GetDeclaredMethod(nameof(object.GetType))!;
private static readonly MethodInfo GetTypeMethodInfo = typeof(object).GetTypeInfo().GetDeclaredMethod(nameof(GetType))!;

private readonly QueryCompilationContext _queryCompilationContext;
private readonly IModel _model;
Expand Down Expand Up @@ -147,7 +147,8 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression)
ifFalse));
}

if (binaryExpression.NodeType == ExpressionType.Equal || binaryExpression.NodeType == ExpressionType.NotEqual
if (binaryExpression.NodeType == ExpressionType.Equal
|| binaryExpression.NodeType == ExpressionType.NotEqual
&& binaryExpression.Left.Type == typeof(Type))
{
if (IsGetTypeMethodCall(binaryExpression.Left, out var entityReference1)
Expand Down Expand Up @@ -247,7 +248,7 @@ Expression ProcessGetType(EntityReferenceExpression entityReferenceExpression, T
// Or add predicate for matching that particular type discriminator value
// All hierarchies have discriminator property
if (TryBindMember(entityReferenceExpression, MemberIdentity.Create(entityType.GetDiscriminatorPropertyName()))
is SqlExpression discriminatorColumn)
is SqlExpression discriminatorColumn)
{
return match
? _sqlExpressionFactory.Equal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,23 @@ public CosmosStringMethodTranslator(ISqlExpressionFactory sqlExpressionFactory)
return TranslateSystemFunction("UPPER", method.ReturnType, instance);
}

if (TrimStartMethodInfoWithoutArgs.Equals(method) == true
if (TrimStartMethodInfoWithoutArgs.Equals(method)
|| (TrimStartMethodInfoWithCharArrayArg.Equals(method)
// Cosmos DB LTRIM does not take arguments
&& ((arguments[0] as SqlConstantExpression)?.Value as Array)?.Length == 0))
{
return TranslateSystemFunction("LTRIM", method.ReturnType, instance);
}

if (TrimEndMethodInfoWithoutArgs.Equals(method) == true
if (TrimEndMethodInfoWithoutArgs.Equals(method)
|| (TrimEndMethodInfoWithCharArrayArg.Equals(method)
// Cosmos DB RTRIM does not take arguments
&& ((arguments[0] as SqlConstantExpression)?.Value as Array)?.Length == 0))
{
return TranslateSystemFunction("RTRIM", method.ReturnType, instance);
}

if (TrimMethodInfoWithoutArgs.Equals(method) == true
if (TrimMethodInfoWithoutArgs.Equals(method)
|| (TrimMethodInfoWithCharArrayArg.Equals(method)
// Cosmos DB TRIM does not take arguments
&& ((arguments[0] as SqlConstantExpression)?.Value as Array)?.Length == 0))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.EntityFrameworkCore.Cosmos.Internal;

#nullable disable

using Microsoft.EntityFrameworkCore.Cosmos.Internal;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore.Cosmos/Query/Internal/ObjectAccessExpression.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.EntityFrameworkCore.Cosmos.Internal;

#nullable disable

using Microsoft.EntityFrameworkCore.Cosmos.Internal;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

/// <summary>
Expand Down
Loading

0 comments on commit 9262a34

Please sign in to comment.