Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove quirks from main #23879

Merged
merged 1 commit into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 9 additions & 21 deletions src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,15 @@ public virtual void Generate(string builderName, IModel model, IndentedStringBui

using (stringBuilder.Indent())
{
var useOldBehavior = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23456", out var enabled) && enabled;

// Temporary patch: specifically exclude some annotations which are known to produce identical Fluent API calls across different
// providers, generating them as raw annotations instead.
var ambiguousAnnotations = useOldBehavior
? Array.Empty<IAnnotation>()
: RemoveAmbiguousFluentApiAnnotations(
annotations,
name => name.EndsWith(":ValueGenerationStrategy", StringComparison.Ordinal)
|| name.EndsWith(":IdentityIncrement", StringComparison.Ordinal)
|| name.EndsWith(":IdentitySeed", StringComparison.Ordinal)
|| name.EndsWith(":HiLoSequenceName", StringComparison.Ordinal)
|| name.EndsWith(":HiLoSequenceSchema", StringComparison.Ordinal));
var ambiguousAnnotations = RemoveAmbiguousFluentApiAnnotations(
ajcvickers marked this conversation as resolved.
Show resolved Hide resolved
annotations,
name => name.EndsWith(":ValueGenerationStrategy", StringComparison.Ordinal)
|| name.EndsWith(":IdentityIncrement", StringComparison.Ordinal)
|| name.EndsWith(":IdentitySeed", StringComparison.Ordinal)
|| name.EndsWith(":HiLoSequenceName", StringComparison.Ordinal)
|| name.EndsWith(":HiLoSequenceSchema", StringComparison.Ordinal));

foreach (var methodCallCodeFragment in
Dependencies.AnnotationCodeGenerator.GenerateFluentApiCalls(model, annotations))
Expand Down Expand Up @@ -589,13 +585,9 @@ protected virtual void GeneratePropertyAnnotations([NotNull] IProperty property,
GenerateFluentApiForDefaultValue(property, stringBuilder);
annotations.Remove(RelationalAnnotationNames.DefaultValue);

var useOldBehavior = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23456", out var enabled) && enabled;

// Temporary patch: specifically exclude some annotations which are known to produce identical Fluent API calls across different
// providers, generating them as raw annotations instead.
var ambiguousAnnotations = useOldBehavior
? Array.Empty<IAnnotation>()
: RemoveAmbiguousFluentApiAnnotations(
var ambiguousAnnotations = RemoveAmbiguousFluentApiAnnotations(
annotations,
name => name.EndsWith(":ValueGenerationStrategy", StringComparison.Ordinal)
|| name.EndsWith(":IdentityIncrement", StringComparison.Ordinal)
Expand Down Expand Up @@ -794,13 +786,9 @@ protected virtual void GenerateIndexAnnotations(
.FilterIgnoredAnnotations(index.GetAnnotations())
.ToDictionary(a => a.Name, a => a);

var useOldBehavior = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23456", out var enabled) && enabled;

// Temporary patch: specifically exclude some annotations which are known to produce identical Fluent API calls across different
// providers, generating them as raw annotations instead.
var ambiguousAnnotations = useOldBehavior
? Array.Empty<IAnnotation>()
: RemoveAmbiguousFluentApiAnnotations(
var ambiguousAnnotations = RemoveAmbiguousFluentApiAnnotations(
annotations,
name => name.EndsWith(":Include", StringComparison.Ordinal));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,7 @@ private static bool ProcessJoinCondition(
}
}

if (!(AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23593", out var enabled)
&& enabled)
&& joinCondition is MethodCallExpression methodCallExpression
if (joinCondition is MethodCallExpression methodCallExpression
&& methodCallExpression.Method.IsStatic
&& methodCallExpression.Method.DeclaringType == typeof(object)
&& methodCallExpression.Method.Name == nameof(object.Equals)
Expand Down Expand Up @@ -1506,8 +1504,7 @@ outerKey is NewArrayExpression newArrayExpression
: foreignKey.Properties,
makeNullable);

if (foreignKey.Properties.Count > 1
&& !(AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore23687", out var enabled) && enabled))
if (foreignKey.Properties.Count > 1)
{
outerKey = Expression.New(AnonymousObject.AnonymousObjectCtor, outerKey);
innerKey = Expression.New(AnonymousObject.AnonymousObjectCtor, innerKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public static string GetDefaultDatabaseName([NotNull] this IIndex index, in Stor
return null;
}

var useOldBehavior = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23672", out var enabled) && enabled;
var rootIndex = index;

// Limit traversal to avoid getting stuck in a cycle (validation will throw for these later)
Expand All @@ -103,7 +102,7 @@ public static string GetDefaultDatabaseName([NotNull] this IIndex index, in Stor
.SelectMany(fk => fk.PrincipalEntityType.GetIndexes()))
{
var otherColumnNames = otherIndex.Properties.GetColumnNames(storeObject);
if ((otherColumnNames != null || useOldBehavior)
if ((otherColumnNames != null)
&& otherColumnNames.SequenceEqual(columnNames))
{
linkedIndex = otherIndex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +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 System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -104,7 +103,6 @@ public static string GetDefaultName([NotNull] this IKey key, in StoreObjectIdent
return null;
}

var useOldBehavior = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23672", out var enabled) && enabled;
var rootKey = key;

// Limit traversal to avoid getting stuck in a cycle (validation will throw for these later)
Expand All @@ -117,7 +115,7 @@ public static string GetDefaultName([NotNull] this IKey key, in StoreObjectIdent
.SelectMany(fk => fk.PrincipalEntityType.GetKeys()))
{
var otherColumnNames = otherKey.Properties.GetColumnNames(storeObject);
if ((otherColumnNames != null || useOldBehavior)
if ((otherColumnNames != null)
&& otherColumnNames.SequenceEqual(columnNames))
{
linkedKey = otherKey;
Expand Down
3 changes: 1 addition & 2 deletions src/EFCore.Relational/Migrations/MigrationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1335,13 +1335,12 @@ private OperationBuilder<InsertDataOperation> InsertDataInternal(
Check.NotNull(columns, nameof(columns));
Check.NotNull(values, nameof(values));

var useOldBehavior = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23503", out var enabled) && enabled;
var operation = new InsertDataOperation
{
Table = table,
Schema = schema,
Columns = columns,
ColumnTypes = useOldBehavior ? null : columnTypes,
ColumnTypes = columnTypes,
Values = values
};
Operations.Add(operation);
Expand Down
7 changes: 0 additions & 7 deletions src/EFCore.Relational/Query/SqlNullabilityProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,6 @@ protected virtual SqlExpression VisitExists(
var subquery = Visit(existsExpression.Subquery);
nullable = false;

if (AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore23617", out var enabled) && enabled)
{
return TryGetBoolConstantValue(subquery.Predicate) == false
? subquery.Predicate!
: existsExpression.Update(subquery);
}

// if subquery has predicate which evaluates to false, we can simply return false
// if the exisits is negated we need to return true instead
return TryGetBoolConstantValue(subquery.Predicate) == false
Expand Down
12 changes: 5 additions & 7 deletions src/EFCore.Relational/Update/Internal/CommandBatchPreparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class CommandBatchPreparer : ICommandBatchPreparer
private readonly IKeyValueIndexFactorySource _keyValueIndexFactorySource;
private readonly int _minBatchSize;
private readonly bool _sensitiveLoggingEnabled;
private static readonly bool _useOldStateBehavior =
AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23668", out var enabled) && enabled;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down Expand Up @@ -494,7 +492,7 @@ private Dictionary<IKeyValueIndex, List<ModificationCommand>> CreateKeyValuePred
.Where(c => c.PrincipalTable.Name == command.TableName && c.PrincipalTable.Schema == command.Schema);

if (!constraints.Any()
|| ((_useOldStateBehavior ? command.EntityState : entry.EntityState) == EntityState.Modified
|| (entry.EntityState == EntityState.Modified
&& !foreignKey.PrincipalKey.Properties.Any(p => entry.IsModified(p))))
{
continue;
Expand Down Expand Up @@ -529,7 +527,7 @@ private Dictionary<IKeyValueIndex, List<ModificationCommand>> CreateKeyValuePred
.Where(c => c.Table.Name == command.TableName && c.Table.Schema == command.Schema);

if (!constraints.Any()
|| ((_useOldStateBehavior ? command.EntityState : entry.EntityState) == EntityState.Modified
|| (entry.EntityState == EntityState.Modified
&& !foreignKey.Properties.Any(p => entry.IsModified(p))))
{
continue;
Expand Down Expand Up @@ -575,7 +573,7 @@ private void AddForeignKeyEdges(
{
if (!foreignKey.GetMappedConstraints()
.Any(c => c.Table.Name == command.TableName && c.Table.Schema == command.Schema)
|| ((_useOldStateBehavior ? command.EntityState : entry.EntityState) == EntityState.Modified
|| (entry.EntityState == EntityState.Modified
&& !foreignKey.Properties.Any(p => entry.IsModified(p))))
{
continue;
Expand Down Expand Up @@ -661,7 +659,7 @@ private void AddUniqueValueEdges(Multigraph<ModificationCommand, IAnnotatable> c
var entry = command.Entries[entryIndex];
foreach (var index in entry.EntityType.GetIndexes().Where(i => i.IsUnique && i.GetMappedTableIndexes().Any()))
{
if ((_useOldStateBehavior ? command.EntityState : entry.EntityState) == EntityState.Modified
if (entry.EntityState == EntityState.Modified
&& !index.Properties.Any(p => entry.IsModified(p)))
{
continue;
Expand Down Expand Up @@ -722,7 +720,7 @@ private void AddUniqueValueEdges(Multigraph<ModificationCommand, IAnnotatable> c
{
foreach (var index in entry.EntityType.GetIndexes().Where(i => i.IsUnique && i.GetMappedTableIndexes().Any()))
{
if ((_useOldStateBehavior ? command.EntityState : entry.EntityState) == EntityState.Modified
if (entry.EntityState == EntityState.Modified
&& !index.Properties.Any(p => entry.IsModified(p)))
{
continue;
Expand Down
17 changes: 2 additions & 15 deletions src/EFCore/ChangeTracking/Internal/NavigationFixer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +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 System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -30,12 +29,6 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking.Internal
/// </summary>
public class NavigationFixer : INavigationFixer
{
private readonly bool _useOldBehaviorFor23659
= AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23659", out var enabled) && enabled;

private readonly bool _useOldBehaviorFor23787
= AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23787", out var enabled) && enabled;

private readonly IChangeDetector _changeDetector;
private readonly IEntityGraphAttacher _attacher;
private bool _inFixup;
Expand Down Expand Up @@ -834,10 +827,7 @@ private void InitialFixup(
AddToCollection(otherEntry, skipNavigation.Inverse, entry, fromQuery);
}

if (!_useOldBehaviorFor23787)
{
entry.AddToCollectionSnapshot(skipNavigation, otherEntity);
}
entry.AddToCollectionSnapshot(skipNavigation, otherEntity);
}
}
}
Expand Down Expand Up @@ -894,10 +884,7 @@ private void DelayedFixup(
{
FixupToPrincipal(entry, referencedEntry, navigation.ForeignKey, setModified, fromQuery);

if (!_useOldBehaviorFor23659)
{
FixupSkipNavigations(entry, navigation.ForeignKey, fromQuery);
}
FixupSkipNavigations(entry, navigation.ForeignKey, fromQuery);
}
}
}
Expand Down