diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 0c6520bc93a..f05c4bf3114 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,58 +1,58 @@ - + https://github.com/dotnet/runtime - 4122c63a13cfe40e97ac1f9ef01d8110a66943f4 + 40d2134aa50389d70fd845a7a6c06f46383e602e - + https://github.com/dotnet/runtime - 4122c63a13cfe40e97ac1f9ef01d8110a66943f4 + 40d2134aa50389d70fd845a7a6c06f46383e602e - + https://github.com/dotnet/runtime - 4122c63a13cfe40e97ac1f9ef01d8110a66943f4 + 40d2134aa50389d70fd845a7a6c06f46383e602e - + https://github.com/dotnet/runtime - 4122c63a13cfe40e97ac1f9ef01d8110a66943f4 + 40d2134aa50389d70fd845a7a6c06f46383e602e - + https://github.com/dotnet/runtime - 4122c63a13cfe40e97ac1f9ef01d8110a66943f4 + 40d2134aa50389d70fd845a7a6c06f46383e602e - + https://github.com/dotnet/runtime - 4122c63a13cfe40e97ac1f9ef01d8110a66943f4 + 40d2134aa50389d70fd845a7a6c06f46383e602e - + https://github.com/dotnet/runtime - 4122c63a13cfe40e97ac1f9ef01d8110a66943f4 + 40d2134aa50389d70fd845a7a6c06f46383e602e - + https://github.com/dotnet/runtime - 4122c63a13cfe40e97ac1f9ef01d8110a66943f4 + 40d2134aa50389d70fd845a7a6c06f46383e602e - + https://github.com/dotnet/runtime - 4122c63a13cfe40e97ac1f9ef01d8110a66943f4 + 40d2134aa50389d70fd845a7a6c06f46383e602e - + https://github.com/dotnet/runtime - 4122c63a13cfe40e97ac1f9ef01d8110a66943f4 + 40d2134aa50389d70fd845a7a6c06f46383e602e - + https://github.com/dotnet/runtime - 4122c63a13cfe40e97ac1f9ef01d8110a66943f4 + 40d2134aa50389d70fd845a7a6c06f46383e602e - + https://github.com/dotnet/runtime - 4122c63a13cfe40e97ac1f9ef01d8110a66943f4 + 40d2134aa50389d70fd845a7a6c06f46383e602e - + https://github.com/dotnet/runtime - 4122c63a13cfe40e97ac1f9ef01d8110a66943f4 + 40d2134aa50389d70fd845a7a6c06f46383e602e diff --git a/eng/Versions.props b/eng/Versions.props index 1627f6f945f..d284d66abf7 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -16,19 +16,19 @@ False - 8.0.0-rc.2.23426.4 - 8.0.0-rc.2.23426.4 - 8.0.0-rc.2.23426.4 - 8.0.0-rc.2.23426.4 - 8.0.0-rc.2.23426.4 - 8.0.0-rc.2.23426.4 - 8.0.0-rc.2.23426.4 - 8.0.0-rc.2.23426.4 - 8.0.0-rc.2.23426.4 - 8.0.0-rc.2.23426.4 - 8.0.0-rc.2.23426.4 - 8.0.0-rc.2.23426.4 - 8.0.0-rc.2.23426.4 + 8.0.0-rc.2.23430.5 + 8.0.0-rc.2.23430.5 + 8.0.0-rc.2.23430.5 + 8.0.0-rc.2.23430.5 + 8.0.0-rc.2.23430.5 + 8.0.0-rc.2.23430.5 + 8.0.0-rc.2.23430.5 + 8.0.0-rc.2.23430.5 + 8.0.0-rc.2.23430.5 + 8.0.0-rc.2.23430.5 + 8.0.0-rc.2.23430.5 + 8.0.0-rc.2.23430.5 + 8.0.0-rc.2.23430.5 8.0.0-beta.23419.1 diff --git a/src/EFCore.Design/Extensions/MethodCallCodeFragmentExtensions.cs b/src/EFCore.Design/Extensions/MethodCallCodeFragmentExtensions.cs new file mode 100644 index 00000000000..e1c3e4d54bd --- /dev/null +++ b/src/EFCore.Design/Extensions/MethodCallCodeFragmentExtensions.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Design; + +/// +/// Design-time extensions. +/// +public static class MethodCallCodeFragmentExtensions +{ + /// + /// Gets the using statements required for this method call. + /// + /// The method call. + /// The usings. + public static IEnumerable GetRequiredUsings(this MethodCallCodeFragment methodCall) + { + var method = methodCall.MethodInfo; + if (method?.IsStatic == true) + { + yield return method.DeclaringType!.Namespace!; + } + + foreach (var argument in methodCall.Arguments) + { + if (argument is NestedClosureCodeFragment nestedClosure) + { + foreach (var nestedUsing in nestedClosure.MethodCalls.SelectMany(GetRequiredUsings)) + { + yield return nestedUsing; + } + } + else if (argument is not null) + { + yield return argument.GetType().Namespace!; + } + } + } +} diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.cs index 79dd3634758..c28d92bf0a0 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.cs @@ -101,8 +101,11 @@ public virtual string TransformText() } + var useProviderCall = providerCode.GenerateUseProvider(Options.ConnectionString); + usings.AddRange(useProviderCall.GetRequiredUsings()); + this.Write(" => optionsBuilder"); - this.Write(this.ToStringHelper.ToStringWithCulture(code.Fragment(providerCode.GenerateUseProvider(Options.ConnectionString), indent: 3))); + this.Write(this.ToStringHelper.ToStringWithCulture(code.Fragment(useProviderCall, indent: 3))); this.Write(";\r\n\r\n"); } @@ -617,7 +620,7 @@ public class CSharpDbContextGeneratorBase /// /// The string builder that generation-time code is using to assemble generated output /// - protected System.Text.StringBuilder GenerationEnvironment + public System.Text.StringBuilder GenerationEnvironment { get { diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.tt b/src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.tt index 80e3c9eca95..0741e40e6b9 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.tt +++ b/src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.tt @@ -78,8 +78,11 @@ public partial class <#= Options.ContextName #> : DbContext #warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263. <# } + + var useProviderCall = providerCode.GenerateUseProvider(Options.ConnectionString); + usings.AddRange(useProviderCall.GetRequiredUsings()); #> - => optionsBuilder<#= code.Fragment(providerCode.GenerateUseProvider(Options.ConnectionString), indent: 3) #>; + => optionsBuilder<#= code.Fragment(useProviderCall, indent: 3) #>; <# } diff --git a/src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs b/src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs index e5e261e048c..e12b70645f4 100644 --- a/src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs @@ -182,15 +182,17 @@ public virtual Expression Translate(SelectExpression selectExpression, Expressio if (expression is MethodCallExpression methodCallExpression) { - if (methodCallExpression.Method.IsGenericMethod - && methodCallExpression.Method.DeclaringType == typeof(Enumerable) - && methodCallExpression.Method.Name == nameof(Enumerable.ToList) - && methodCallExpression.Arguments.Count == 1 - && methodCallExpression.Arguments[0].Type.TryGetElementType(typeof(IQueryable<>)) != null) + if (methodCallExpression is + { + Method.IsGenericMethod: true, + Method.Name: nameof(Enumerable.ToList), + Method: var method, + Arguments: [var argument] + } + && method.DeclaringType == typeof(Enumerable) + && argument.Type.TryGetElementType(typeof(IQueryable<>)) != null) { - var subquery = _queryableMethodTranslatingExpressionVisitor.TranslateSubquery( - methodCallExpression.Arguments[0]); - if (subquery != null) + if (_queryableMethodTranslatingExpressionVisitor.TranslateSubquery(argument) is ShapedQueryExpression subquery) { _clientProjections!.Add(subquery); // expression.Type here will be List diff --git a/src/EFCore.Relational/Query/SqlExpressions/CrossApplyExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/CrossApplyExpression.cs index 9f58ec09b4b..c1ba6d964eb 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/CrossApplyExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/CrossApplyExpression.cs @@ -38,7 +38,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// /// The property of the result. /// This expression if no children changed, or an expression with the updated children. - public virtual CrossApplyExpression Update(TableExpressionBase table) + public override CrossApplyExpression Update(TableExpressionBase table) => table != Table ? new CrossApplyExpression(table, GetAnnotations()) : this; diff --git a/src/EFCore.Relational/Query/SqlExpressions/CrossJoinExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/CrossJoinExpression.cs index c5e6c4eef09..89f87da89dc 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/CrossJoinExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/CrossJoinExpression.cs @@ -38,7 +38,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// /// The property of the result. /// This expression if no children changed, or an expression with the updated children. - public virtual CrossJoinExpression Update(TableExpressionBase table) + public override CrossJoinExpression Update(TableExpressionBase table) => table != Table ? new CrossJoinExpression(table, GetAnnotations()) : this; diff --git a/src/EFCore.Relational/Query/SqlExpressions/InnerJoinExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/InnerJoinExpression.cs index dc4fc43fa47..f3287684c79 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/InnerJoinExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/InnerJoinExpression.cs @@ -48,11 +48,22 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// The property of the result. /// The property of the result. /// This expression if no children changed, or an expression with the updated children. - public virtual InnerJoinExpression Update(TableExpressionBase table, SqlExpression joinPredicate) + public override InnerJoinExpression Update(TableExpressionBase table, SqlExpression joinPredicate) => table != Table || joinPredicate != JoinPredicate ? new InnerJoinExpression(table, joinPredicate, GetAnnotations()) : this; + /// + /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will + /// return this expression. + /// + /// The property of the result. + /// This expression if no children changed, or an expression with the updated children. + public override InnerJoinExpression Update(TableExpressionBase table) + => table != Table + ? new InnerJoinExpression(table, JoinPredicate, GetAnnotations()) + : this; + /// protected override TableExpressionBase CreateWithAnnotations(IEnumerable annotations) => new InnerJoinExpression(Table, JoinPredicate, annotations); diff --git a/src/EFCore.Relational/Query/SqlExpressions/JoinExpressionBase.cs b/src/EFCore.Relational/Query/SqlExpressions/JoinExpressionBase.cs index 7e5653e041f..15fae8a45db 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/JoinExpressionBase.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/JoinExpressionBase.cs @@ -39,6 +39,14 @@ protected JoinExpressionBase(TableExpressionBase table, IEnumerable /// public virtual TableExpressionBase Table { get; } + /// + /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will + /// return this expression. + /// + /// The property of the result. + /// This expression if no children changed, or an expression with the updated children. + public abstract JoinExpressionBase Update(TableExpressionBase table); + /// public override bool Equals(object? obj) => obj != null diff --git a/src/EFCore.Relational/Query/SqlExpressions/LeftJoinExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/LeftJoinExpression.cs index ca8e42132ec..b0eceb1e0a2 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/LeftJoinExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/LeftJoinExpression.cs @@ -48,11 +48,22 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// The property of the result. /// The property of the result. /// This expression if no children changed, or an expression with the updated children. - public virtual LeftJoinExpression Update(TableExpressionBase table, SqlExpression joinPredicate) + public override LeftJoinExpression Update(TableExpressionBase table, SqlExpression joinPredicate) => table != Table || joinPredicate != JoinPredicate ? new LeftJoinExpression(table, joinPredicate, GetAnnotations()) : this; + /// + /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will + /// return this expression. + /// + /// The property of the result. + /// This expression if no children changed, or an expression with the updated children. + public override LeftJoinExpression Update(TableExpressionBase table) + => table != Table + ? new LeftJoinExpression(table, JoinPredicate, GetAnnotations()) + : this; + /// protected override TableExpressionBase CreateWithAnnotations(IEnumerable annotations) => new LeftJoinExpression(Table, JoinPredicate, annotations); diff --git a/src/EFCore.Relational/Query/SqlExpressions/OuterApplyExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/OuterApplyExpression.cs index 2cc30f8dda0..7f20fd74494 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/OuterApplyExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/OuterApplyExpression.cs @@ -38,7 +38,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// /// The property of the result. /// This expression if no children changed, or an expression with the updated children. - public virtual OuterApplyExpression Update(TableExpressionBase table) + public override OuterApplyExpression Update(TableExpressionBase table) => table != Table ? new OuterApplyExpression(table, GetAnnotations()) : this; diff --git a/src/EFCore.Relational/Query/SqlExpressions/PredicateJoinExpressionBase.cs b/src/EFCore.Relational/Query/SqlExpressions/PredicateJoinExpressionBase.cs index 8c40d3043a0..a1df3330052 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/PredicateJoinExpressionBase.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/PredicateJoinExpressionBase.cs @@ -44,6 +44,15 @@ protected PredicateJoinExpressionBase( /// public virtual SqlExpression JoinPredicate { get; } + /// + /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will + /// return this expression. + /// + /// The property of the result. + /// The property of the result. + /// This expression if no children changed, or an expression with the updated children. + public abstract PredicateJoinExpressionBase Update(TableExpressionBase table, SqlExpression joinPredicate); + /// public override bool Equals(object? obj) => obj != null diff --git a/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs b/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs index 06097c77f64..46aa60e1b2a 100644 --- a/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs +++ b/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs @@ -225,11 +225,12 @@ protected override CoreTypeMapping FindMapping(in TypeMappingInfo mappingInfo) Type? providerType, CoreTypeMapping? elementMapping) { - var elementType = modelType.TryGetElementType(typeof(IEnumerable<>))!; + if (TryFindJsonCollectionMapping( + info.CoreTypeMappingInfo, modelType, providerType, ref elementMapping, out var collectionReaderWriter)) + { + var elementType = modelType.TryGetElementType(typeof(IEnumerable<>))!; - return TryFindJsonCollectionMapping( - info.CoreTypeMappingInfo, modelType, providerType, ref elementMapping, out var collectionReaderWriter) - ? (RelationalTypeMapping)FindMapping( + return (RelationalTypeMapping)FindMapping( info.WithConverter( // Note that the converter info is only used temporarily here and never creates an instance. new ValueConverterInfo(modelType, typeof(string), _ => null!)))! @@ -242,8 +243,10 @@ protected override CoreTypeMapping FindMapping(in TypeMappingInfo mappingInfo) : typeof(ListComparer<>).MakeGenericType(elementMapping!.Comparer.Type), elementMapping!.Comparer), elementMapping, - collectionReaderWriter) - : null; + collectionReaderWriter); + } + + return null; } /// diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerJsonPostprocessor.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerJsonPostprocessor.cs index b7499aa02a3..4ec630254f5 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerJsonPostprocessor.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerJsonPostprocessor.cs @@ -92,12 +92,9 @@ public virtual Expression Process(Expression expression) table = table switch { - InnerJoinExpression ij => ij.Update(newOpenJsonExpression, ij.JoinPredicate), - LeftJoinExpression lj => lj.Update(newOpenJsonExpression, lj.JoinPredicate), - CrossJoinExpression cj => cj.Update(newOpenJsonExpression), - CrossApplyExpression ca => ca.Update(newOpenJsonExpression), - OuterApplyExpression oa => oa.Update(newOpenJsonExpression), - _ => newOpenJsonExpression, + JoinExpressionBase j => j.Update(newOpenJsonExpression), + SqlServerOpenJsonExpression => newOpenJsonExpression, + _ => throw new UnreachableException() }; foreach (var columnInfo in openJsonExpression.ColumnInfos!) diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs index d9362c84df3..fea04b1d908 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs @@ -220,8 +220,7 @@ static SqlServerTypeMappingSource() /// public SqlServerTypeMappingSource( TypeMappingSourceDependencies dependencies, - RelationalTypeMappingSourceDependencies relationalDependencies, - ISqlServerSingletonOptions sqlServerSingletonOptions) + RelationalTypeMappingSourceDependencies relationalDependencies) : base(dependencies, relationalDependencies) { } diff --git a/src/EFCore/ChangeTracking/ListComparer.cs b/src/EFCore/ChangeTracking/ListComparer.cs index 2f9220722b0..9d46113cedd 100644 --- a/src/EFCore/ChangeTracking/ListComparer.cs +++ b/src/EFCore/ChangeTracking/ListComparer.cs @@ -103,7 +103,7 @@ private static int GetHashCode(IEnumerable source, ValueComparer Snapshot(IEnumerable source, ValueComparer elementComparer) { - if (!(source is IList sourceList)) + if (source is not IList sourceList) { throw new InvalidOperationException( CoreStrings.BadListType( diff --git a/src/EFCore/ChangeTracking/NullableValueTypeListComparer.cs b/src/EFCore/ChangeTracking/NullableValueTypeListComparer.cs index d2e8ac223ee..65740f52934 100644 --- a/src/EFCore/ChangeTracking/NullableValueTypeListComparer.cs +++ b/src/EFCore/ChangeTracking/NullableValueTypeListComparer.cs @@ -104,7 +104,7 @@ private static int GetHashCode(IEnumerable source, ValueComparer Snapshot(IEnumerable source, ValueComparer elementComparer) { - if (!(source is IList sourceList)) + if (source is not IList sourceList) { throw new InvalidOperationException( CoreStrings.BadListType( diff --git a/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs b/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs index 24ddf62a94b..4c29fc5b471 100644 --- a/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs +++ b/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs @@ -827,8 +827,7 @@ private static SqlServerTypeMappingSource CreateTypeMappingSource( params IRelationalTypeMappingSourcePlugin[] plugins) => new( TestServiceFactory.Instance.Create(), - new RelationalTypeMappingSourceDependencies(plugins), - new SqlServerSingletonOptions()); + new RelationalTypeMappingSourceDependencies(plugins)); private class TestTypeMappingPlugin : IRelationalTypeMappingSourcePlugin { diff --git a/test/EFCore.Design.Tests/Extensions/MethodCallCodeFragmentExtensionsTest.cs b/test/EFCore.Design.Tests/Extensions/MethodCallCodeFragmentExtensionsTest.cs new file mode 100644 index 00000000000..87f6a27819b --- /dev/null +++ b/test/EFCore.Design.Tests/Extensions/MethodCallCodeFragmentExtensionsTest.cs @@ -0,0 +1,75 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Extensions +{ + public class MethodCallCodeFragmentExtensionsTest + { + [ConditionalFact] + public void GetRequiredUsings_works() + { + var methodCall = new MethodCallCodeFragment( + typeof(Namespace1.TestExtensions1) + .GetRuntimeMethod( + nameof(Namespace1.TestExtensions1.Extension1), + new[] + { + typeof(MethodCallCodeFragmentExtensionsTest), + typeof(Action) + }), + new NestedClosureCodeFragment( + "x", + new MethodCallCodeFragment( + typeof(Namespace2.TestExtensions2) + .GetRuntimeMethod( + nameof(Namespace2.TestExtensions2.Extension2), + new[] + { + typeof(MethodCallCodeFragmentExtensionsTest), + typeof(Namespace3.TestArgument) + }), + new Namespace3.TestArgument()))); + + + var usings = methodCall.GetRequiredUsings(); + + Assert.Equal( + new[] + { + "Microsoft.EntityFrameworkCore.Extensions.Namespace1", + "Microsoft.EntityFrameworkCore.Extensions.Namespace2", + "Microsoft.EntityFrameworkCore.Extensions.Namespace3" + }, + usings); + } + } + + namespace Namespace1 + { + internal static class TestExtensions1 + { + public static void Extension1( + this MethodCallCodeFragmentExtensionsTest extendedObject, + Action closure) + => throw new NotImplementedException(); + } + } + + namespace Namespace2 + { + internal static class TestExtensions2 + { + public static void Extension2( + this MethodCallCodeFragmentExtensionsTest extendedObject, + Namespace3.TestArgument argument) + => throw new NotImplementedException(); + } + } + + namespace Namespace3 + { + internal class TestArgument + { + } + } +} diff --git a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs index ff59d0d87d8..765ff612e6a 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs @@ -20,8 +20,7 @@ public void Generate_separates_operations_by_a_blank_line() new CSharpHelper( new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions())))); + TestServiceFactory.Instance.Create())))); var builder = new IndentedStringBuilder(); @@ -3160,8 +3159,7 @@ private void Test(T operation, string expectedCode, Action assert) new IRelationalTypeMappingSourcePlugin[] { new SqlServerNetTopologySuiteTypeMappingSourcePlugin(NtsGeometryServices.Instance) - }), - new SqlServerSingletonOptions())))); + }))))); var builder = new IndentedStringBuilder(); generator.Generate("mb", new[] { operation }, builder); diff --git a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs index d798e071d2a..3153973338f 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs @@ -349,8 +349,7 @@ private static void MissingAnnotationCheck( { var sqlServerTypeMappingSource = new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()); + TestServiceFactory.Instance.Create()); var sqlServerAnnotationCodeGenerator = new SqlServerAnnotationCodeGenerator( new AnnotationCodeGeneratorDependencies(sqlServerTypeMappingSource)); @@ -452,8 +451,7 @@ public void Snapshot_with_enum_discriminator_uses_converted_values() { var sqlServerTypeMappingSource = new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()); + TestServiceFactory.Instance.Create()); var codeHelper = new CSharpHelper( sqlServerTypeMappingSource); @@ -510,8 +508,7 @@ private static void AssertConverter(ValueConverter valueConverter, string expect var sqlServerTypeMappingSource = new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()); + TestServiceFactory.Instance.Create()); var codeHelper = new CSharpHelper(sqlServerTypeMappingSource); diff --git a/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs b/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs index efc9abacced..18c50430198 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs @@ -58,8 +58,7 @@ private IMigrationsScaffolder CreateMigrationScaffolder() var idGenerator = new MigrationsIdGenerator(); var sqlServerTypeMappingSource = new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()); + TestServiceFactory.Instance.Create()); var sqlServerAnnotationCodeGenerator = new SqlServerAnnotationCodeGenerator( new AnnotationCodeGeneratorDependencies(sqlServerTypeMappingSource)); var code = new CSharpHelper(sqlServerTypeMappingSource); diff --git a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs index 381b4adbb79..dc5f28bf12b 100644 --- a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs +++ b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs @@ -7769,8 +7769,7 @@ protected CSharpMigrationsGenerator CreateMigrationsGenerator() new IRelationalTypeMappingSourcePlugin[] { new SqlServerNetTopologySuiteTypeMappingSourcePlugin(NtsGeometryServices.Instance) - }), - new SqlServerSingletonOptions()); + })); var codeHelper = new CSharpHelper(sqlServerTypeMappingSource); diff --git a/test/EFCore.Design.Tests/Query/LinqToCSharpTranslatorTest.cs b/test/EFCore.Design.Tests/Query/LinqToCSharpTranslatorTest.cs index e517ac61147..f814818f942 100644 --- a/test/EFCore.Design.Tests/Query/LinqToCSharpTranslatorTest.cs +++ b/test/EFCore.Design.Tests/Query/LinqToCSharpTranslatorTest.cs @@ -1835,8 +1835,7 @@ private void AssertCore(Expression expression, bool isStatement, string expected { var typeMappingSource = new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - new RelationalTypeMappingSourceDependencies(new IRelationalTypeMappingSourcePlugin[0]), - new SqlServerSingletonOptions()); + new RelationalTypeMappingSourceDependencies(new IRelationalTypeMappingSourcePlugin[0])); var translator = new CSharpHelper(typeMappingSource); var namespaces = new HashSet(); diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs index 0c1f0d4311e..f0c8ea07dc9 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs @@ -404,6 +404,5 @@ private static ScaffoldingTypeMapper CreateMapper() => new( new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions())); + TestServiceFactory.Instance.Create())); } diff --git a/test/EFCore.Relational.Specification.Tests/Query/PrimitiveCollectionsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/PrimitiveCollectionsQueryRelationalTestBase.cs new file mode 100644 index 00000000000..e2e7ae9e91e --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/PrimitiveCollectionsQueryRelationalTestBase.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query; + +public class PrimitiveCollectionsQueryRelationalTestBase : PrimitiveCollectionsQueryTestBase + where TFixture : PrimitiveCollectionsQueryTestBase.PrimitiveCollectionsQueryFixtureBase, new() +{ + public PrimitiveCollectionsQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override Task Column_collection_Concat_parameter_collection_equality_inline_collection(bool async) + => AssertTranslationFailed(() => base.Column_collection_Concat_parameter_collection_equality_inline_collection(async)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override Task Column_collection_equality_inline_collection_with_parameters(bool async) + => AssertTranslationFailed(() => base.Column_collection_equality_inline_collection_with_parameters(async)); + + [ConditionalFact] + public override void Parameter_collection_in_subquery_and_Convert_as_compiled_query() + { + // The array indexing is translated as a subquery over e.g. OPENJSON with LIMIT/OFFSET. + // Since there's a CAST over that, the type mapping inference from the other side (p.String) doesn't propagate inside to the + // subquery. In this case, the CAST operand gets the default CLR type mapping, but that's object in this case. + // We should apply the default type mapping to the parameter, but need to figure out the exact rules when to do this. + var exception = + Assert.Throws(() => base.Parameter_collection_in_subquery_and_Convert_as_compiled_query()); + + Assert.Contains("in the SQL tree does not have a type mapping assigned", exception.Message); + } + + public override async Task Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query(bool async) + { + var message = (await Assert.ThrowsAsync( + () => base.Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query(async))).Message; + + Assert.Equal(RelationalStrings.SetOperationsRequireAtLeastOneSideWithValidTypeMapping("Union"), message); + } +} diff --git a/test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs index f6bc23f3eec..d56c6bdd7a2 100644 --- a/test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs @@ -599,14 +599,15 @@ public virtual Task Column_collection_equality_parameter_collection(bool async) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task Column_collection_Concat_parameter_collection_equality_inline_collection_not_supported(bool async) + public virtual async Task Column_collection_Concat_parameter_collection_equality_inline_collection(bool async) { var ints = new[] { 1, 10 }; - await AssertTranslationFailed( - () => AssertQuery( - async, - ss => ss.Set().Where(c => c.Ints.Concat(ints) == new[] { 1, 11, 111, 1, 10 }))); + await AssertQuery( + async, + ss => ss.Set().Where(c => c.Ints.Concat(ints) == new[] { 1, 11, 111, 1, 10 }), + ss => ss.Set().Where(c => c.Ints.Concat(ints).SequenceEqual(new[] { 1, 11, 111, 1, 10 })), + entryCount: 1); } [ConditionalTheory] @@ -620,15 +621,15 @@ public virtual Task Column_collection_equality_inline_collection(bool async) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Column_collection_equality_inline_collection_with_parameters(bool async) + public virtual async Task Column_collection_equality_inline_collection_with_parameters(bool async) { var (i, j) = (1, 10); - return AssertTranslationFailed( - () => AssertQuery( - async, - ss => ss.Set().Where(c => c.Ints == new[] { i, j }), - entryCount: 1)); + await AssertQuery( + async, + ss => ss.Set().Where(c => c.Ints == new[] { i, j }), + ss => ss.Set().Where(c => c.Ints.SequenceEqual(new[] { i, j })), + entryCount: 1); } [ConditionalTheory] @@ -696,19 +697,13 @@ public virtual Task Parameter_collection_in_subquery_Union_column_collection_nes [ConditionalFact] public virtual void Parameter_collection_in_subquery_and_Convert_as_compiled_query() { - // The array indexing is translated as a subquery over e.g. OPENJSON with LIMIT/OFFSET. - // Since there's a CAST over that, the type mapping inference from the other side (p.String) doesn't propagate inside to the - // subquery. In this case, the CAST operand gets the default CLR type mapping, but that's object in this case. - // We should apply the default type mapping to the parameter, but need to figure out the exact rules when to do this. var query = EF.CompileQuery( (PrimitiveCollectionsContext context, object[] parameters) => context.Set().Where(p => p.String == (string)parameters[0])); using var context = Fixture.CreateContext(); - var exception = Assert.Throws(() => query(context, new[] { "foo" }).ToList()); - - Assert.Contains("in the SQL tree does not have a type mapping assigned", exception.Message); + _ = query(context, new[] { "foo" }).ToList(); } [ConditionalTheory] @@ -723,12 +718,7 @@ public virtual async Task Parameter_collection_in_subquery_Union_another_paramet var ints1 = new[] { 10, 111 }; var ints2 = new[] { 7, 42 }; - compiledQuery(context, ints1, ints2).ToList(); - - //var message = Assert.Throws( - // () => compiledQuery(context, ints1, ints2).ToList()).Message; - - //Assert.Equal(RelationalStrings.SetOperationsRequireAtLeastOneSideWithValidTypeMapping("Union"), message); + _ = compiledQuery(context, ints1, ints2).ToList(); } [ConditionalTheory] @@ -774,7 +764,7 @@ public virtual Task Project_collection_of_datetimes_filtered(bool async) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Project_collection_of_ints_with_paging(bool async) + public virtual Task Project_collection_of_nullable_ints_with_paging(bool async) => AssertQuery( async, ss => ss.Set().OrderBy(x => x.Id).Select(x => x.NullableInts.Take(20).ToList()), @@ -783,7 +773,7 @@ public virtual Task Project_collection_of_ints_with_paging(bool async) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Project_collection_of_ints_with_paging2(bool async) + public virtual Task Project_collection_of_nullable_ints_with_paging2(bool async) => AssertQuery( async, ss => ss.Set().OrderBy(x => x.Id).Select(x => x.NullableInts.OrderBy(x => x).Skip(1).ToList()), @@ -792,7 +782,7 @@ public virtual Task Project_collection_of_ints_with_paging2(bool async) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Project_collection_of_ints_with_paging3(bool async) + public virtual Task Project_collection_of_nullable_ints_with_paging3(bool async) => AssertQuery( async, ss => ss.Set().OrderBy(x => x.Id).Select(x => x.NullableInts.Skip(2).ToList()), diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQueryOldSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQueryOldSqlServerTest.cs index f3dce36adad..1f2c600627b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQueryOldSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQueryOldSqlServerTest.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.EntityFrameworkCore.SqlServer.Internal; +using Xunit.Sdk; namespace Microsoft.EntityFrameworkCore.Query; @@ -10,7 +11,7 @@ namespace Microsoft.EntityFrameworkCore.Query; /// This exercises the older translation paths for e.g. Contains, to make sure things work for providers with no queryable constant/ /// parameter support. /// -public class PrimitiveCollectionsQueryOldSqlServerTest : PrimitiveCollectionsQueryTestBase< +public class PrimitiveCollectionsQueryOldSqlServerTest : PrimitiveCollectionsQueryRelationalTestBase< PrimitiveCollectionsQueryOldSqlServerTest.PrimitiveCollectionsQueryOldSqlServerFixture> { public PrimitiveCollectionsQueryOldSqlServerTest(PrimitiveCollectionsQueryOldSqlServerFixture fixture, ITestOutputHelper testOutputHelper) @@ -464,9 +465,9 @@ FROM [PrimitiveCollectionsEntity] AS [p] """); } - public override async Task Column_collection_Concat_parameter_collection_equality_inline_collection_not_supported(bool async) + public override async Task Column_collection_Concat_parameter_collection_equality_inline_collection(bool async) { - await base.Column_collection_Concat_parameter_collection_equality_inline_collection_not_supported(async); + await base.Column_collection_Concat_parameter_collection_equality_inline_collection(async); AssertSql(); } @@ -510,8 +511,9 @@ public override Task Parameter_collection_in_subquery_Count_as_compiled_query(bo public override Task Column_collection_in_subquery_Union_parameter_collection(bool async) => AssertCompatibilityLevelTooLow(() => base.Column_collection_in_subquery_Union_parameter_collection(async)); + // Base implementation asserts that a different exception is thrown public override Task Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query(bool async) - => AssertCompatibilityLevelTooLow(() => base.Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query(async)); + => Assert.ThrowsAsync(() => base.Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query(async)); public override async Task Project_collection_of_ints_simple(bool async) { @@ -533,9 +535,9 @@ public override Task Project_collection_of_datetimes_filtered(bool async) // we don't propagate error details from projection => AssertTranslationFailed(() => base.Project_collection_of_datetimes_filtered(async)); - public override async Task Project_collection_of_ints_with_paging(bool async) + public override async Task Project_collection_of_nullable_ints_with_paging(bool async) { - await base.Project_collection_of_ints_with_paging(async); + await base.Project_collection_of_nullable_ints_with_paging(async); // client eval AssertSql( @@ -546,13 +548,13 @@ ORDER BY [p].[Id] """); } - public override Task Project_collection_of_ints_with_paging2(bool async) + public override Task Project_collection_of_nullable_ints_with_paging2(bool async) // we don't propagate error details from projection - => AssertTranslationFailed(() => base.Project_collection_of_ints_with_paging2(async)); + => AssertTranslationFailed(() => base.Project_collection_of_nullable_ints_with_paging2(async)); - public override async Task Project_collection_of_ints_with_paging3(bool async) + public override async Task Project_collection_of_nullable_ints_with_paging3(bool async) { - await base.Project_collection_of_ints_with_paging3(async); + await base.Project_collection_of_nullable_ints_with_paging3(async); // client eval AssertSql( diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs index e2ddaa9a82f..84e59a15cbc 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs @@ -5,7 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable enable -public class PrimitiveCollectionsQuerySqlServerTest : PrimitiveCollectionsQueryTestBase< +public class PrimitiveCollectionsQuerySqlServerTest : PrimitiveCollectionsQueryRelationalTestBase< PrimitiveCollectionsQuerySqlServerTest.PrimitiveCollectionsQuerySqlServerFixture> { public PrimitiveCollectionsQuerySqlServerTest(PrimitiveCollectionsQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) @@ -877,9 +877,9 @@ FROM [PrimitiveCollectionsEntity] AS [p] """); } - public override async Task Column_collection_Concat_parameter_collection_equality_inline_collection_not_supported(bool async) + public override async Task Column_collection_Concat_parameter_collection_equality_inline_collection(bool async) { - await base.Column_collection_Concat_parameter_collection_equality_inline_collection_not_supported(async); + await base.Column_collection_Concat_parameter_collection_equality_inline_collection(async); AssertSql(); } @@ -1018,10 +1018,9 @@ OFFSET 1 ROWS public override async Task Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query(bool async) { - var message = (await Assert.ThrowsAsync( - () => base.Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query(async))).Message; + await base.Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query(async); - Assert.Equal(RelationalStrings.SetOperationsRequireAtLeastOneSideWithValidTypeMapping("Union"), message); + AssertSql(); } public override async Task Column_collection_in_subquery_Union_parameter_collection(bool async) @@ -1093,9 +1092,9 @@ WHERE DATEPART(day, CAST([d].[value] AS datetime2)) <> 1 """); } - public override async Task Project_collection_of_ints_with_paging(bool async) + public override async Task Project_collection_of_nullable_ints_with_paging(bool async) { - await base.Project_collection_of_ints_with_paging(async); + await base.Project_collection_of_nullable_ints_with_paging(async); AssertSql( """ @@ -1110,9 +1109,9 @@ ORDER BY CAST([n].[key] AS int) """); } - public override async Task Project_collection_of_ints_with_paging2(bool async) + public override async Task Project_collection_of_nullable_ints_with_paging2(bool async) { - await base.Project_collection_of_ints_with_paging2(async); + await base.Project_collection_of_nullable_ints_with_paging2(async); AssertSql( """ @@ -1128,9 +1127,9 @@ OFFSET 1 ROWS """); } - public override async Task Project_collection_of_ints_with_paging3(bool async) + public override async Task Project_collection_of_nullable_ints_with_paging3(bool async) { - await base.Project_collection_of_ints_with_paging3(async); + await base.Project_collection_of_nullable_ints_with_paging3(async); AssertSql( """ diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyFixture.cs index 2a108b2e6f6..aaa65262e3b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyFixture.cs @@ -40,9 +40,8 @@ protected class ReplacementTypeMappingSource : SqlServerTypeMappingSource { public ReplacementTypeMappingSource( TypeMappingSourceDependencies dependencies, - RelationalTypeMappingSourceDependencies relationalDependencies, - ISqlServerSingletonOptions sqlServerSingletonOptions) - : base(dependencies, relationalDependencies, sqlServerSingletonOptions) + RelationalTypeMappingSourceDependencies relationalDependencies) + : base(dependencies, relationalDependencies) { } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryFixture.cs index 8084b613b7d..05bd58cabb9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryFixture.cs @@ -37,9 +37,8 @@ protected class ReplacementTypeMappingSource : SqlServerTypeMappingSource { public ReplacementTypeMappingSource( TypeMappingSourceDependencies dependencies, - RelationalTypeMappingSourceDependencies relationalDependencies, - ISqlServerSingletonOptions sqlServerSingletonOptions) - : base(dependencies, relationalDependencies, sqlServerSingletonOptions) + RelationalTypeMappingSourceDependencies relationalDependencies) + : base(dependencies, relationalDependencies) { } diff --git a/test/EFCore.SqlServer.FunctionalTests/Update/SqlServerUpdateSqlGeneratorTest.cs b/test/EFCore.SqlServer.FunctionalTests/Update/SqlServerUpdateSqlGeneratorTest.cs index 7de26bdcb11..f361aa68484 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Update/SqlServerUpdateSqlGeneratorTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Update/SqlServerUpdateSqlGeneratorTest.cs @@ -21,8 +21,7 @@ protected override IUpdateSqlGenerator CreateSqlGenerator() new RelationalSqlGenerationHelperDependencies()), new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()))); + TestServiceFactory.Instance.Create()))); } protected override TestHelpers TestHelpers diff --git a/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs b/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs index 6ec6b2c0487..0151c3cae4f 100644 --- a/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs +++ b/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs @@ -394,6 +394,5 @@ private SqlServerAnnotationCodeGenerator CreateGenerator() new JsonValueReaderWriterSource(new JsonValueReaderWriterSourceDependencies()), Array.Empty()), new RelationalTypeMappingSourceDependencies( - Array.Empty()), - new SqlServerSingletonOptions()))); + Array.Empty())))); } diff --git a/test/EFCore.SqlServer.Tests/SqlServerSequenceValueGeneratorTest.cs b/test/EFCore.SqlServer.Tests/SqlServerSequenceValueGeneratorTest.cs index 13d875b5927..045c5fb35a7 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerSequenceValueGeneratorTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerSequenceValueGeneratorTest.cs @@ -77,8 +77,7 @@ private async Task Generates_sequential_values(bool async) new RelationalSqlGenerationHelperDependencies()), new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()))), + TestServiceFactory.Instance.Create()))), state, CreateConnection(), new FakeRelationalCommandDiagnosticsLogger()); @@ -132,8 +131,7 @@ private async Task>> GenerateValuesInMultipleThreads(int new RelationalSqlGenerationHelperDependencies()), new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()))); + TestServiceFactory.Instance.Create()))); var logger = new FakeRelationalCommandDiagnosticsLogger(); @@ -184,8 +182,7 @@ public void Does_not_generate_temp_values() new RelationalSqlGenerationHelperDependencies()), new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()))), + TestServiceFactory.Instance.Create()))), state, CreateConnection(), new FakeRelationalCommandDiagnosticsLogger()); diff --git a/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingSourceTest.cs b/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingSourceTest.cs index 844936668cb..d919e81acfa 100644 --- a/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingSourceTest.cs +++ b/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingSourceTest.cs @@ -1682,8 +1682,7 @@ public void Plugins_can_override_builtin_mappings() TestServiceFactory.Instance.Create() with { Plugins = new[] { new FakeTypeMappingSourcePlugin() } - }, - new SqlServerSingletonOptions()); + }); Assert.Equal("String", typeMappingSource.GetMapping("datetime2").ClrType.Name); } @@ -1697,8 +1696,7 @@ public RelationalTypeMapping FindMapping(in RelationalTypeMappingInfo mappingInf protected override IRelationalTypeMappingSource CreateRelationalTypeMappingSource() => new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()); + TestServiceFactory.Instance.Create()); private enum LongEnum : long { diff --git a/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs b/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs index 578b66bf203..fe7abf7c45a 100644 --- a/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs +++ b/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs @@ -183,8 +183,7 @@ public virtual void Create_and_clone_UDT_mapping_with_converter() public static RelationalTypeMapping GetMapping(Type type) => new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()) + TestServiceFactory.Instance.Create()) .FindMapping(type); public override void ByteArray_literal_generated_correctly() @@ -418,8 +417,7 @@ public static RelationalTypeMapping GetMapping(string type) public static SqlServerTypeMappingSource GetTypeMappingSource() => new( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()); + TestServiceFactory.Instance.Create()); protected virtual void Test_GenerateCodeLiteral_helper( RelationalTypeMapping typeMapping, @@ -428,8 +426,7 @@ protected virtual void Test_GenerateCodeLiteral_helper( { var typeMappingSource = new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()); + TestServiceFactory.Instance.Create()); var csharpHelper = new CSharpHelper(typeMappingSource); diff --git a/test/EFCore.SqlServer.Tests/Update/SqlServerModificationCommandBatchFactoryTest.cs b/test/EFCore.SqlServer.Tests/Update/SqlServerModificationCommandBatchFactoryTest.cs index 32d2740ce45..63f478c8ab7 100644 --- a/test/EFCore.SqlServer.Tests/Update/SqlServerModificationCommandBatchFactoryTest.cs +++ b/test/EFCore.SqlServer.Tests/Update/SqlServerModificationCommandBatchFactoryTest.cs @@ -20,8 +20,7 @@ public void Uses_MaxBatchSize_specified_in_SqlServerOptionsExtension() var typeMapper = new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()); + TestServiceFactory.Instance.Create()); var logger = new FakeRelationalCommandDiagnosticsLogger(); @@ -57,8 +56,7 @@ public void MaxBatchSize_is_optional() var typeMapper = new SqlServerTypeMappingSource( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()); + TestServiceFactory.Instance.Create()); var logger = new FakeRelationalCommandDiagnosticsLogger(); diff --git a/test/EFCore.SqlServer.Tests/Update/SqlServerModificationCommandBatchTest.cs b/test/EFCore.SqlServer.Tests/Update/SqlServerModificationCommandBatchTest.cs index bf5ecd31201..6ec20c0f8fe 100644 --- a/test/EFCore.SqlServer.Tests/Update/SqlServerModificationCommandBatchTest.cs +++ b/test/EFCore.SqlServer.Tests/Update/SqlServerModificationCommandBatchTest.cs @@ -156,8 +156,7 @@ private static TestSqlServerModificationCommandBatch CreateBatch(int maxBatchSiz private static SqlServerTypeMappingSource CreateTypeMappingSource() => new( TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create(), - new SqlServerSingletonOptions()); + TestServiceFactory.Instance.Create()); private static INonTrackedModificationCommand CreateModificationCommand( string name, diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs index 7c2009996f9..e1d0fcb1eee 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs @@ -6,7 +6,7 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class PrimitiveCollectionsQuerySqliteTest : PrimitiveCollectionsQueryTestBase< +public class PrimitiveCollectionsQuerySqliteTest : PrimitiveCollectionsQueryRelationalTestBase< PrimitiveCollectionsQuerySqliteTest.PrimitiveCollectionsQuerySqlServerFixture> { public PrimitiveCollectionsQuerySqliteTest(PrimitiveCollectionsQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) @@ -858,9 +858,9 @@ public override async Task Column_collection_equality_parameter_collection(bool """); } - public override async Task Column_collection_Concat_parameter_collection_equality_inline_collection_not_supported(bool async) + public override async Task Column_collection_Concat_parameter_collection_equality_inline_collection(bool async) { - await base.Column_collection_Concat_parameter_collection_equality_inline_collection_not_supported(async); + await base.Column_collection_Concat_parameter_collection_equality_inline_collection(async); AssertSql(); } @@ -908,10 +908,9 @@ ORDER BY "i"."key" public override async Task Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query(bool async) { - var message = (await Assert.ThrowsAsync( - () => base.Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query(async))).Message; + await base.Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query(async); - Assert.Equal(RelationalStrings.SetOperationsRequireAtLeastOneSideWithValidTypeMapping("Union"), message); + AssertSql(); } public override async Task Parameter_collection_in_subquery_Union_column_collection_as_compiled_query(bool async) @@ -1056,23 +1055,23 @@ public override async Task Project_collection_of_datetimes_filtered(bool async) (await Assert.ThrowsAsync( () => base.Project_collection_of_datetimes_filtered(async))).Message); - public override async Task Project_collection_of_ints_with_paging(bool async) + public override async Task Project_collection_of_nullable_ints_with_paging(bool async) => Assert.Equal( SqliteStrings.ApplyNotSupported, (await Assert.ThrowsAsync( - () => base.Project_collection_of_ints_with_paging(async))).Message); + () => base.Project_collection_of_nullable_ints_with_paging(async))).Message); - public override async Task Project_collection_of_ints_with_paging2(bool async) + public override async Task Project_collection_of_nullable_ints_with_paging2(bool async) => Assert.Equal( SqliteStrings.ApplyNotSupported, (await Assert.ThrowsAsync( - () => base.Project_collection_of_ints_with_paging2(async))).Message); + () => base.Project_collection_of_nullable_ints_with_paging2(async))).Message); - public override async Task Project_collection_of_ints_with_paging3(bool async) + public override async Task Project_collection_of_nullable_ints_with_paging3(bool async) => Assert.Equal( SqliteStrings.ApplyNotSupported, (await Assert.ThrowsAsync( - () => base.Project_collection_of_ints_with_paging3(async))).Message); + () => base.Project_collection_of_nullable_ints_with_paging3(async))).Message); public override async Task Project_collection_of_ints_with_distinct(bool async) => Assert.Equal(