Skip to content

Commit

Permalink
Fixup for #23376
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Jan 12, 2021
1 parent 4149be5 commit e94c1cb
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 81 deletions.
1 change: 0 additions & 1 deletion src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ when sqlUnaryExpression.IsLogicalNot():
throw new InvalidOperationException(
CosmosStrings.UnsupportedOperatorForSqlExpression(
sqlUnaryExpression.OperatorType, typeof(SqlUnaryExpression).ShortDisplayName()));
;
}

return new SqlUnaryExpression(sqlUnaryExpression.OperatorType, operand, resultType, resultTypeMapping);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// 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 JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
Expand Down Expand Up @@ -44,9 +45,7 @@ public static bool AreCompatible(
var columnNames = foreignKey.Properties.GetColumnNames(storeObject);
var duplicateColumnNames = duplicateForeignKey.Properties.GetColumnNames(storeObject);
if (columnNames is null
|| duplicateColumnNames is null
|| principalTable is null
|| duplicatePrincipalTable is null)
|| duplicateColumnNames is null)
{
if (shouldThrow)
{
Expand All @@ -66,11 +65,13 @@ public static bool AreCompatible(
return false;
}

var principalColumns = foreignKey.PrincipalKey.Properties.GetColumnNames(principalTable.Value);
var duplicatePrincipalColumns = duplicateForeignKey.PrincipalKey.Properties.GetColumnNames(principalTable.Value);
if (principalTable != duplicatePrincipalTable
|| principalColumns == null
|| duplicatePrincipalColumns == null)
if (principalTable is null
|| duplicatePrincipalTable is null
|| principalTable != duplicatePrincipalTable
|| !(foreignKey.PrincipalKey.Properties.GetColumnNames(principalTable.Value)
is IReadOnlyList<string> principalColumns)
|| !(duplicateForeignKey.PrincipalKey.Properties.GetColumnNames(principalTable.Value)
is IReadOnlyList<string> duplicatePrincipalColumns))
{
if (shouldThrow)
{
Expand All @@ -81,7 +82,9 @@ public static bool AreCompatible(
duplicateForeignKey.Properties.Format(),
duplicateForeignKey.DeclaringEntityType.DisplayName(),
foreignKey.DeclaringEntityType.GetSchemaQualifiedTableName(),
foreignKey.GetConstraintName(storeObject, principalTable.Value),
principalTable.HasValue
? foreignKey.GetConstraintName(storeObject, principalTable.Value)
: foreignKey.GetDefaultName(),
principalType.GetSchemaQualifiedTableName(),
duplicatePrincipalType.GetSchemaQualifiedTableName()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ protected override Assembly TargetAssembly

public class CosmosApiConsistencyFixture : ApiConsistencyFixtureBase
{
public override bool TryGetProviderOptionsDelegate(out Action<DbContextOptionsBuilder> configureOptions)
{
configureOptions = b => CosmosTestHelpers.Instance.UseProviderOptions(b);

return true;
}

public override HashSet<Type> FluentApiTypes { get; } = new HashSet<Type>
{
typeof(CosmosModelBuilderExtensions),
Expand Down
7 changes: 0 additions & 7 deletions test/EFCore.Design.Tests/DesignApiConsistencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ protected override Assembly TargetAssembly

public class DesignApiConsistencyFixture : ApiConsistencyFixtureBase
{
public override bool TryGetProviderOptionsDelegate(out Action<DbContextOptionsBuilder> configureOptions)
{
configureOptions = b => InMemoryTestHelpers.Instance.UseProviderOptions(b);

return true;
}

public override HashSet<Type> FluentApiTypes { get; } = new HashSet<Type> { typeof(DesignTimeServiceCollectionExtensions) };
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ protected override Assembly TargetAssembly

public class InMemoryApiConsistencyFixture : ApiConsistencyFixtureBase
{
public override bool TryGetProviderOptionsDelegate(out Action<DbContextOptionsBuilder> configureOptions)
{
configureOptions = b => InMemoryTestHelpers.Instance.UseProviderOptions(b);

return true;
}

public override HashSet<Type> FluentApiTypes { get; } = new HashSet<Type>
{
typeof(InMemoryServiceCollectionExtensions),
Expand Down
7 changes: 0 additions & 7 deletions test/EFCore.Proxies.Tests/ProxiesApiConsistencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ protected override Assembly TargetAssembly

public class ProxiesApiConsistencyFixture : ApiConsistencyFixtureBase
{
public override bool TryGetProviderOptionsDelegate(out Action<DbContextOptionsBuilder> configureOptions)
{
configureOptions = b => InMemoryTestHelpers.Instance.UseProviderOptions(b);

return true;
}

public override HashSet<Type> FluentApiTypes { get; } = new HashSet<Type> { typeof(ProxiesServiceCollectionExtensions) };
}
}
Expand Down
6 changes: 0 additions & 6 deletions test/EFCore.Relational.Tests/RelationalApiConsistencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ public void Readonly_relational_metadata_methods_have_expected_name()

public class RelationalApiConsistencyFixture : ApiConsistencyFixtureBase
{
public override bool TryGetProviderOptionsDelegate(out Action<DbContextOptionsBuilder> configureOptions)
{
configureOptions = null;
return false;
}

private static Dictionary<Type, (Type Mutable, Type Convention, Type ConventionBuilder)> _metadataTypes
=> new Dictionary<Type, (Type, Type, Type)>
{
Expand Down
10 changes: 7 additions & 3 deletions test/EFCore.Specification.Tests/ApiConsistencyTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,13 @@ where ns.StartsWith("Microsoft.Entity", StringComparison.Ordinal)
&& !it.Name.EndsWith("Dependencies", StringComparison.Ordinal)
&& (it.GetConstructors().Length != 1
|| it.GetConstructors()[0].GetParameters().Length == 0
|| it.GetConstructors()[0].GetParameters()[0].Name != "dependencies")
|| it.GetConstructors()[0].GetParameters()[0].Name != "dependencies"
// Check that the parameter has a non-public copy constructor, identifying C# 9 records
|| !it.GetConstructors()[0].GetParameters()[0].ParameterType
.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic)
.Any(c => c.GetParameters() is var parameters
&& parameters.Length == 1
&& parameters[0].Name == "original"))
select it)
.ToList();

Expand Down Expand Up @@ -900,8 +906,6 @@ protected ApiConsistencyFixtureBase()
Initialize();
}

public abstract bool TryGetProviderOptionsDelegate(out Action<DbContextOptionsBuilder> configureOptions);

public virtual HashSet<Type> FluentApiTypes { get; } = new HashSet<Type>();

public virtual Dictionary<Type, Type> GenericFluentApiTypes { get; } = new Dictionary<Type, Type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ protected override Assembly TargetAssembly

public class SqlServerApiConsistencyFixture : ApiConsistencyFixtureBase
{
public override bool TryGetProviderOptionsDelegate(out Action<DbContextOptionsBuilder> configureOptions)
{
configureOptions = b => SqlServerTestHelpers.Instance.UseProviderOptions(b);

return true;
}

public override HashSet<Type> FluentApiTypes { get; } = new HashSet<Type>
{
typeof(SqlServerDbContextOptionsBuilder),
Expand Down
7 changes: 0 additions & 7 deletions test/EFCore.SqlServer.Tests/SqlServerNTSApiConsistencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ protected override Assembly TargetAssembly

public class SqlServerNTSApiConsistencyFixture : ApiConsistencyFixtureBase
{
public override bool TryGetProviderOptionsDelegate(out Action<DbContextOptionsBuilder> configureOptions)
{
configureOptions = b => SqlServerTestHelpers.Instance.UseProviderOptions(b);

return true;
}

public override HashSet<Type> FluentApiTypes { get; } = new HashSet<Type>
{
typeof(SqlServerNetTopologySuiteDbContextOptionsBuilderExtensions),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ protected override Assembly TargetAssembly

public class SqliteApiConsistencyFixture : ApiConsistencyFixtureBase
{
public override bool TryGetProviderOptionsDelegate(out Action<DbContextOptionsBuilder> configureOptions)
{
configureOptions = b => SqliteTestHelpers.Instance.UseProviderOptions(b);

return true;
}

public override HashSet<Type> FluentApiTypes { get; } = new HashSet<Type>
{
typeof(SqliteServiceCollectionExtensions),
Expand Down
7 changes: 0 additions & 7 deletions test/EFCore.Sqlite.Tests/SqliteNTSApiConsistencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ protected override Assembly TargetAssembly

public class SqliteNTSApiConsistencyFixture : ApiConsistencyFixtureBase
{
public override bool TryGetProviderOptionsDelegate(out Action<DbContextOptionsBuilder> configureOptions)
{
configureOptions = b => SqliteTestHelpers.Instance.UseProviderOptions(b);

return true;
}

public override HashSet<Type> FluentApiTypes { get; } = new HashSet<Type>
{
typeof(SqliteNetTopologySuiteDbContextOptionsBuilderExtensions),
Expand Down
6 changes: 0 additions & 6 deletions test/EFCore.Tests/ApiConsistencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ protected override void Initialize()
base.Initialize();
}

public override bool TryGetProviderOptionsDelegate(out Action<DbContextOptionsBuilder> configureOptions)
{
configureOptions = null;
return false;
}

public override HashSet<Type> FluentApiTypes { get; } = new HashSet<Type>
{
typeof(ModelBuilder),
Expand Down

0 comments on commit e94c1cb

Please sign in to comment.