Skip to content

Commit

Permalink
Resolve merge conflicts and add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ajcvickers committed Mar 25, 2021
1 parent d6551af commit fcb0580
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 23 deletions.
6 changes: 2 additions & 4 deletions src/EFCore/Metadata/ContextParameterBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;
Expand Down Expand Up @@ -57,7 +55,7 @@ var propertyExpression
/// </summary>
/// <param name="consumedProperties"> The new consumed properties. </param>
/// <returns> A copy with replaced consumed properties. </returns>
public override ParameterBinding With(IReadOnlyList<IPropertyBase> consumedProperties)
=> new ContextParameterBinding(ParameterType, consumedProperties.SingleOrDefault());
public override ParameterBinding With(IPropertyBase[] consumedProperties)
=> new ContextParameterBinding(ParameterType, consumedProperties);
}
}
2 changes: 1 addition & 1 deletion src/EFCore/Metadata/Conventions/SlimModelConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private ParameterBinding Create(ParameterBinding parameterBinding, SlimEntityTyp
(entityType.FindProperty(property.Name)
?? entityType.FindServiceProperty(property.Name)
?? entityType.FindNavigation(property.Name)
?? (IPropertyBase?)entityType.FindSkipNavigation(property.Name))!).ToList());
?? (IPropertyBase?)entityType.FindSkipNavigation(property.Name))!).ToArray());

private InstantiationBinding? Create(InstantiationBinding? instantiationBinding, SlimEntityType entityType)
=> instantiationBinding?.With(instantiationBinding.ParameterBindings.Select(binding => Create(binding, entityType)).ToList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public override Expression BindToParameter(
/// </summary>
/// <param name="consumedProperties"> The new consumed properties. </param>
/// <returns> A copy with replaced consumed properties. </returns>
public override ParameterBinding With(IReadOnlyList<IPropertyBase> consumedProperties)
=> new DependencyInjectionMethodParameterBinding(ParameterType, ServiceType, Method, consumedProperties.SingleOrDefault());
public override ParameterBinding With(IPropertyBase[] consumedProperties)
=> new DependencyInjectionMethodParameterBinding(ParameterType, ServiceType, Method, consumedProperties);
}
}
6 changes: 2 additions & 4 deletions src/EFCore/Metadata/DependencyInjectionParameterBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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;
using System.Reflection;
using Microsoft.EntityFrameworkCore.Infrastructure;
Expand Down Expand Up @@ -65,7 +63,7 @@ public override Expression BindToParameter(
/// </summary>
/// <param name="consumedProperties"> The new consumed properties. </param>
/// <returns> A copy with replaced consumed properties. </returns>
public override ParameterBinding With(IReadOnlyList<IPropertyBase> consumedProperties)
=> new DependencyInjectionParameterBinding(ParameterType, ServiceType, consumedProperties.SingleOrDefault());
public override ParameterBinding With(IPropertyBase[] consumedProperties)
=> new DependencyInjectionParameterBinding(ParameterType, ServiceType, consumedProperties);
}
}
6 changes: 2 additions & 4 deletions src/EFCore/Metadata/EntityTypeParameterBinding.cs
Original file line number Diff line number Diff line change
@@ -1,8 +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.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Utilities;

Expand Down Expand Up @@ -40,7 +38,7 @@ public override Expression BindToParameter(
/// </summary>
/// <param name="consumedProperties"> The new consumed properties. </param>
/// <returns> A copy with replaced consumed properties. </returns>
public override ParameterBinding With(IReadOnlyList<IPropertyBase> consumedProperties)
=> new EntityTypeParameterBinding(consumedProperties.SingleOrDefault());
public override ParameterBinding With(IPropertyBase[] consumedProperties)
=> new EntityTypeParameterBinding(consumedProperties);
}
}
4 changes: 2 additions & 2 deletions src/EFCore/Metadata/ObjectArrayParameterBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public override Expression BindToParameter(ParameterBindingInfo bindingInfo)
/// </summary>
/// <param name="consumedProperties"> The new consumed properties. </param>
/// <returns> A copy with replaced consumed properties. </returns>
public override ParameterBinding With(IReadOnlyList<IPropertyBase> consumedProperties)
public override ParameterBinding With(IPropertyBase[] consumedProperties)
{
var newBindings = new List<ParameterBinding>(_bindings.Count);
var propertyCount = 0;
foreach (var binding in _bindings)
{
var newBinding = binding.With(consumedProperties.Skip(propertyCount).Take(binding.ConsumedProperties.Count).ToList());
var newBinding = binding.With(consumedProperties.Skip(propertyCount).Take(binding.ConsumedProperties.Count).ToArray());
newBindings.Add(newBinding);
propertyCount += binding.ConsumedProperties.Count;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/Metadata/ParameterBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ protected ParameterBinding(
/// </summary>
/// <param name="consumedProperties"> The new consumed properties. </param>
/// <returns> A copy with replaced consumed properties. </returns>
public abstract ParameterBinding With(IReadOnlyList<IPropertyBase> consumedProperties);
public abstract ParameterBinding With(IPropertyBase[] consumedProperties);
}
}
3 changes: 1 addition & 2 deletions src/EFCore/Metadata/PropertyParameterBinding.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.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Infrastructure;
Expand Down Expand Up @@ -43,7 +42,7 @@ public override Expression BindToParameter(ParameterBindingInfo bindingInfo)
/// </summary>
/// <param name="consumedProperties"> The new consumed properties. </param>
/// <returns> A copy with replaced consumed properties. </returns>
public override ParameterBinding With(IReadOnlyList<IPropertyBase> consumedProperties)
public override ParameterBinding With(IPropertyBase[] consumedProperties)
=> new PropertyParameterBinding((IProperty)consumedProperties.Single());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void Finds_service_properties_in_hierarchy()
using (var context = new ServicePropertiesContext())
{
var entityTypes = context.Model.GetEntityTypes().ToList();
Assert.Equal(10, entityTypes.Count);
Assert.Equal(13, entityTypes.Count);

foreach (var entityType in entityTypes)
{
Expand Down Expand Up @@ -93,9 +93,13 @@ public void Finds_service_properties_in_hierarchy()
foreach (var entry in context.ChangeTracker.Entries())
{
var clrType = entry.Metadata.ClrType;
while (clrType!.BaseType != typeof(object))

if (!clrType.Name.StartsWith("PrivateWithDuplicates", StringComparison.Ordinal))
{
clrType = clrType.BaseType;
while (clrType!.BaseType != typeof(object))
{
clrType = clrType.BaseType;
}
}

if (clrType == typeof(PublicUnmappedBaseSuper))
Expand Down Expand Up @@ -247,6 +251,15 @@ public DbSet<PublicMappedBaseSuper> PublicMappedBaseSupers
public DbSet<PublicMappedBaseSub> PublicMappedBaseSubs
=> Set<PublicMappedBaseSub>();

public DbSet<PrivateWithDuplicatesBase> PrivateWithDuplicatesBases
=> Set<PrivateWithDuplicatesBase>();

public DbSet<PrivateWithDuplicatesSuper> PrivateWithDuplicatesSupers
=> Set<PrivateWithDuplicatesSuper>();

public DbSet<PrivateWithDuplicatesSub> PrivateWithDuplicatesSubs
=> Set<PrivateWithDuplicatesSub>();

protected internal override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<PrivateUnmappedBaseSuper>(
Expand Down Expand Up @@ -412,6 +425,40 @@ protected class PublicMappedBaseSuper : PublicMappedBase
protected class PublicMappedBaseSub : PublicMappedBaseSuper
{
}

protected class PrivateWithDuplicatesBase
{
public int Id { get; set; }
private DbContext? Context { get; set; }
private DbContext? Context2 { get; set; }
private IEntityType? EntityType { get; set; }
private IEntityType? EntityType2 { get; set; }
private ILazyLoader? ALazyLoader { get; set; }
private ILazyLoader? ALazyLoader2 { get; set; }
private Action<object, string>? LazyLoader { get; set; }
}

protected class PrivateWithDuplicatesSuper : PrivateWithDuplicatesBase
{
private DbContext? Context { get; set; }
private DbContext? Context2 { get; set; }
private IEntityType? EntityType { get; set; }
private IEntityType? EntityType2 { get; set; }
private ILazyLoader? ALazyLoader { get; set; }
private ILazyLoader? ALazyLoader2 { get; set; }
private Action<object, string>? LazyLoader { get; set; }
}

protected class PrivateWithDuplicatesSub : PrivateWithDuplicatesSuper
{
private DbContext? Context { get; set; }
private DbContext? Context2 { get; set; }
private IEntityType? EntityType { get; set; }
private IEntityType? EntityType2 { get; set; }
private ILazyLoader? ALazyLoader { get; set; }
private ILazyLoader? ALazyLoader2 { get; set; }
private Action<object, string>? LazyLoader { get; set; }
}
}
}

Expand Down

0 comments on commit fcb0580

Please sign in to comment.