diff --git a/EFCore.sln.DotSettings b/EFCore.sln.DotSettings
index c3e0c3a37e2..d16183b5637 100644
--- a/EFCore.sln.DotSettings
+++ b/EFCore.sln.DotSettings
@@ -189,7 +189,9 @@ Licensed under the Apache License, Version 2.0. See License.txt in the project r
True
True
True
+ True
True
+ True
True
True
True
diff --git a/src/EFCore.Cosmos/Extensions/CosmosDbContextOptionsExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosDbContextOptionsExtensions.cs
index a601e17278c..100b5052fd9 100644
--- a/src/EFCore.Cosmos/Extensions/CosmosDbContextOptionsExtensions.cs
+++ b/src/EFCore.Cosmos/Extensions/CosmosDbContextOptionsExtensions.cs
@@ -8,6 +8,7 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Utilities;
+// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
public static class CosmosDbContextOptionsExtensions
diff --git a/src/EFCore.Cosmos/Extensions/CosmosLoggerExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosLoggerExtensions.cs
index 3112abd445e..9818b936200 100644
--- a/src/EFCore.Cosmos/Extensions/CosmosLoggerExtensions.cs
+++ b/src/EFCore.Cosmos/Extensions/CosmosLoggerExtensions.cs
@@ -13,6 +13,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
+// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
public static class CosmosLoggerExtensions
diff --git a/src/EFCore.Cosmos/Extensions/CosmosServiceCollectionExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosServiceCollectionExtensions.cs
index 1db2e9f123d..6fa0abd8bfc 100644
--- a/src/EFCore.Cosmos/Extensions/CosmosServiceCollectionExtensions.cs
+++ b/src/EFCore.Cosmos/Extensions/CosmosServiceCollectionExtensions.cs
@@ -19,6 +19,7 @@
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;
+// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.DependencyInjection
{
public static class CosmosServiceCollectionExtensions
diff --git a/src/EFCore.Design/Design/Internal/DbContextOperations.cs b/src/EFCore.Design/Design/Internal/DbContextOperations.cs
index 63ca474cdfa..5f339601cdd 100644
--- a/src/EFCore.Design/Design/Internal/DbContextOperations.cs
+++ b/src/EFCore.Design/Design/Internal/DbContextOperations.cs
@@ -8,6 +8,7 @@
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage;
diff --git a/src/EFCore.InMemory/Extensions/Internal/InMemoryLoggerExtensions.cs b/src/EFCore.InMemory/Diagnostics/Internal/InMemoryLoggerExtensions.cs
similarity index 100%
rename from src/EFCore.InMemory/Extensions/Internal/InMemoryLoggerExtensions.cs
rename to src/EFCore.InMemory/Diagnostics/Internal/InMemoryLoggerExtensions.cs
diff --git a/src/EFCore.InMemory/Query/Pipeline/InMemoryProjectionBindingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Pipeline/InMemoryProjectionBindingExpressionVisitor.cs
index 8d7d00cae06..eb69b794a49 100644
--- a/src/EFCore.InMemory/Query/Pipeline/InMemoryProjectionBindingExpressionVisitor.cs
+++ b/src/EFCore.InMemory/Query/Pipeline/InMemoryProjectionBindingExpressionVisitor.cs
@@ -5,7 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
+using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Query.Pipeline;
using Microsoft.EntityFrameworkCore.Storage;
diff --git a/src/EFCore.InMemory/Query/Pipeline/Translator.cs b/src/EFCore.InMemory/Query/Pipeline/Translator.cs
index 6fe1d97dcb1..aa17f646615 100644
--- a/src/EFCore.InMemory/Query/Pipeline/Translator.cs
+++ b/src/EFCore.InMemory/Query/Pipeline/Translator.cs
@@ -4,7 +4,7 @@
using System;
using System.Linq.Expressions;
using System.Reflection;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
+using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Query.Expressions.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
diff --git a/src/EFCore.Relational/Internal/MethodInfoExtensions.cs b/src/EFCore.Relational/Extensions/Internal/MethodInfoExtensions.cs
similarity index 100%
rename from src/EFCore.Relational/Internal/MethodInfoExtensions.cs
rename to src/EFCore.Relational/Extensions/Internal/MethodInfoExtensions.cs
diff --git a/src/EFCore.Relational/Extensions/RelationalTaskExtensions.cs b/src/EFCore.Relational/Extensions/RelationalTaskExtensions.cs
index d68c819f7b6..614e6d43e20 100644
--- a/src/EFCore.Relational/Extensions/RelationalTaskExtensions.cs
+++ b/src/EFCore.Relational/Extensions/RelationalTaskExtensions.cs
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+// ReSharper disable once CheckNamespace
namespace System.Threading.Tasks
{
internal static class RelationalTaskExtensions
diff --git a/src/EFCore.Relational/Internal/RelationalPropertyExtensions.cs b/src/EFCore.Relational/Internal/RelationalPropertyExtensions.cs
deleted file mode 100644
index 7de22ab9be0..00000000000
--- a/src/EFCore.Relational/Internal/RelationalPropertyExtensions.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Metadata;
-
-namespace Microsoft.EntityFrameworkCore.Internal
-{
- ///
- /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
- /// the same compatibility standards as public APIs. It may be changed or removed without notice in
- /// any release. You should only use it directly in your code with extreme caution and knowing that
- /// doing so can result in application failures when updating to a new Entity Framework Core release.
- ///
- public static class RelationalPropertyExtensions
- {
- ///
- /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
- /// the same compatibility standards as public APIs. It may be changed or removed without notice in
- /// any release. You should only use it directly in your code with extreme caution and knowing that
- /// doing so can result in application failures when updating to a new Entity Framework Core release.
- ///
- public static string FormatColumns([NotNull] this IEnumerable properties)
- => "{" + string.Join(", ", properties.Select(p => "'" + p.GetColumnName() + "'")) + "}";
-
- ///
- /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
- /// the same compatibility standards as public APIs. It may be changed or removed without notice in
- /// any release. You should only use it directly in your code with extreme caution and knowing that
- /// doing so can result in application failures when updating to a new Entity Framework Core release.
- ///
- [DebuggerStepThrough]
- public static string GetConfiguredColumnType([NotNull] this IProperty property)
- => (string)property[RelationalAnnotationNames.ColumnType];
- }
-}
diff --git a/src/EFCore.Relational/Metadata/Internal/RelationalPropertyExtensions.cs b/src/EFCore.Relational/Metadata/Internal/RelationalPropertyExtensions.cs
index dbdf7325e8a..f90d6577a36 100644
--- a/src/EFCore.Relational/Metadata/Internal/RelationalPropertyExtensions.cs
+++ b/src/EFCore.Relational/Metadata/Internal/RelationalPropertyExtensions.cs
@@ -1,6 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
using JetBrains.Annotations;
namespace Microsoft.EntityFrameworkCore.Metadata.Internal
@@ -48,5 +51,24 @@ public static IForeignKey FindSharedTableLink([NotNull] this IProperty property)
return null;
}
+
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ public static string FormatColumns([NotNull] this IEnumerable properties)
+ => "{" + string.Join(", ", properties.Select(p => "'" + p.GetColumnName() + "'")) + "}";
+
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ [DebuggerStepThrough]
+ public static string GetConfiguredColumnType([NotNull] this IProperty property)
+ => (string)property[RelationalAnnotationNames.ColumnType];
}
}
diff --git a/src/EFCore.Relational/Query/Pipeline/RelationalSqlTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/Pipeline/RelationalSqlTranslatingExpressionVisitor.cs
index 8afa0d65f6d..e190ae4e741 100644
--- a/src/EFCore.Relational/Query/Pipeline/RelationalSqlTranslatingExpressionVisitor.cs
+++ b/src/EFCore.Relational/Query/Pipeline/RelationalSqlTranslatingExpressionVisitor.cs
@@ -2,13 +2,11 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
-using System.Runtime.InteropServices.ComTypes;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
+using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Query.Expressions.Internal;
@@ -157,10 +155,8 @@ protected override Expression VisitTypeBinary(TypeBinaryExpression typeBinaryExp
_sqlExpressionFactory.Constant(concreteEntityTypes.Select(et => et.GetDiscriminatorValue()).ToList()),
negated: false);
}
- else
- {
- return _sqlExpressionFactory.Constant(false);
- }
+
+ return _sqlExpressionFactory.Constant(false);
}
return null;
@@ -189,15 +185,11 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
{
return subquery.Projection[0].Expression;
}
- else
- {
- throw new InvalidOperationException();
- }
- }
- else
- {
- return new SubSelectExpression(subquery);
+
+ throw new InvalidOperationException();
}
+
+ return new SubSelectExpression(subquery);
}
var @object = Visit(methodCallExpression.Object);
@@ -393,8 +385,6 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression)
[DebuggerStepThrough]
private bool TranslationFailed(Expression original, Expression translation)
- {
- return original == null ? false : !(translation is SqlExpression);
- }
+ => original != null && !(translation is SqlExpression);
}
}
diff --git a/src/EFCore.Relational/Extensions/RelationalExecutionStrategyExtensions.cs b/src/EFCore.Relational/Storage/RelationalExecutionStrategyExtensions.cs
similarity index 100%
rename from src/EFCore.Relational/Extensions/RelationalExecutionStrategyExtensions.cs
rename to src/EFCore.Relational/Storage/RelationalExecutionStrategyExtensions.cs
diff --git a/src/EFCore.Relational/Update/ColumnModification.cs b/src/EFCore.Relational/Update/ColumnModification.cs
index f07ee466f6b..54b2c1f9668 100644
--- a/src/EFCore.Relational/Update/ColumnModification.cs
+++ b/src/EFCore.Relational/Update/ColumnModification.cs
@@ -8,6 +8,7 @@
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
namespace Microsoft.EntityFrameworkCore.Update
diff --git a/src/EFCore.SqlServer/Extensions/SqlServerDatabaseFacadeExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerDatabaseFacadeExtensions.cs
index 44f0fd0be52..967a77926ed 100644
--- a/src/EFCore.SqlServer/Extensions/SqlServerDatabaseFacadeExtensions.cs
+++ b/src/EFCore.SqlServer/Extensions/SqlServerDatabaseFacadeExtensions.cs
@@ -7,6 +7,7 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.SqlServer.Infrastructure.Internal;
+// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
///
diff --git a/src/EFCore.Sqlite.Core/SqliteDatabaseFacadeExtensions.cs b/src/EFCore.Sqlite.Core/Extensions/SqliteDatabaseFacadeExtensions.cs
similarity index 97%
rename from src/EFCore.Sqlite.Core/SqliteDatabaseFacadeExtensions.cs
rename to src/EFCore.Sqlite.Core/Extensions/SqliteDatabaseFacadeExtensions.cs
index da89e6e1897..e3f937aa31c 100644
--- a/src/EFCore.Sqlite.Core/SqliteDatabaseFacadeExtensions.cs
+++ b/src/EFCore.Sqlite.Core/Extensions/SqliteDatabaseFacadeExtensions.cs
@@ -7,6 +7,7 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Sqlite.Infrastructure.Internal;
+// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
///
diff --git a/src/EFCore.Sqlite.Core/SqliteDbContextOptionsBuilderExtensions.cs b/src/EFCore.Sqlite.Core/Extensions/SqliteDbContextOptionsBuilderExtensions.cs
similarity index 99%
rename from src/EFCore.Sqlite.Core/SqliteDbContextOptionsBuilderExtensions.cs
rename to src/EFCore.Sqlite.Core/Extensions/SqliteDbContextOptionsBuilderExtensions.cs
index b20cba55620..7351b3b388d 100644
--- a/src/EFCore.Sqlite.Core/SqliteDbContextOptionsBuilderExtensions.cs
+++ b/src/EFCore.Sqlite.Core/Extensions/SqliteDbContextOptionsBuilderExtensions.cs
@@ -9,6 +9,7 @@
using Microsoft.EntityFrameworkCore.Sqlite.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
+// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
///
diff --git a/src/EFCore.Sqlite.Core/Infrastructure/SqliteServiceCollectionExtensions.cs b/src/EFCore.Sqlite.Core/Extensions/SqliteServiceCollectionExtensions.cs
similarity index 100%
rename from src/EFCore.Sqlite.Core/Infrastructure/SqliteServiceCollectionExtensions.cs
rename to src/EFCore.Sqlite.Core/Extensions/SqliteServiceCollectionExtensions.cs
diff --git a/src/EFCore.Sqlite.NTS/Extensions/SqliteNetTopologySuiteDbContextOptionsBuilderExtensions.cs b/src/EFCore.Sqlite.NTS/Extensions/SqliteNetTopologySuiteDbContextOptionsBuilderExtensions.cs
index e9542fb49fa..4bf5201a72a 100644
--- a/src/EFCore.Sqlite.NTS/Extensions/SqliteNetTopologySuiteDbContextOptionsBuilderExtensions.cs
+++ b/src/EFCore.Sqlite.NTS/Extensions/SqliteNetTopologySuiteDbContextOptionsBuilderExtensions.cs
@@ -6,6 +6,7 @@
using Microsoft.EntityFrameworkCore.Sqlite.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
+// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
///
diff --git a/src/EFCore.Sqlite.NTS/Extensions/SqliteNetTopologySuiteServiceCollectionExtensions.cs b/src/EFCore.Sqlite.NTS/Extensions/SqliteNetTopologySuiteServiceCollectionExtensions.cs
index ed9ee3cd85a..64011ac7006 100644
--- a/src/EFCore.Sqlite.NTS/Extensions/SqliteNetTopologySuiteServiceCollectionExtensions.cs
+++ b/src/EFCore.Sqlite.NTS/Extensions/SqliteNetTopologySuiteServiceCollectionExtensions.cs
@@ -11,6 +11,7 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using NetTopologySuite;
+// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.DependencyInjection
{
///
diff --git a/src/EFCore/ChangeTracking/Internal/IdentityMap.cs b/src/EFCore/ChangeTracking/Internal/IdentityMap.cs
index 0811bf53c74..f1978bcda7e 100644
--- a/src/EFCore/ChangeTracking/Internal/IdentityMap.cs
+++ b/src/EFCore/ChangeTracking/Internal/IdentityMap.cs
@@ -47,7 +47,7 @@ public IdentityMap(
{
_foreignKeys = key.DeclaringEntityType
.GetDerivedTypesInclusive()
- .SelectMany(e => e.GetDeclaredForeignKeys())
+ .SelectMany(EntityTypeExtensions.GetDeclaredForeignKeys)
.ToArray();
}
}
diff --git a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs
index 796c8951569..c2fefbedcfd 100644
--- a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs
+++ b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs
@@ -12,6 +12,7 @@
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using Microsoft.EntityFrameworkCore.Diagnostics.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
@@ -34,8 +35,6 @@ namespace Microsoft.EntityFrameworkCore.Diagnostics
///
public static class CoreLoggerExtensions
{
- private const int QueryModelStringLengthLimit = 100;
-
///
/// Logs for the event.
///
diff --git a/src/EFCore/EntityFrameworkQueryableExtensions.cs b/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs
similarity index 99%
rename from src/EFCore/EntityFrameworkQueryableExtensions.cs
rename to src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs
index aa007437677..aea194ed028 100644
--- a/src/EFCore/EntityFrameworkQueryableExtensions.cs
+++ b/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs
@@ -12,7 +12,7 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Diagnostics;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
+using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
diff --git a/src/EFCore/EntityFrameworkServiceCollectionExtensions.cs b/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs
similarity index 99%
rename from src/EFCore/EntityFrameworkServiceCollectionExtensions.cs
rename to src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs
index 96bf857ff8d..80f01cebb7d 100644
--- a/src/EFCore/EntityFrameworkServiceCollectionExtensions.cs
+++ b/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs
@@ -116,7 +116,7 @@ public static IServiceCollection AddDbContext)null
- : (p, b) => optionsAction?.Invoke(b), contextLifetime, optionsLifetime);
+ : (p, b) => optionsAction.Invoke(b), contextLifetime, optionsLifetime);
///
/// Registers the given context as a service in the and enables DbContext pooling.
@@ -219,7 +219,7 @@ public static IServiceCollection AddDbContextPool(
[NotNull] Action optionsAction,
int poolSize = 128)
where TContext : DbContext
- => AddDbContextPool(serviceCollection, optionsAction);
+ => AddDbContextPool(serviceCollection, optionsAction, poolSize);
///
///
diff --git a/src/EFCore/Extensions/Internal/EFPropertyExtensions.cs b/src/EFCore/Extensions/Internal/EFPropertyExtensions.cs
index 3d8aaa3e710..12d29566e18 100644
--- a/src/EFCore/Extensions/Internal/EFPropertyExtensions.cs
+++ b/src/EFCore/Extensions/Internal/EFPropertyExtensions.cs
@@ -9,7 +9,8 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Metadata;
-namespace Microsoft.EntityFrameworkCore.Extensions.Internal
+// ReSharper disable once CheckNamespace
+namespace Microsoft.EntityFrameworkCore.Internal
{
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/Internal/EnumerableExtensions.cs b/src/EFCore/Extensions/Internal/EnumerableExtensions.cs
similarity index 85%
rename from src/EFCore/Internal/EnumerableExtensions.cs
rename to src/EFCore/Extensions/Internal/EnumerableExtensions.cs
index bfadd03516f..c26e8fac0e5 100644
--- a/src/EFCore/Internal/EnumerableExtensions.cs
+++ b/src/EFCore/Extensions/Internal/EnumerableExtensions.cs
@@ -6,8 +6,11 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
using JetBrains.Annotations;
+// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore.Internal
{
///
@@ -66,7 +69,7 @@ public DynamicEqualityComparer(Func func)
public static string Join(
[NotNull] this IEnumerable source,
[NotNull] string separator = ", ")
- => string.Join(separator, source);
+ => String.Join(separator, source);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -191,5 +194,32 @@ public static bool Any([NotNull] this IEnumerable source)
return false;
}
+
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ public static List ToList(this IEnumerable source)
+ => source.OfType().ToList();
+
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ public static async Task> ToListAsync(
+ this IAsyncEnumerable source, CancellationToken cancellationToken = default)
+ {
+ var list = new List();
+ await foreach (var element in source.WithCancellation(cancellationToken))
+ {
+ list.Add(element);
+ }
+
+ return list;
+ }
}
}
diff --git a/src/EFCore/Extensions/Internal/ExpressionExtensions.cs b/src/EFCore/Extensions/Internal/ExpressionExtensions.cs
index 8d9902764af..8acc4c7aa2a 100644
--- a/src/EFCore/Extensions/Internal/ExpressionExtensions.cs
+++ b/src/EFCore/Extensions/Internal/ExpressionExtensions.cs
@@ -332,25 +332,12 @@ public static Expression Assign(
if (memberExpression.Member is FieldInfo fieldInfo
&& fieldInfo.IsInitOnly)
{
- if (new FrameworkName(AppContext.TargetFrameworkName).Identifier == ".NETCoreApp")
- {
- return (BinaryExpression)Activator.CreateInstance(
- _assignBinaryExpressionType,
- BindingFlags.NonPublic | BindingFlags.Instance,
- null,
- new object[] { memberExpression, valueExpression },
- null);
- }
-
- // On .NET Framework the compiler refuses to compile an expression tree with IsInitOnly access,
- // so use Reflection's SetValue instead.
- return Expression.Call(
- Expression.Constant(fieldInfo),
- _fieldInfoSetValueMethod,
- memberExpression.Expression,
- Expression.Convert(
- valueExpression,
- typeof(object)));
+ return (BinaryExpression)Activator.CreateInstance(
+ _assignBinaryExpressionType,
+ BindingFlags.NonPublic | BindingFlags.Instance,
+ null,
+ new object[] { memberExpression, valueExpression },
+ null);
}
return Expression.Assign(memberExpression, valueExpression);
@@ -359,9 +346,12 @@ public static Expression Assign(
private static readonly Type _assignBinaryExpressionType
= typeof(Expression).Assembly.GetType("System.Linq.Expressions.AssignBinaryExpression");
- private static readonly MethodInfo _fieldInfoSetValueMethod
- = typeof(FieldInfo).GetRuntimeMethod(nameof(FieldInfo.SetValue), new[] { typeof(object), typeof(object) });
-
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
public static LambdaExpression GetLambdaOrNull(this Expression expression)
=> expression is LambdaExpression lambda
? lambda
@@ -369,15 +359,33 @@ public static LambdaExpression GetLambdaOrNull(this Expression expression)
? (LambdaExpression)unary.Operand
: null;
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
public static LambdaExpression UnwrapQuote(this Expression expression)
=> expression is UnaryExpression unary && expression.NodeType == ExpressionType.Quote
? (LambdaExpression)unary.Operand
: (LambdaExpression)expression;
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
public static bool IsIncludeMethod(this MethodCallExpression methodCallExpression)
=> methodCallExpression.Method.DeclaringType == typeof(EntityFrameworkQueryableExtensions)
&& methodCallExpression.Method.Name == nameof(EntityFrameworkQueryableExtensions.Include);
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
public static Expression BuildPropertyAccess(this Expression root, List path)
{
var result = root;
@@ -389,13 +397,19 @@ public static Expression BuildPropertyAccess(this Expression root, List
return result;
}
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
public static Expression CombineAndRemap(
- Expression source,
+ this Expression source,
ParameterExpression sourceParameter,
Expression replaceWith)
=> new ExpressionCombiningVisitor(sourceParameter, replaceWith).Visit(source);
- public class ExpressionCombiningVisitor : ExpressionVisitor
+ private class ExpressionCombiningVisitor : ExpressionVisitor
{
private ParameterExpression _sourceParameter;
private Expression _replaceWith;
diff --git a/src/EFCore/Extensions/Internal/MethodInfoExtensions.cs b/src/EFCore/Extensions/Internal/MethodInfoExtensions.cs
index c798eba27f0..aa331ec133c 100644
--- a/src/EFCore/Extensions/Internal/MethodInfoExtensions.cs
+++ b/src/EFCore/Extensions/Internal/MethodInfoExtensions.cs
@@ -6,7 +6,7 @@
using JetBrains.Annotations;
// ReSharper disable once CheckNamespace
-namespace Microsoft.EntityFrameworkCore.Extensions.Internal
+namespace Microsoft.EntityFrameworkCore.Internal
{
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/Extensions/Internal/QueryableExtensions.cs b/src/EFCore/Extensions/Internal/QueryableExtensions.cs
index 7dab0fdaca6..6673326b5f3 100644
--- a/src/EFCore/Extensions/Internal/QueryableExtensions.cs
+++ b/src/EFCore/Extensions/Internal/QueryableExtensions.cs
@@ -4,12 +4,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Linq.Expressions;
+using System.Threading;
+using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
-namespace Microsoft.EntityFrameworkCore.Extensions.Internal
+// ReSharper disable CheckNamespace
+namespace Microsoft.EntityFrameworkCore.Internal
{
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -42,5 +46,30 @@ public static IAsyncEnumerable AsAsyncEnumerable(
throw new InvalidOperationException(CoreStrings.IQueryableNotAsync(typeof(TSource)));
}
+
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ public static IQueryable LeftJoin(
+ this IQueryable outer,
+ IEnumerable inner,
+ Expression> outerKeySelector,
+ Expression> innerKeySelector,
+ Expression> resultSelector)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ public static Task> ToListAsync(this IQueryable source, CancellationToken cancellationToken = default)
+ => ((IQueryable)source).ToListAsync(cancellationToken);
}
}
diff --git a/src/EFCore/Internal/TypeExtensions.cs b/src/EFCore/Extensions/Internal/TypeExtensions.cs
similarity index 81%
rename from src/EFCore/Internal/TypeExtensions.cs
rename to src/EFCore/Extensions/Internal/TypeExtensions.cs
index 2f04d2cf0b5..f4b24e93679 100644
--- a/src/EFCore/Internal/TypeExtensions.cs
+++ b/src/EFCore/Extensions/Internal/TypeExtensions.cs
@@ -8,6 +8,7 @@
using System.Text;
using JetBrains.Annotations;
+// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore.Internal
{
///
@@ -181,5 +182,35 @@ public static IEnumerable GetNamespaces([NotNull] this Type type)
}
}
}
+
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ public static string GenerateParameterName(this Type type)
+ {
+ var sb = new StringBuilder();
+ var removeLowerCase = sb.Append(type.Name.Where(char.IsUpper).ToArray()).ToString();
+
+ return removeLowerCase.Length > 0 ? removeLowerCase.ToLower() : type.Name.ToLower().Substring(0, 1);
+ }
+
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ public static bool IsQueryableType(this Type type)
+ {
+ if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IQueryable<>))
+ {
+ return true;
+ }
+
+ return type.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IQueryable<>));
+ }
}
}
diff --git a/src/EFCore/Extensions/ObservableCollectionExtensions.cs b/src/EFCore/Extensions/ObservableCollectionExtensions.cs
index 1c263659152..9f61c1ecc87 100644
--- a/src/EFCore/Extensions/ObservableCollectionExtensions.cs
+++ b/src/EFCore/Extensions/ObservableCollectionExtensions.cs
@@ -7,6 +7,7 @@
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
+// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
///
diff --git a/src/EFCore/Extensions/PropertyBaseExtensions.cs b/src/EFCore/Extensions/PropertyBaseExtensions.cs
index 0fbaaf82889..f3422da5ad1 100644
--- a/src/EFCore/Extensions/PropertyBaseExtensions.cs
+++ b/src/EFCore/Extensions/PropertyBaseExtensions.cs
@@ -8,6 +8,7 @@
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
+// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
///
diff --git a/src/EFCore/Infrastructure/AccessorExtensions.cs b/src/EFCore/Infrastructure/AccessorExtensions.cs
index ecc4e0e9817..127234974f9 100644
--- a/src/EFCore/Infrastructure/AccessorExtensions.cs
+++ b/src/EFCore/Infrastructure/AccessorExtensions.cs
@@ -4,6 +4,7 @@
using System;
using System.Diagnostics;
using JetBrains.Annotations;
+using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
@@ -43,7 +44,7 @@ public static class AccessorExtensions
/// The requested service.
[DebuggerStepThrough]
public static TService GetService([NotNull] this IInfrastructure accessor)
- => InternalAccessorExtensions.GetService(Check.NotNull(accessor, nameof(accessor)));
+ => InfrastructureExtensions.GetService(Check.NotNull(accessor, nameof(accessor)));
///
///
diff --git a/src/EFCore/Metadata/Internal/AnnotatableExtensions.cs b/src/EFCore/Infrastructure/Internal/AnnotatableExtensions.cs
similarity index 94%
rename from src/EFCore/Metadata/Internal/AnnotatableExtensions.cs
rename to src/EFCore/Infrastructure/Internal/AnnotatableExtensions.cs
index 8bae06274ab..2f5980a2c08 100644
--- a/src/EFCore/Metadata/Internal/AnnotatableExtensions.cs
+++ b/src/EFCore/Infrastructure/Internal/AnnotatableExtensions.cs
@@ -4,9 +4,8 @@
using System.Linq;
using System.Text;
using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-namespace Microsoft.EntityFrameworkCore.Metadata.Internal
+namespace Microsoft.EntityFrameworkCore.Infrastructure.Internal
{
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/Extensions/Internal/DbContextOptionsExtensions.cs b/src/EFCore/Infrastructure/Internal/DbContextOptionsExtensions.cs
similarity index 92%
rename from src/EFCore/Extensions/Internal/DbContextOptionsExtensions.cs
rename to src/EFCore/Infrastructure/Internal/DbContextOptionsExtensions.cs
index 26eba5c506f..919a82657b2 100644
--- a/src/EFCore/Extensions/Internal/DbContextOptionsExtensions.cs
+++ b/src/EFCore/Infrastructure/Internal/DbContextOptionsExtensions.cs
@@ -3,10 +3,8 @@
using System.Text;
using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-// ReSharper disable once CheckNamespace
-namespace Microsoft.EntityFrameworkCore.Internal
+namespace Microsoft.EntityFrameworkCore.Infrastructure.Internal
{
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/Internal/InternalAccessorExtensions.cs b/src/EFCore/Infrastructure/Internal/InfrastructureExtensions.cs
similarity index 91%
rename from src/EFCore/Internal/InternalAccessorExtensions.cs
rename to src/EFCore/Infrastructure/Internal/InfrastructureExtensions.cs
index aa20808c800..4f34a3e5276 100644
--- a/src/EFCore/Internal/InternalAccessorExtensions.cs
+++ b/src/EFCore/Infrastructure/Internal/InfrastructureExtensions.cs
@@ -5,10 +5,11 @@
using System.Linq;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
-using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.Extensions.DependencyInjection;
-namespace Microsoft.EntityFrameworkCore.Internal
+// ReSharper disable once CheckNamespace
+namespace Microsoft.EntityFrameworkCore.Infrastructure.Internal
{
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -16,7 +17,7 @@ namespace Microsoft.EntityFrameworkCore.Internal
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public static class InternalAccessorExtensions
+ public static class InfrastructureExtensions
{
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/Extensions/Internal/DbContextDependenciesExtensions.cs b/src/EFCore/Internal/DbContextDependenciesExtensions.cs
similarity index 98%
rename from src/EFCore/Extensions/Internal/DbContextDependenciesExtensions.cs
rename to src/EFCore/Internal/DbContextDependenciesExtensions.cs
index 4fbead42cc4..2fb0eaacefe 100644
--- a/src/EFCore/Extensions/Internal/DbContextDependenciesExtensions.cs
+++ b/src/EFCore/Internal/DbContextDependenciesExtensions.cs
@@ -5,7 +5,6 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;
-// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore.Internal
{
///
diff --git a/src/EFCore/Metadata/DependencyInjectionParameterBinding.cs b/src/EFCore/Metadata/DependencyInjectionParameterBinding.cs
index 264bed84e16..1eedd2e9225 100644
--- a/src/EFCore/Metadata/DependencyInjectionParameterBinding.cs
+++ b/src/EFCore/Metadata/DependencyInjectionParameterBinding.cs
@@ -6,7 +6,7 @@
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Internal;
+using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;
@@ -20,7 +20,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata
public class DependencyInjectionParameterBinding : ServiceParameterBinding
{
private static readonly MethodInfo _getServiceMethod
- = typeof(InternalAccessorExtensions).GetMethod(nameof(InternalAccessorExtensions.GetService));
+ = typeof(InfrastructureExtensions).GetMethod(nameof(InfrastructureExtensions.GetService));
///
/// Creates a new instance for the given service type.
diff --git a/src/EFCore/Metadata/Internal/EntityTypeExtensions.cs b/src/EFCore/Metadata/Internal/EntityTypeExtensions.cs
index deb6506308a..d7656aea2a9 100644
--- a/src/EFCore/Metadata/Internal/EntityTypeExtensions.cs
+++ b/src/EFCore/Metadata/Internal/EntityTypeExtensions.cs
@@ -12,6 +12,7 @@
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using Microsoft.EntityFrameworkCore.Diagnostics;
+using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
// ReSharper disable ArgumentsStyleOther
diff --git a/src/EFCore/Metadata/Internal/ForeignKeyExtensions.cs b/src/EFCore/Metadata/Internal/ForeignKeyExtensions.cs
index 07cc690521d..12c020f2f99 100644
--- a/src/EFCore/Metadata/Internal/ForeignKeyExtensions.cs
+++ b/src/EFCore/Metadata/Internal/ForeignKeyExtensions.cs
@@ -8,6 +8,7 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using Microsoft.EntityFrameworkCore.Diagnostics;
+using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
namespace Microsoft.EntityFrameworkCore.Metadata.Internal
{
diff --git a/src/EFCore/Metadata/Internal/IndexExtensions.cs b/src/EFCore/Metadata/Internal/IndexExtensions.cs
index 09b65652912..01a6ecc56f8 100644
--- a/src/EFCore/Metadata/Internal/IndexExtensions.cs
+++ b/src/EFCore/Metadata/Internal/IndexExtensions.cs
@@ -6,6 +6,7 @@
using System.Text;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
+using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
namespace Microsoft.EntityFrameworkCore.Metadata.Internal
{
diff --git a/src/EFCore/Metadata/Internal/KeyExtensions.cs b/src/EFCore/Metadata/Internal/KeyExtensions.cs
index cca6bf804d5..d0e50f272c3 100644
--- a/src/EFCore/Metadata/Internal/KeyExtensions.cs
+++ b/src/EFCore/Metadata/Internal/KeyExtensions.cs
@@ -7,6 +7,7 @@
using System.Text;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
+using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
namespace Microsoft.EntityFrameworkCore.Metadata.Internal
{
diff --git a/src/EFCore/Metadata/Internal/ModelExtensions.cs b/src/EFCore/Metadata/Internal/ModelExtensions.cs
index 533a1ceb990..addd4e0b9ae 100644
--- a/src/EFCore/Metadata/Internal/ModelExtensions.cs
+++ b/src/EFCore/Metadata/Internal/ModelExtensions.cs
@@ -6,6 +6,7 @@
using System.Runtime.CompilerServices;
using System.Text;
using JetBrains.Annotations;
+using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
namespace Microsoft.EntityFrameworkCore.Metadata.Internal
{
diff --git a/src/EFCore/Metadata/Internal/NavigationExtensions.cs b/src/EFCore/Metadata/Internal/NavigationExtensions.cs
index 2347d6bc3f6..8fd6422b747 100644
--- a/src/EFCore/Metadata/Internal/NavigationExtensions.cs
+++ b/src/EFCore/Metadata/Internal/NavigationExtensions.cs
@@ -5,6 +5,7 @@
using System.Text;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
namespace Microsoft.EntityFrameworkCore.Metadata.Internal
{
diff --git a/src/EFCore/Metadata/Internal/PropertyExtensions.cs b/src/EFCore/Metadata/Internal/PropertyExtensions.cs
index 4b6509f8f48..d789588078f 100644
--- a/src/EFCore/Metadata/Internal/PropertyExtensions.cs
+++ b/src/EFCore/Metadata/Internal/PropertyExtensions.cs
@@ -8,6 +8,7 @@
using System.Text;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.ValueGeneration;
namespace Microsoft.EntityFrameworkCore.Metadata.Internal
diff --git a/src/EFCore/Metadata/Internal/ServicePropertyExtensions.cs b/src/EFCore/Metadata/Internal/ServicePropertyExtensions.cs
index 32af5e97670..1595b8d8f21 100644
--- a/src/EFCore/Metadata/Internal/ServicePropertyExtensions.cs
+++ b/src/EFCore/Metadata/Internal/ServicePropertyExtensions.cs
@@ -5,6 +5,7 @@
using System.Text;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
namespace Microsoft.EntityFrameworkCore.Metadata.Internal
{
diff --git a/src/EFCore/Query/Expressions/Internal/NullConditionalExpression.cs b/src/EFCore/Query/Expressions/Internal/NullConditionalExpression.cs
index 6f6579f8194..b91f4960551 100644
--- a/src/EFCore/Query/Expressions/Internal/NullConditionalExpression.cs
+++ b/src/EFCore/Query/Expressions/Internal/NullConditionalExpression.cs
@@ -5,7 +5,7 @@
using System.Collections.Generic;
using System.Linq.Expressions;
using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
+using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Query.Pipeline;
using Microsoft.EntityFrameworkCore.Utilities;
diff --git a/src/EFCore/Extensions/Internal/AsyncQueryProviderExtensions.cs b/src/EFCore/Query/Internal/AsyncQueryProviderExtensions.cs
similarity index 95%
rename from src/EFCore/Extensions/Internal/AsyncQueryProviderExtensions.cs
rename to src/EFCore/Query/Internal/AsyncQueryProviderExtensions.cs
index 40ab4afe833..28531cbed5d 100644
--- a/src/EFCore/Extensions/Internal/AsyncQueryProviderExtensions.cs
+++ b/src/EFCore/Query/Internal/AsyncQueryProviderExtensions.cs
@@ -5,10 +5,9 @@
using System.Linq.Expressions;
using System.Reflection;
using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
-namespace Microsoft.EntityFrameworkCore.Extensions.Internal
+namespace Microsoft.EntityFrameworkCore.Query.Internal
{
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/Query/Internal/ExpressionPrinter.cs b/src/EFCore/Query/Internal/ExpressionPrinter.cs
index 814e7c8884e..cd9edcb4149 100644
--- a/src/EFCore/Query/Internal/ExpressionPrinter.cs
+++ b/src/EFCore/Query/Internal/ExpressionPrinter.cs
@@ -9,7 +9,6 @@
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
diff --git a/src/EFCore/Query/NavigationExpansion/NavigationExpansionHelpers.cs b/src/EFCore/Query/NavigationExpansion/NavigationExpansionHelpers.cs
index ea9d6d99c08..14552be1632 100644
--- a/src/EFCore/Query/NavigationExpansion/NavigationExpansionHelpers.cs
+++ b/src/EFCore/Query/NavigationExpansion/NavigationExpansionHelpers.cs
@@ -6,13 +6,11 @@
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Query.Expressions.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
-using Microsoft.EntityFrameworkCore.Query.Pipeline;
namespace Microsoft.EntityFrameworkCore.Query.NavigationExpansion
{
@@ -57,8 +55,8 @@ public static NavigationExpansionExpression CreateNavigationExpansionRoot(
materializeCollectionNavigation?.ClrType ?? operand.Type);
}
- private static MethodInfo _leftJoinMethodInfo = typeof(EntityQueryableExtensions).GetTypeInfo()
- .GetDeclaredMethods(nameof(EntityQueryableExtensions.LeftJoin)).Single(mi => mi.GetParameters().Length == 5);
+ private static readonly MethodInfo _leftJoinMethodInfo = typeof(QueryableExtensions).GetTypeInfo()
+ .GetDeclaredMethods(nameof(QueryableExtensions.LeftJoin)).Single(mi => mi.GetParameters().Length == 5);
public static (Expression source, ParameterExpression parameter) AddNavigationJoin(
Expression sourceExpression,
@@ -123,8 +121,6 @@ public static (Expression source, ParameterExpression parameter) AddNavigationJo
innerKeySelectorBody,
innerKeySelectorParameter);
- var oldParameterExpression = parameterExpression;
-
if (!sourceExpression.Type.IsQueryableType())
{
var asQueryableMethodInfo = LinqMethodHelpers.AsQueryable.MakeGenericMethod(sourceType);
@@ -171,7 +167,6 @@ var transparentIdentifierCtorInfo
innerKeySelector,
resultSelector);
- sourceType = resultSelector.ReturnType;
sourceExpression = joinMethodCall;
var transparentIdentifierParameterName = resultSelectorInnerParameterName;
diff --git a/src/EFCore/Query/NavigationExpansion/NavigationExpansionTypeExtensions.cs b/src/EFCore/Query/NavigationExpansion/NavigationExpansionTypeExtensions.cs
deleted file mode 100644
index d34f1a622d5..00000000000
--- a/src/EFCore/Query/NavigationExpansion/NavigationExpansionTypeExtensions.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Linq;
-using System.Text;
-
-namespace Microsoft.EntityFrameworkCore.Query.NavigationExpansion
-{
- public static class NavigationExpansionTypeExtensions
- {
- public static string GenerateParameterName(this Type type)
- {
- var sb = new StringBuilder();
- var removeLowerCase = sb.Append(type.Name.Where(c => char.IsUpper(c)).ToArray()).ToString();
-
- if (removeLowerCase.Length > 0)
- {
- return removeLowerCase.ToLower();
- }
- else
- {
- return type.Name.ToLower().Substring(0, 1);
- }
- }
-
- public static bool IsQueryableType(this Type type)
- {
- if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IQueryable<>))
- {
- return true;
- }
-
- return type.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IQueryable<>));
- }
- }
-}
diff --git a/src/EFCore/Query/NavigationExpansion/Visitors/CollectionNavigationRewritingVisitor.cs b/src/EFCore/Query/NavigationExpansion/Visitors/CollectionNavigationRewritingVisitor.cs
index 9f3f0d236cb..4468642b436 100644
--- a/src/EFCore/Query/NavigationExpansion/Visitors/CollectionNavigationRewritingVisitor.cs
+++ b/src/EFCore/Query/NavigationExpansion/Visitors/CollectionNavigationRewritingVisitor.cs
@@ -6,7 +6,6 @@
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query.Internal;
@@ -19,7 +18,7 @@ namespace Microsoft.EntityFrameworkCore.Query.NavigationExpansion.Visitors
///
public class CollectionNavigationRewritingVisitor : ExpressionVisitor
{
- private ParameterExpression _sourceParameter;
+ private readonly ParameterExpression _sourceParameter;
public CollectionNavigationRewritingVisitor(ParameterExpression sourceParameter)
{
@@ -221,10 +220,8 @@ protected override Expression VisitMember(MemberExpression memberExpression)
return result;
}
- else
- {
- return memberExpression.Update(newExpression);
- }
+
+ return memberExpression.Update(newExpression);
}
return memberExpression;
@@ -233,7 +230,7 @@ protected override Expression VisitMember(MemberExpression memberExpression)
private static Expression CreateKeyComparisonExpressionForCollectionNavigationSubquery(
Expression outerKeyExpression,
Expression innerKeyExpression,
- Expression colectionRootExpression)
+ Expression collectionRootExpression)
{
if (outerKeyExpression.Type != innerKeyExpression.Type)
{
@@ -254,8 +251,8 @@ private static Expression CreateKeyComparisonExpressionForCollectionNavigationSu
var outerNullProtection
= Expression.NotEqual(
- colectionRootExpression,
- Expression.Constant(null, colectionRootExpression.Type));
+ collectionRootExpression,
+ Expression.Constant(null, collectionRootExpression.Type));
return new CorrelationPredicateExpression(
outerNullProtection,
diff --git a/src/EFCore/Query/NavigationExpansion/Visitors/IncludeApplyingVisitor.cs b/src/EFCore/Query/NavigationExpansion/Visitors/IncludeApplyingVisitor.cs
index 50e51e4de0a..318d123d207 100644
--- a/src/EFCore/Query/NavigationExpansion/Visitors/IncludeApplyingVisitor.cs
+++ b/src/EFCore/Query/NavigationExpansion/Visitors/IncludeApplyingVisitor.cs
@@ -1,12 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System.Linq;
+using System.Linq.Expressions;
+using Microsoft.EntityFrameworkCore.Internal;
+
namespace Microsoft.EntityFrameworkCore.Query.NavigationExpansion.Visitors
{
- using System.Linq;
- using System.Linq.Expressions;
- using Microsoft.EntityFrameworkCore.Extensions.Internal;
-
public class PendingSelectorIncludeRewriter : ExpressionVisitor
{
protected override Expression VisitMember(MemberExpression memberExpression) => memberExpression;
diff --git a/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpandingVisitor.cs b/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpandingVisitor.cs
index 5726fd02e9e..d03d9f7164f 100644
--- a/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpandingVisitor.cs
+++ b/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpandingVisitor.cs
@@ -5,7 +5,6 @@
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query.Internal;
@@ -108,7 +107,7 @@ private Expression ProcessMemberPushdown(
}
var selector = Expression.Lambda(selectorBody, selectorParameter);
- var remappedSelectorBody = ExpressionExtensions.CombineAndRemap(selector.Body, selectorParameter, navigationExpansionExpression.State.PendingSelector.Body);
+ var remappedSelectorBody = selector.Body.CombineAndRemap(selectorParameter, navigationExpansionExpression.State.PendingSelector.Body);
var binder = new NavigationPropertyBindingVisitor(
navigationExpansionExpression.State.CurrentParameter,
@@ -136,7 +135,7 @@ private Expression ProcessMemberPushdown(
lastNavigation.ForeignKey.PrincipalKey.Properties),
innerParameter);
- var combinedKeySelectorBody = ExpressionExtensions.CombineAndRemap(innerKeyAccessLambda.Body, innerKeyAccessLambda.Parameters[0], navigationExpansionExpression.State.PendingSelector.Body);
+ var combinedKeySelectorBody = innerKeyAccessLambda.Body.CombineAndRemap(innerKeyAccessLambda.Parameters[0], navigationExpansionExpression.State.PendingSelector.Body);
if (outerKeyAccess.Type != combinedKeySelectorBody.Type)
{
if (combinedKeySelectorBody.Type.IsNullableType())
@@ -230,7 +229,7 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression)
var rightConstantNull = binaryExpression.Right.IsNullConstantExpression();
// collection comparison must be optimized out before we visit the left and right
- // otherwise collections would be rewriteen and harder to identify
+ // otherwise collections would be rewritten and harder to identify
if (binaryExpression.NodeType == ExpressionType.Equal
|| binaryExpression.NodeType == ExpressionType.NotEqual)
{
@@ -239,7 +238,7 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression)
var rightParent = default(Expression);
var rightNavigation = default(INavigation);
- // TODO: this is hacky and won't work for weak entity types
+ // TODO: this isn't robust and won't work for weak entity types
// also, add support for EF.Property and maybe convert node around the navigation
if (binaryExpression.Left is MemberExpression leftMember
&& leftMember.Type.TryGetSequenceType() is Type leftSequenceType
diff --git a/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpandingVisitor_MethodCall.cs b/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpandingVisitor_MethodCall.cs
index 5920c215cc1..a25d03fef91 100644
--- a/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpandingVisitor_MethodCall.cs
+++ b/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpandingVisitor_MethodCall.cs
@@ -6,7 +6,6 @@
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query.Internal;
@@ -281,14 +280,14 @@ private Expression ProcessSelectMany(MethodCallExpression methodCallExpression)
var collectionSelector = methodCallExpression.Arguments[1].UnwrapQuote();
AdjustCurrentParameterName(outerSourceNee.State, collectionSelector.Parameters[0].Name);
- var applyNavigsationsResult = FindAndApplyNavigations(outerSourceNee.Operand, collectionSelector, outerSourceNee.State);
- var applyOrderingsResult = ApplyPendingOrderings(applyNavigsationsResult.source, applyNavigsationsResult.state);
+ var applyNavigationsResult = FindAndApplyNavigations(outerSourceNee.Operand, collectionSelector, outerSourceNee.State);
+ var applyOrderingsResult = ApplyPendingOrderings(applyNavigationsResult.source, applyNavigationsResult.state);
var outerSource = applyOrderingsResult.source;
var outerState = applyOrderingsResult.state;
- var collectionSelectorNavigationExpansionExpression = applyNavigsationsResult.lambdaBody as NavigationExpansionExpression
- ?? (applyNavigsationsResult.lambdaBody as NavigationExpansionRootExpression)?.Unwrap() as NavigationExpansionExpression;
+ var collectionSelectorNavigationExpansionExpression = applyNavigationsResult.lambdaBody as NavigationExpansionExpression
+ ?? (applyNavigationsResult.lambdaBody as NavigationExpansionRootExpression)?.Unwrap() as NavigationExpansionExpression;
if (collectionSelectorNavigationExpansionExpression != null)
{
@@ -299,29 +298,8 @@ private Expression ProcessSelectMany(MethodCallExpression methodCallExpression)
// it's not needed for SelectMany collection selectors as they are not directly projected
collectionSelectorState.MaterializeCollectionNavigation = null;
- if (methodCallExpression.Method.MethodIsClosedFormOf(LinqMethodHelpers.QueryableSelectManyWithResultOperatorMethodInfo))
- {
- if (outerState.CurrentParameter.Name == null
- && outerState.CurrentParameter.Name != methodCallExpression.Arguments[2].UnwrapQuote().Parameters[0].Name)
- {
- var newOuterParameter = Expression.Parameter(outerState.CurrentParameter.Type, methodCallExpression.Arguments[2].UnwrapQuote().Parameters[0].Name);
- outerState.PendingSelector = (LambdaExpression)new ExpressionReplacingVisitor(outerState.CurrentParameter, newOuterParameter).Visit(outerState.PendingSelector);
- collectionSelectorLambdaBody = new ExpressionReplacingVisitor(outerState.CurrentParameter, newOuterParameter).Visit(collectionSelectorLambdaBody);
- outerState.CurrentParameter = newOuterParameter;
- }
-
- if (collectionSelectorState.CurrentParameter.Name == null
- && collectionSelectorState.CurrentParameter.Name != methodCallExpression.Arguments[2].UnwrapQuote().Parameters[1].Name)
- {
- var newInnerParameter = Expression.Parameter(collectionSelectorState.CurrentParameter.Type, methodCallExpression.Arguments[2].UnwrapQuote().Parameters[1].Name);
- collectionSelectorState.PendingSelector = (LambdaExpression)new ExpressionReplacingVisitor(collectionSelectorState.CurrentParameter, newInnerParameter).Visit(collectionSelectorState.PendingSelector);
- collectionSelectorState.CurrentParameter = newInnerParameter;
- }
- }
-
if (methodCallExpression.Method.MethodIsClosedFormOf(LinqMethodHelpers.QueryableSelectManyWithResultOperatorMethodInfo)
- && (collectionSelectorState.CurrentParameter.Name == null
- || collectionSelectorState.CurrentParameter.Name != methodCallExpression.Arguments[2].UnwrapQuote().Parameters[1].Name))
+ && collectionSelectorState.CurrentParameter.Name != methodCallExpression.Arguments[2].UnwrapQuote().Parameters[1].Name)
{
// TODO: should we rename the second parameter according to the second parameter of the result selector instead?
var newParameter = Expression.Parameter(collectionSelectorState.CurrentParameter.Type, methodCallExpression.Arguments[2].UnwrapQuote().Parameters[1].Name);
@@ -404,7 +382,7 @@ private NavigationExpansionExpressionState CreateSelectManyInnerState(Navigation
sourceMappingMapping[oldSourceMapping] = newSourceMapping;
var newNavigationTreeRoot = NavigationTreeNode.CreateRoot(newSourceMapping, new List(), oldSourceMapping.NavigationTree.Optional);
- // TODO: simply coyping ToMapping might not be correct for very complex cases where the child mapping is not purely Inner/Outer but has some properties from preivous anonymous projections
+ // TODO: simply copying ToMapping might not be correct for very complex cases where the child mapping is not purely Inner/Outer but has some properties from previous anonymous projections
// we should recognize and filter those out, however this is theoretical at this point - scenario is not supported and likely won't be in the foreseeable future
newNavigationTreeRoot.ToMapping = oldSourceMapping.NavigationTree.ToMapping.ToList();
newSourceMapping.NavigationTree = newNavigationTreeRoot;
@@ -451,7 +429,7 @@ private void CopyNavigationTree(
copy.ExpansionMode = child.ExpansionMode;
copy.Included = child.Included;
- // TODO: simply coyping ToMapping might not be correct for very complex cases where the child mapping is not purely Inner/Outer but has some properties from preivous anonymous projections
+ // TODO: simply copying ToMapping might not be correct for very complex cases where the child mapping is not purely Inner/Outer but has some properties from previous anonymous projections
// we should recognize and filter those out, however this is theoretical at this point - scenario is not supported and likely won't be in the foreseeable future
copy.ToMapping = child.ToMapping.ToList();
mapping[child] = copy;
@@ -461,11 +439,11 @@ private void CopyNavigationTree(
private class SelectManyCollectionPendingSelectorRemapper : ExpressionVisitor
{
- private ParameterExpression _oldParameter;
- private ParameterExpression _newParameter;
- private Dictionary _sourceMappingMapping;
- private Dictionary _navigationTreeNodeMapping;
- private Dictionary, List> _customRootMappingMapping;
+ private readonly ParameterExpression _oldParameter;
+ private readonly ParameterExpression _newParameter;
+ private readonly Dictionary _sourceMappingMapping;
+ private readonly Dictionary _navigationTreeNodeMapping;
+ private readonly Dictionary, List> _customRootMappingMapping;
public SelectManyCollectionPendingSelectorRemapper(
ParameterExpression oldParameter,
@@ -603,7 +581,7 @@ private Expression ProcessGroupJoin(MethodCallExpression methodCallExpression)
var innerApplyOrderingsResult = ApplyPendingOrderings(innerApplyNavigationsResult.source, innerApplyNavigationsResult.state);
var resultSelectorBody = resultSelector.Body;
- var remappedResultSelectorBody = ExpressionExtensions.CombineAndRemap(resultSelector.Body, resultSelector.Parameters[0], outerApplyOrderingsResult.state.PendingSelector.Body);
+ var remappedResultSelectorBody = resultSelector.Body.CombineAndRemap(resultSelector.Parameters[0], outerApplyOrderingsResult.state.PendingSelector.Body);
var groupingParameter = resultSelector.Parameters[1];
var newGroupingParameter = Expression.Parameter(typeof(IEnumerable<>).MakeGenericType(innerApplyOrderingsResult.state.CurrentParameter.Type), "new_" + groupingParameter.Name);
@@ -950,8 +928,8 @@ private Expression ProcessSkipTake(MethodCallExpression methodCallExpression)
private class PendingSelectorReprojector : ExpressionVisitor
{
- private List _currentPath = new List();
- private CustomRootExpression _rootExpression;
+ private readonly List _currentPath = new List();
+ private readonly CustomRootExpression _rootExpression;
public PendingSelectorReprojector(CustomRootExpression rootExpression)
{
@@ -1047,7 +1025,7 @@ private Expression ProcessInclude(MethodCallExpression methodCallExpression)
Expression remappedIncludeLambdaBody;
if (methodCallExpression.Method.Name == "Include")
{
- remappedIncludeLambdaBody = ExpressionExtensions.CombineAndRemap(includeLambda.Body, includeLambda.Parameters[0], applyOrderingsResult.state.PendingSelector.Body);
+ remappedIncludeLambdaBody = includeLambda.Body.CombineAndRemap(includeLambda.Parameters[0], applyOrderingsResult.state.PendingSelector.Body);
}
else
{
@@ -1069,7 +1047,7 @@ private Expression ProcessInclude(MethodCallExpression methodCallExpression)
else
{
var pendingIncludeChainLambda = Expression.Lambda(applyOrderingsResult.state.PendingIncludeChain, applyOrderingsResult.state.CurrentParameter);
- remappedIncludeLambdaBody = ExpressionExtensions.CombineAndRemap(includeLambda.Body, includeLambda.Parameters[0], pendingIncludeChainLambda.Body);
+ remappedIncludeLambdaBody = includeLambda.Body.CombineAndRemap(includeLambda.Parameters[0], pendingIncludeChainLambda.Body);
}
}
@@ -1244,7 +1222,7 @@ protected override Expression VisitConstant(ConstantExpression constantExpressio
return (source, lambda.Body, state);
}
- var remappedLambdaBody = ExpressionExtensions.CombineAndRemap(lambda.Body, lambda.Parameters[0], state.PendingSelector.Body);
+ var remappedLambdaBody = lambda.Body.CombineAndRemap(lambda.Parameters[0], state.PendingSelector.Body);
var binder = new NavigationPropertyBindingVisitor(
state.PendingSelector.Parameters[0],
@@ -1306,8 +1284,8 @@ protected override Expression VisitConstant(ConstantExpression constantExpressio
NavigationExpansionExpressionState outerState,
NavigationExpansionExpressionState innerState)
{
- var remappedResultSelectorBody = ExpressionExtensions.CombineAndRemap(resultSelector.Body, resultSelector.Parameters[0], outerState.PendingSelector.Body);
- remappedResultSelectorBody = ExpressionExtensions.CombineAndRemap(remappedResultSelectorBody, resultSelector.Parameters[1], innerState.PendingSelector.Body);
+ var remappedResultSelectorBody = resultSelector.Body.CombineAndRemap(resultSelector.Parameters[0], outerState.PendingSelector.Body);
+ remappedResultSelectorBody = remappedResultSelectorBody.CombineAndRemap(resultSelector.Parameters[1], innerState.PendingSelector.Body);
var outerBinder = new NavigationPropertyBindingVisitor(
outerState.CurrentParameter,
@@ -1389,13 +1367,13 @@ protected override Expression VisitConstant(ConstantExpression constantExpressio
private class PendingSelectorSourceMappingGenerator : ExpressionVisitor
{
- private ParameterExpression _rootParameter;
- private List _currentPath = new List();
- private IEntityType _entityTypeOverride;
+ private readonly ParameterExpression _rootParameter;
+ private readonly List _currentPath = new List();
+ private readonly IEntityType _entityTypeOverride;
- public List SourceMappings = new List();
+ public readonly List SourceMappings = new List();
- public Dictionary BindingToSourceMapping
+ public readonly Dictionary BindingToSourceMapping
= new Dictionary();
public PendingSelectorSourceMappingGenerator(ParameterExpression rootParameter, IEntityType entityTypeOverride)
diff --git a/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpansionCleanupVisitor.cs b/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpansionCleanupVisitor.cs
index 2baa69c62c1..303bebcec38 100644
--- a/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpansionCleanupVisitor.cs
+++ b/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpansionCleanupVisitor.cs
@@ -3,7 +3,6 @@
using System;
using System.Linq.Expressions;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
using Microsoft.EntityFrameworkCore.Internal;
namespace Microsoft.EntityFrameworkCore.Query.NavigationExpansion.Visitors
diff --git a/src/EFCore/Query/NavigationExpansion/Visitors/NavigationPropertyBindingVisitor.cs b/src/EFCore/Query/NavigationExpansion/Visitors/NavigationPropertyBindingVisitor.cs
index 296daa29a20..fb6f8c76519 100644
--- a/src/EFCore/Query/NavigationExpansion/Visitors/NavigationPropertyBindingVisitor.cs
+++ b/src/EFCore/Query/NavigationExpansion/Visitors/NavigationPropertyBindingVisitor.cs
@@ -4,16 +4,16 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
+using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Query.Expressions.Internal;
namespace Microsoft.EntityFrameworkCore.Query.NavigationExpansion.Visitors
{
public class NavigationPropertyBindingVisitor : ExpressionVisitor
{
- private ParameterExpression _rootParameter;
- private List _sourceMappings;
- private bool _bindInclude;
+ private readonly ParameterExpression _rootParameter;
+ private readonly List _sourceMappings;
+ private readonly bool _bindInclude;
public NavigationPropertyBindingVisitor(
ParameterExpression rootParameter,
@@ -191,7 +191,7 @@ private Expression TryBindProperty(Expression originalExpression, Expression new
if (expression is ParameterExpression parameterExpression
&& (parameterExpression == _rootParameter))
{
- var matchingCandidate = navigationTreeNodeCandidates.Where(m => m.path.Count == 0).SingleOrDefault();
+ var matchingCandidate = navigationTreeNodeCandidates.SingleOrDefault(m => m.path.Count == 0);
return matchingCandidate.navigationTreeNode != null
? (rootParameter: parameterExpression, matchingCandidate.navigationTreeNode)
@@ -201,7 +201,7 @@ private Expression TryBindProperty(Expression originalExpression, Expression new
if (expression is CustomRootExpression customRootExpression
&& customRootExpression.RootParameter == _rootParameter)
{
- var matchingCandidate = navigationTreeNodeCandidates.Where(m => m.path.Count == 0).SingleOrDefault();
+ var matchingCandidate = navigationTreeNodeCandidates.SingleOrDefault(m => m.path.Count == 0);
return matchingCandidate.navigationTreeNode != null
? (rootParameter: customRootExpression.RootParameter, matchingCandidate.navigationTreeNode)
diff --git a/src/EFCore/Query/NavigationExpansion/Visitors/NavigationPropertyUnbindingVisitor.cs b/src/EFCore/Query/NavigationExpansion/Visitors/NavigationPropertyUnbindingVisitor.cs
index e479f3679df..07d37d93a3d 100644
--- a/src/EFCore/Query/NavigationExpansion/Visitors/NavigationPropertyUnbindingVisitor.cs
+++ b/src/EFCore/Query/NavigationExpansion/Visitors/NavigationPropertyUnbindingVisitor.cs
@@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Query.NavigationExpansion.Visitors
{
public class NavigationPropertyUnbindingVisitor : ExpressionVisitor
{
- private ParameterExpression _rootParameter;
+ private readonly ParameterExpression _rootParameter;
public NavigationPropertyUnbindingVisitor(ParameterExpression rootParameter)
{
diff --git a/src/EFCore/Query/NavigationExpansion/Visitors/PendingIncludeFindingVisitor.cs b/src/EFCore/Query/NavigationExpansion/Visitors/PendingIncludeFindingVisitor.cs
index 77efd766069..ae4dd3e703b 100644
--- a/src/EFCore/Query/NavigationExpansion/Visitors/PendingIncludeFindingVisitor.cs
+++ b/src/EFCore/Query/NavigationExpansion/Visitors/PendingIncludeFindingVisitor.cs
@@ -3,7 +3,7 @@
using System.Collections.Generic;
using System.Linq.Expressions;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
+using Microsoft.EntityFrameworkCore.Internal;
namespace Microsoft.EntityFrameworkCore.Query.NavigationExpansion.Visitors
{
diff --git a/src/EFCore/Query/Pipeline/EntityEqualityRewritingExpressionVisitor.cs b/src/EFCore/Query/Pipeline/EntityEqualityRewritingExpressionVisitor.cs
index 2867ba5c283..f501a4bf805 100644
--- a/src/EFCore/Query/Pipeline/EntityEqualityRewritingExpressionVisitor.cs
+++ b/src/EFCore/Query/Pipeline/EntityEqualityRewritingExpressionVisitor.cs
@@ -8,12 +8,10 @@
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query.Expressions.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
-using Microsoft.EntityFrameworkCore.Query.NavigationExpansion;
namespace Microsoft.EntityFrameworkCore.Query.Pipeline
{
@@ -151,7 +149,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
if (methodCallExpression.Method.DeclaringType == typeof(Queryable)
|| methodCallExpression.Method.DeclaringType == typeof(Enumerable)
- || methodCallExpression.Method.DeclaringType == typeof(EntityQueryableExtensions))
+ || methodCallExpression.Method.DeclaringType == typeof(QueryableExtensions))
{
switch (methodCallExpression.Method.Name)
{
@@ -163,7 +161,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
case nameof(Queryable.GroupJoin):
case nameof(Queryable.Join):
- case nameof(EntityQueryableExtensions.LeftJoin):
+ case nameof(QueryableExtensions.LeftJoin):
return VisitJoinMethodCall(methodCallExpression);
case nameof(Queryable.GroupBy): // TODO: Implement
diff --git a/src/EFCore/Query/Pipeline/EntityQueryableExtensions.cs b/src/EFCore/Query/Pipeline/EntityQueryableExtensions.cs
deleted file mode 100644
index 49fac7a2ba3..00000000000
--- a/src/EFCore/Query/Pipeline/EntityQueryableExtensions.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-
-namespace Microsoft.EntityFrameworkCore.Query.Pipeline
-{
- public static class EntityQueryableExtensions
- {
- public static IQueryable LeftJoin(
- this IQueryable outer,
- IEnumerable inner,
- Expression> outerKeySelector,
- Expression> innerKeySelector,
- Expression> resultSelector)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/EFCore/Query/Pipeline/GroupJoinFlatteningExpressionVisitor.cs b/src/EFCore/Query/Pipeline/GroupJoinFlatteningExpressionVisitor.cs
index bc4ad09a358..3ce69608298 100644
--- a/src/EFCore/Query/Pipeline/GroupJoinFlatteningExpressionVisitor.cs
+++ b/src/EFCore/Query/Pipeline/GroupJoinFlatteningExpressionVisitor.cs
@@ -6,39 +6,40 @@
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
+using Microsoft.EntityFrameworkCore.Internal;
namespace Microsoft.EntityFrameworkCore.Query.Pipeline
{
public class GroupJoinFlatteningExpressionVisitor : ExpressionVisitor
{
- private static MethodInfo _whereMethodInfo = typeof(Queryable).GetTypeInfo()
+ private static readonly MethodInfo _whereMethodInfo = typeof(Queryable).GetTypeInfo()
.GetDeclaredMethods(nameof(Queryable.Where))
.Single(mi => mi.GetParameters().Length == 2
&& mi.GetParameters()[1].ParameterType.GetGenericArguments()[0].GetGenericArguments().Length == 2);
- private static MethodInfo _groupJoinMethodInfo = typeof(Queryable).GetTypeInfo()
+ private static readonly MethodInfo _groupJoinMethodInfo = typeof(Queryable).GetTypeInfo()
.GetDeclaredMethods(nameof(Queryable.GroupJoin)).Single(mi => mi.GetParameters().Length == 5);
- private static MethodInfo _defaultIfEmptyWithoutArgMethodInfo = typeof(Enumerable).GetTypeInfo()
+ private static readonly MethodInfo _defaultIfEmptyWithoutArgMethodInfo = typeof(Enumerable).GetTypeInfo()
.GetDeclaredMethods(nameof(Enumerable.DefaultIfEmpty)).Single(mi => mi.GetParameters().Length == 1);
- private static MethodInfo _selectManyWithCollectionSelectorMethodInfo = typeof(Queryable).GetTypeInfo()
+ private static readonly MethodInfo _selectManyWithCollectionSelectorMethodInfo = typeof(Queryable).GetTypeInfo()
.GetDeclaredMethods(nameof(Queryable.SelectMany))
.Single(mi => mi.GetParameters().Length == 3
&& mi.GetParameters()[1].ParameterType.GetGenericArguments()[0].GetGenericArguments().Length == 2);
- private static MethodInfo _selectManyWithoutCollectionSelectorMethodInfo = typeof(Queryable).GetTypeInfo()
+ private static readonly MethodInfo _selectManyWithoutCollectionSelectorMethodInfo = typeof(Queryable).GetTypeInfo()
.GetDeclaredMethods(nameof(Queryable.SelectMany))
.Single(mi => mi.GetParameters().Length == 2
&& mi.GetParameters()[1].ParameterType.GetGenericArguments()[0].GetGenericArguments().Length == 2);
- private static MethodInfo _joinMethodInfo = typeof(Queryable).GetTypeInfo()
+ private static readonly MethodInfo _joinMethodInfo = typeof(Queryable).GetTypeInfo()
.GetDeclaredMethods(nameof(Queryable.Join)).Single(mi => mi.GetParameters().Length == 5);
- private static MethodInfo _leftJoinMethodInfo = typeof(EntityQueryableExtensions).GetTypeInfo()
- .GetDeclaredMethods(nameof(EntityQueryableExtensions.LeftJoin)).Single(mi => mi.GetParameters().Length == 5);
+ private static readonly MethodInfo _leftJoinMethodInfo = typeof(QueryableExtensions).GetTypeInfo()
+ .GetDeclaredMethods(nameof(QueryableExtensions.LeftJoin)).Single(mi => mi.GetParameters().Length == 5);
- private static SelectManyVerifyingExpressionVisitor _selectManyVerifyingExpressionVisitor
+ private static readonly SelectManyVerifyingExpressionVisitor _selectManyVerifyingExpressionVisitor
= new SelectManyVerifyingExpressionVisitor();
- private static EnumerableToQueryableReMappingExpressionVisitor _enumerableToQueryableReMappingExpressionVisitor
+ private static readonly EnumerableToQueryableReMappingExpressionVisitor _enumerableToQueryableReMappingExpressionVisitor
= new EnumerableToQueryableReMappingExpressionVisitor();
protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression)
diff --git a/src/EFCore/Query/Pipeline/ParameterExtractingExpressionVisitor.cs b/src/EFCore/Query/Pipeline/ParameterExtractingExpressionVisitor.cs
index eaedc6b022f..4c9c6a6d3f8 100644
--- a/src/EFCore/Query/Pipeline/ParameterExtractingExpressionVisitor.cs
+++ b/src/EFCore/Query/Pipeline/ParameterExtractingExpressionVisitor.cs
@@ -2,13 +2,11 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Microsoft.EntityFrameworkCore.Diagnostics;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
diff --git a/src/EFCore/Query/Pipeline/QueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore/Query/Pipeline/QueryableMethodTranslatingExpressionVisitor.cs
index d2494338945..e6874b98a87 100644
--- a/src/EFCore/Query/Pipeline/QueryableMethodTranslatingExpressionVisitor.cs
+++ b/src/EFCore/Query/Pipeline/QueryableMethodTranslatingExpressionVisitor.cs
@@ -7,6 +7,7 @@
using System.Linq.Expressions;
using System.Reflection;
using JetBrains.Annotations;
+using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Query.NavigationExpansion.Visitors;
namespace Microsoft.EntityFrameworkCore.Query.Pipeline
@@ -26,7 +27,7 @@ protected override Expression VisitExtension(Expression extensionExpression)
protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression)
{
if (methodCallExpression.Method.DeclaringType == typeof(Queryable)
- || methodCallExpression.Method.DeclaringType == typeof(EntityQueryableExtensions))
+ || methodCallExpression.Method.DeclaringType == typeof(QueryableExtensions))
{
var source = Visit(methodCallExpression.Arguments[0]);
if (source is ShapedQueryExpression shapedQueryExpression)
@@ -244,7 +245,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
break;
- case nameof(EntityQueryableExtensions.LeftJoin)
+ case nameof(QueryableExtensions.LeftJoin)
when argumentCount == 5:
{
var innerSource = Visit(methodCallExpression.Arguments[1]);
diff --git a/src/EFCore/Extensions/ExecutionStrategyExtensions.cs b/src/EFCore/Storage/ExecutionStrategyExtensions.cs
similarity index 100%
rename from src/EFCore/Extensions/ExecutionStrategyExtensions.cs
rename to src/EFCore/Storage/ExecutionStrategyExtensions.cs
diff --git a/src/Microsoft.Data.Sqlite.Core/Extensions/SQLitePCLExtensions.cs b/src/Microsoft.Data.Sqlite.Core/Extensions/SQLitePCLExtensions.cs
index b7d3301cd9e..2fdc1659834 100644
--- a/src/Microsoft.Data.Sqlite.Core/Extensions/SQLitePCLExtensions.cs
+++ b/src/Microsoft.Data.Sqlite.Core/Extensions/SQLitePCLExtensions.cs
@@ -5,6 +5,7 @@
using static SQLitePCL.raw;
+// ReSharper disable once CheckNamespace
namespace SQLitePCL
{
internal static class SQLitePCLExtensions
diff --git a/src/Microsoft.Data.Sqlite.Core/Extensions/SqliteConnectionExtensions.cs b/src/Microsoft.Data.Sqlite.Core/Extensions/SqliteConnectionExtensions.cs
index 55876a683f1..dd26d33a392 100644
--- a/src/Microsoft.Data.Sqlite.Core/Extensions/SqliteConnectionExtensions.cs
+++ b/src/Microsoft.Data.Sqlite.Core/Extensions/SqliteConnectionExtensions.cs
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Sqlite
{
internal static class SqliteConnectionExtensions
diff --git a/src/Microsoft.Data.Sqlite.Core/Extensions/TypeExtensions.cs b/src/Microsoft.Data.Sqlite.Core/Extensions/TypeExtensions.cs
index d7ac9889ef2..e975d7531c0 100644
--- a/src/Microsoft.Data.Sqlite.Core/Extensions/TypeExtensions.cs
+++ b/src/Microsoft.Data.Sqlite.Core/Extensions/TypeExtensions.cs
@@ -3,6 +3,7 @@
using System.Reflection;
+// ReSharper disable once CheckNamespace
namespace System
{
internal static class TypeExtensions
diff --git a/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs b/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs
index 6cc9d4f6bc5..09f8359234e 100644
--- a/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs
+++ b/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs
@@ -4,7 +4,8 @@
using Microsoft.EntityFrameworkCore.Cosmos.TestUtilities;
using Xunit;
-namespace Microsoft.EntityFrameworkCore.Cosmos.Metadata
+// ReSharper disable once CheckNamespace
+namespace Microsoft.EntityFrameworkCore.Metadata
{
public class CosmosBuilderExtensionsTest
{
diff --git a/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs b/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs
index 4a0e17c21da..0557e7856c2 100644
--- a/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs
+++ b/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs
@@ -5,7 +5,8 @@
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Xunit;
-namespace Microsoft.EntityFrameworkCore
+// ReSharper disable once CheckNamespace
+namespace Microsoft.EntityFrameworkCore.Metadata
{
public class CosmosMetadataExtensionsTest
{
diff --git a/test/EFCore.Cosmos.Tests/TestUtilities/CosmosTestHelpers.cs b/test/EFCore.Cosmos.Tests/TestUtilities/CosmosTestHelpers.cs
index 37480ba4279..336ef9d3bd3 100644
--- a/test/EFCore.Cosmos.Tests/TestUtilities/CosmosTestHelpers.cs
+++ b/test/EFCore.Cosmos.Tests/TestUtilities/CosmosTestHelpers.cs
@@ -1,11 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Metadata.Internal;
-using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Microsoft.Extensions.DependencyInjection;
diff --git a/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs b/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs
index 32011f9f007..b8716328b21 100644
--- a/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs
+++ b/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Cosmos.TestUtilities;
+using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit;
namespace Microsoft.EntityFrameworkCore.Cosmos.ValueGenerator.Internal
diff --git a/test/EFCore.Specification.Tests/LoadTestBase.cs b/test/EFCore.Specification.Tests/LoadTestBase.cs
index 5c4ebb7f231..20a67e67b10 100644
--- a/test/EFCore.Specification.Tests/LoadTestBase.cs
+++ b/test/EFCore.Specification.Tests/LoadTestBase.cs
@@ -11,6 +11,7 @@
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Diagnostics.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
diff --git a/test/EFCore.Specification.Tests/Query/CompiledQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/CompiledQueryTestBase.cs
index c336ec38b0c..c3736db7656 100644
--- a/test/EFCore.Specification.Tests/Query/CompiledQueryTestBase.cs
+++ b/test/EFCore.Specification.Tests/Query/CompiledQueryTestBase.cs
@@ -4,6 +4,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.TestModels.Northwind;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Microsoft.EntityFrameworkCore.TestUtilities.Xunit;
diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindData.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindData.cs
index a15f1193adf..7ee584fac5f 100644
--- a/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindData.cs
+++ b/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindData.cs
@@ -7,8 +7,8 @@
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.TestUtilities;
diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendIncludeToExistingExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendIncludeToExistingExpressionMutator.cs
index 5e5ade13bba..5a5dbc641c0 100644
--- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendIncludeToExistingExpressionMutator.cs
+++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendIncludeToExistingExpressionMutator.cs
@@ -5,7 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
+using Microsoft.EntityFrameworkCore.Internal;
namespace Microsoft.EntityFrameworkCore.TestUtilities.QueryTestGeneration
{
@@ -20,7 +20,7 @@ public AppendIncludeToExistingExpressionMutator(DbContext context)
public override bool IsValid(Expression expression)
{
- _expressionFinder = new ExpressionFinder(this);
+ _expressionFinder = new ExpressionFinder();
_expressionFinder.Visit(expression);
return _expressionFinder.FoundExpressions.Any();
@@ -87,13 +87,6 @@ public override Expression Apply(Expression expression, Random random)
private class ExpressionFinder : ExpressionVisitor
{
- private AppendIncludeToExistingExpressionMutator _mutator;
-
- public ExpressionFinder(AppendIncludeToExistingExpressionMutator mutator)
- {
- _mutator = mutator;
- }
-
public readonly List FoundExpressions = new List();
protected override Expression VisitMethodCall(MethodCallExpression node)
diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectStringFunctionExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectStringFunctionExpressionMutator.cs
index 065ff19299e..553ccf318c8 100644
--- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectStringFunctionExpressionMutator.cs
+++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectStringFunctionExpressionMutator.cs
@@ -6,7 +6,7 @@
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
+using Microsoft.EntityFrameworkCore.Internal;
namespace Microsoft.EntityFrameworkCore.TestUtilities.QueryTestGeneration
{
@@ -51,8 +51,8 @@ public override Expression Visit(Expression node)
if (_insideLambda
&& !_insideEFProperty
&& node?.Type == typeof(string)
- && node?.NodeType != ExpressionType.Parameter
- && (node?.NodeType != ExpressionType.Constant || ((ConstantExpression)node)?.Value != null))
+ && node.NodeType != ExpressionType.Parameter
+ && (node.NodeType != ExpressionType.Constant || ((ConstantExpression)node)?.Value != null))
{
FoundExpressions.Add(node);
}
diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/StringConcatWithSelfExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/StringConcatWithSelfExpressionMutator.cs
index 58293f0c142..6d9c3a9cf59 100644
--- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/StringConcatWithSelfExpressionMutator.cs
+++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/StringConcatWithSelfExpressionMutator.cs
@@ -6,7 +6,7 @@
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
+using Microsoft.EntityFrameworkCore.Internal;
namespace Microsoft.EntityFrameworkCore.TestUtilities.QueryTestGeneration
{
diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryableExtensions.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryableExtensions.cs
deleted file mode 100644
index 2194486dfee..00000000000
--- a/test/EFCore.Specification.Tests/TestUtilities/QueryableExtensions.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
-
-namespace Microsoft.EntityFrameworkCore.TestUtilities
-{
- public static class QueryableExtensions
- {
- public static List ToList(this System.Collections.IEnumerable source)
- => source.OfType().ToList();
-
- public static Task> ToListAsync(this IQueryable source, CancellationToken cancellationToken = default)
- {
- return ((IQueryable)source).ToListAsync(cancellationToken);
- }
-
- public static async Task> ToListAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default)
- {
- var list = new List();
- await foreach (var element in source.WithCancellation(cancellationToken))
- {
- list.Add(element);
- }
-
- return list;
- }
- }
-}
diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientCascade.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientCascade.cs
index a07467420b5..c9699cea6bf 100644
--- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientCascade.cs
+++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientCascade.cs
@@ -24,7 +24,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
foreach (var foreignKey in modelBuilder.Model
.GetEntityTypes()
- .SelectMany(e => MutableEntityTypeExtensions.GetDeclaredForeignKeys(e))
+ .SelectMany(e => e.GetDeclaredForeignKeys())
.Where(e => e.DeleteBehavior == DeleteBehavior.Cascade))
{
foreignKey.DeleteBehavior = DeleteBehavior.ClientCascade;
diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientNoAction.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientNoAction.cs
index ddd6330a4a8..537029c31ac 100644
--- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientNoAction.cs
+++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientNoAction.cs
@@ -24,7 +24,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
foreach (var foreignKey in modelBuilder.Model
.GetEntityTypes()
- .SelectMany(e => MutableEntityTypeExtensions.GetDeclaredForeignKeys(e)))
+ .SelectMany(e => e.GetDeclaredForeignKeys()))
{
foreignKey.DeleteBehavior = DeleteBehavior.ClientNoAction;
}
diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AsyncSimpleQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AsyncSimpleQuerySqlServerTest.cs
index 62a36fc0dfa..8c820ad4692 100644
--- a/test/EFCore.SqlServer.FunctionalTests/Query/AsyncSimpleQuerySqlServerTest.cs
+++ b/test/EFCore.SqlServer.FunctionalTests/Query/AsyncSimpleQuerySqlServerTest.cs
@@ -4,7 +4,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
+using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.TestModels.Northwind;
diff --git a/test/EFCore.SqlServer.Tests/Design/SqlServerDesignTimeProviderServicesTest.cs b/test/EFCore.SqlServer.Tests/Design/SqlServerDesignTimeProviderServicesTest.cs
index ce447e12846..43fc7d5d186 100644
--- a/test/EFCore.SqlServer.Tests/Design/SqlServerDesignTimeProviderServicesTest.cs
+++ b/test/EFCore.SqlServer.Tests/Design/SqlServerDesignTimeProviderServicesTest.cs
@@ -3,11 +3,10 @@
using System;
using System.Reflection;
-using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.SqlServer.Design.Internal;
using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal;
-namespace Microsoft.EntityFrameworkCore
+namespace Microsoft.EntityFrameworkCore.Design
{
public class SqlServerDesignTimeProviderServicesTest : DesignTimeProviderServicesTest
{
diff --git a/test/EFCore.Tests/ExceptionTest.cs b/test/EFCore.Tests/ExceptionTest.cs
index 2be68fa634f..96d486eddf7 100644
--- a/test/EFCore.Tests/ExceptionTest.cs
+++ b/test/EFCore.Tests/ExceptionTest.cs
@@ -13,6 +13,7 @@
using Microsoft.EntityFrameworkCore.TestUtilities;
using Microsoft.EntityFrameworkCore.Update;
using Xunit;
+// ReSharper disable InconsistentNaming
namespace Microsoft.EntityFrameworkCore
{
@@ -186,7 +187,7 @@ public FakeInternalEntityEntry()
public override object Entity { get; }
}
- private static IEntityType CreateEntityType()
+ private static IEntityType CreateEntityType()
{
var model = new Model(new ConventionSet());
var entityType = model.AddEntityType(typeof(object), ConfigurationSource.Convention);
diff --git a/test/EFCore.Tests/Extensions/PropertyExtensionsTest.cs b/test/EFCore.Tests/Extensions/PropertyExtensionsTest.cs
index 24febb9ce67..a127f50ad30 100644
--- a/test/EFCore.Tests/Extensions/PropertyExtensionsTest.cs
+++ b/test/EFCore.Tests/Extensions/PropertyExtensionsTest.cs
@@ -11,7 +11,8 @@
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit;
-namespace Microsoft.EntityFrameworkCore.Extensions
+// ReSharper disable once CheckNamespace
+namespace Microsoft.EntityFrameworkCore
{
public class PropertyExtensionsTest
{
diff --git a/test/EFCore.Tests/Extensions/QueryableExtensionsTest.cs b/test/EFCore.Tests/Extensions/QueryableExtensionsTest.cs
index c480f8819b3..985e93afd1c 100644
--- a/test/EFCore.Tests/Extensions/QueryableExtensionsTest.cs
+++ b/test/EFCore.Tests/Extensions/QueryableExtensionsTest.cs
@@ -9,14 +9,15 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Diagnostics;
-using Microsoft.EntityFrameworkCore.Extensions.Internal;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.TestModels.Northwind;
using Xunit;
+// ReSharper disable InconsistentNaming
// ReSharper disable RedundantArgumentDefaultValue
-namespace Microsoft.EntityFrameworkCore.Extensions
+// ReSharper disable once CheckNamespace
+namespace Microsoft.EntityFrameworkCore
{
public class QueryableExtensionsTest
{
diff --git a/test/EFCore.Tests/Extensions/ServiceProviderExtensionsTest.cs b/test/EFCore.Tests/Extensions/ServiceProviderExtensionsTest.cs
index b444556eaa7..046bc445c36 100644
--- a/test/EFCore.Tests/Extensions/ServiceProviderExtensionsTest.cs
+++ b/test/EFCore.Tests/Extensions/ServiceProviderExtensionsTest.cs
@@ -5,7 +5,8 @@
using Microsoft.Extensions.DependencyInjection;
using Xunit;
-namespace Microsoft.EntityFrameworkCore.Extensions
+// ReSharper disable InconsistentNaming
+namespace Microsoft.EntityFrameworkCore
{
public class ServiceProviderExtensionsTest
{