Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
Fixes #28964
  • Loading branch information
ajcvickers committed Sep 7, 2022
1 parent d67de27 commit 8fdd61c
Show file tree
Hide file tree
Showing 664 changed files with 4,571 additions and 4,169 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">HINT</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">TargetTyped</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
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected override void ApplySortCore(PropertyDescriptor prop, ListSortDirection
_sortDirection = direction;
_sortProperty = prop;
_isSorted = true;
OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
OnListChanged(new(ListChangedType.Reset, -1));
}
}

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 @@ -79,7 +79,7 @@ public static DbContextOptionsBuilder UseCosmos(

((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);

cosmosOptionsAction?.Invoke(new CosmosDbContextOptionsBuilder(optionsBuilder));
cosmosOptionsAction?.Invoke(new(optionsBuilder));

return optionsBuilder;
}
Expand Down Expand Up @@ -147,7 +147,7 @@ public static DbContextOptionsBuilder UseCosmos(

((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);

cosmosOptionsAction?.Invoke(new CosmosDbContextOptionsBuilder(optionsBuilder));
cosmosOptionsAction?.Invoke(new(optionsBuilder));

return optionsBuilder;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ public static DbContextOptionsBuilder UseCosmos(

((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);

cosmosOptionsAction?.Invoke(new CosmosDbContextOptionsBuilder(optionsBuilder));
cosmosOptionsAction?.Invoke(new(optionsBuilder));

return optionsBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,21 @@ 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))
{
mappedTypes = new List<IEntityType>();
mappedTypes = new();
containers[container] = 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
Expand Up @@ -59,7 +59,7 @@ public static ModelBuilder CreateModelBuilder()
{
using var serviceScope = CreateServiceScope();
using var context = serviceScope.ServiceProvider.GetRequiredService<DbContext>();
return new ModelBuilder(ConventionSet.CreateConventionSet(context), context.GetService<ModelDependencies>());
return new(ConventionSet.CreateConventionSet(context), context.GetService<ModelDependencies>());
}

private static IServiceScope CreateServiceScope()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public virtual CollectionShaperExpression Update(
Check.NotNull(innerShaper, nameof(innerShaper));

return projection != Projection || innerShaper != InnerShaper
? new CollectionShaperExpression(projection, innerShaper, Navigation, ElementType)
? new(projection, innerShaper, Navigation, ElementType)
: this;
}

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 Expand Up @@ -57,7 +57,7 @@ public virtual Expression Translate(SelectExpression selectExpression, Expressio
_selectExpression = selectExpression;
_clientEval = false;

_projectionMembers.Push(new ProjectionMember());
_projectionMembers.Push(new());

var result = Visit(expression);
if (result == null)
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 Expand Up @@ -40,13 +40,13 @@ public CosmosQueryableMethodTranslatingExpressionVisitor(
_sqlExpressionFactory = sqlExpressionFactory;
_memberTranslatorProvider = memberTranslatorProvider;
_methodCallTranslatorProvider = methodCallTranslatorProvider;
_sqlTranslator = new CosmosSqlTranslatingExpressionVisitor(
_sqlTranslator = new(
queryCompilationContext,
_sqlExpressionFactory,
_memberTranslatorProvider,
_methodCallTranslatorProvider);
_projectionBindingExpressionVisitor =
new CosmosProjectionBindingExpressionVisitor(_queryCompilationContext.Model, _sqlTranslator);
new(_queryCompilationContext.Model, _sqlTranslator);
}

/// <summary>
Expand All @@ -61,13 +61,13 @@ protected CosmosQueryableMethodTranslatingExpressionVisitor(
{
_queryCompilationContext = parentVisitor._queryCompilationContext;
_sqlExpressionFactory = parentVisitor._sqlExpressionFactory;
_sqlTranslator = new CosmosSqlTranslatingExpressionVisitor(
_sqlTranslator = new(
QueryCompilationContext,
_sqlExpressionFactory,
_memberTranslatorProvider,
_methodCallTranslatorProvider);
_projectionBindingExpressionVisitor =
new CosmosProjectionBindingExpressionVisitor(_queryCompilationContext.Model, _sqlTranslator);
new(_queryCompilationContext.Model, _sqlTranslator);
}

/// <summary>
Expand Down Expand Up @@ -271,7 +271,7 @@ protected override ShapedQueryExpression TranslateAverage(ShapedQueryExpression
source = TranslateSelect(source, selector);
}

var projection = (SqlExpression)selectExpression.GetMappedProjection(new ProjectionMember());
var projection = (SqlExpression)selectExpression.GetMappedProjection(new());
projection = _sqlExpressionFactory.Function(
"AVG", new[] { projection }, projection.Type, projection.TypeMapping);

Expand Down Expand Up @@ -575,7 +575,7 @@ protected override ShapedQueryExpression TranslateMax(ShapedQueryExpression sour
source = TranslateSelect(source, selector);
}

var projection = (SqlExpression)selectExpression.GetMappedProjection(new ProjectionMember());
var projection = (SqlExpression)selectExpression.GetMappedProjection(new());

projection = _sqlExpressionFactory.Function("MAX", new[] { projection }, resultType, projection.TypeMapping);

Expand Down Expand Up @@ -603,7 +603,7 @@ protected override ShapedQueryExpression TranslateMin(ShapedQueryExpression sour
source = TranslateSelect(source, selector);
}

var projection = (SqlExpression)selectExpression.GetMappedProjection(new ProjectionMember());
var projection = (SqlExpression)selectExpression.GetMappedProjection(new());

projection = _sqlExpressionFactory.Function("MIN", new[] { projection }, resultType, projection.TypeMapping);

Expand Down Expand Up @@ -682,7 +682,7 @@ protected override ShapedQueryExpression TranslateOrderBy(
var translation = TranslateLambdaExpression(source, keySelector);
if (translation != null)
{
((SelectExpression)source.QueryExpression).ApplyOrdering(new OrderingExpression(translation, ascending));
((SelectExpression)source.QueryExpression).ApplyOrdering(new(translation, ascending));

return source;
}
Expand Down Expand Up @@ -841,7 +841,7 @@ protected override ShapedQueryExpression TranslateSum(ShapedQueryExpression sour
}

var serverOutputType = resultType.UnwrapNullableType();
var projection = (SqlExpression)selectExpression.GetMappedProjection(new ProjectionMember());
var projection = (SqlExpression)selectExpression.GetMappedProjection(new());

projection = _sqlExpressionFactory.Function(
"SUM", new[] { projection }, serverOutputType, projection.TypeMapping);
Expand Down Expand Up @@ -895,7 +895,7 @@ protected override ShapedQueryExpression TranslateThenBy(ShapedQueryExpression s
var translation = TranslateLambdaExpression(source, keySelector);
if (translation != null)
{
((SelectExpression)source.QueryExpression).AppendOrdering(new OrderingExpression(translation, ascending));
((SelectExpression)source.QueryExpression).AppendOrdering(new(translation, ascending));

return source;
}
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 @@ -330,7 +330,7 @@ private BlockExpression AddIncludes(BlockExpression shaperBlock)
shaperExpressions.RemoveAt(shaperExpressions.Count - 1);

var includesToProcess = _pendingIncludes;
_pendingIncludes = new List<IncludeExpression>();
_pendingIncludes = new();

foreach (var include in includesToProcess)
{
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
Loading

0 comments on commit 8fdd61c

Please sign in to comment.