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

Fix 18561. Update IInfrastructure on Fluent API to use public interfaces #20492

Merged
merged 1 commit into from
Apr 1, 2020
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
4 changes: 2 additions & 2 deletions src/EFCore/Metadata/Builders/CollectionNavigationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Builders
/// and it is not designed to be directly constructed in your application code.
/// </para>
/// </summary>
public class CollectionNavigationBuilder : IInfrastructure<InternalForeignKeyBuilder>
public class CollectionNavigationBuilder : IInfrastructure<IConventionForeignKeyBuilder>
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down Expand Up @@ -105,7 +105,7 @@ public CollectionNavigationBuilder(
/// not directly exposed in the public API surface.
/// </para>
/// </summary>
InternalForeignKeyBuilder IInfrastructure<InternalForeignKeyBuilder>.Instance => Builder;
IConventionForeignKeyBuilder IInfrastructure<IConventionForeignKeyBuilder>.Instance => Builder;

/// <summary>
/// <para>
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore/Metadata/Builders/EntityTypeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Builders
/// and it is not designed to be directly constructed in your application code.
/// </para>
/// </summary>
public class EntityTypeBuilder : IInfrastructure<InternalEntityTypeBuilder>
public class EntityTypeBuilder : IInfrastructure<IConventionEntityTypeBuilder>
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -46,7 +46,7 @@ public EntityTypeBuilder([NotNull] IMutableEntityType entityType)
/// <summary>
/// Gets the internal builder being used to configure the entity type.
/// </summary>
InternalEntityTypeBuilder IInfrastructure<InternalEntityTypeBuilder>.Instance => Builder;
IConventionEntityTypeBuilder IInfrastructure<IConventionEntityTypeBuilder>.Instance => Builder;

/// <summary>
/// The entity type being configured.
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,6 @@ public virtual DiscriminatorBuilder<TDiscriminator> HasDiscriminator<TDiscrimina
public new virtual EntityTypeBuilder<TEntity> HasNoDiscriminator()
=> (EntityTypeBuilder<TEntity>)base.HasNoDiscriminator();

private InternalEntityTypeBuilder Builder => this.GetInfrastructure();
private InternalEntityTypeBuilder Builder => (InternalEntityTypeBuilder)this.GetInfrastructure();
}
}
6 changes: 3 additions & 3 deletions src/EFCore/Metadata/Builders/IndexBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Builders
/// and it is not designed to be directly constructed in your application code.
/// </para>
/// </summary>
public class IndexBuilder : IInfrastructure<InternalIndexBuilder>
public class IndexBuilder : IInfrastructure<IConventionIndexBuilder>
{
private readonly InternalIndexBuilder _builder;

Expand All @@ -39,7 +39,7 @@ public IndexBuilder([NotNull] IMutableIndex index)
/// <summary>
/// The internal builder being used to configure the index.
/// </summary>
InternalIndexBuilder IInfrastructure<InternalIndexBuilder>.Instance => _builder;
IConventionIndexBuilder IInfrastructure<IConventionIndexBuilder>.Instance => _builder;

/// <summary>
/// The index being configured.
Expand Down Expand Up @@ -76,7 +76,7 @@ public virtual IndexBuilder IsUnique(bool unique = true)
return this;
}

private InternalIndexBuilder Builder => this.GetInfrastructure();
private InternalIndexBuilder Builder => (InternalIndexBuilder)this.GetInfrastructure();

#region Hidden System.Object members

Expand Down
6 changes: 3 additions & 3 deletions src/EFCore/Metadata/Builders/KeyBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Builders
/// and it is not designed to be directly constructed in your application code.
/// </para>
/// </summary>
public class KeyBuilder : IInfrastructure<InternalKeyBuilder>
public class KeyBuilder : IInfrastructure<IConventionKeyBuilder>
{
private readonly InternalKeyBuilder _builder;

Expand All @@ -39,7 +39,7 @@ public KeyBuilder([NotNull] IMutableKey key)
/// <summary>
/// The internal builder being used to configure the key.
/// </summary>
InternalKeyBuilder IInfrastructure<InternalKeyBuilder>.Instance => _builder;
IConventionKeyBuilder IInfrastructure<IConventionKeyBuilder>.Instance => _builder;

/// <summary>
/// The key being configured.
Expand All @@ -64,7 +64,7 @@ public virtual KeyBuilder HasAnnotation([NotNull] string annotation, [NotNull] o
return this;
}

private InternalKeyBuilder Builder => this.GetInfrastructure();
private InternalKeyBuilder Builder => (InternalKeyBuilder)this.GetInfrastructure();

#region Hidden System.Object members

Expand Down
4 changes: 2 additions & 2 deletions src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Builders
/// <summary>
/// Provides a simple API for configuring a navigation to an owned entity type.
/// </summary>
public class OwnedNavigationBuilder : IInfrastructure<InternalEntityTypeBuilder>
public class OwnedNavigationBuilder : IInfrastructure<IConventionEntityTypeBuilder>
{
private InternalForeignKeyBuilder _builder;

Expand Down Expand Up @@ -90,7 +90,7 @@ protected virtual T UpdateBuilder<T>([NotNull] Func<T> configure)
/// <summary>
/// Gets the internal builder being used to configure the owned entity type.
/// </summary>
InternalEntityTypeBuilder IInfrastructure<InternalEntityTypeBuilder>.Instance => DependentEntityType.Builder;
IConventionEntityTypeBuilder IInfrastructure<IConventionEntityTypeBuilder>.Instance => DependentEntityType.Builder;

/// <summary>
/// The foreign key that represents this ownership.
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore/Metadata/Builders/PropertyBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Builders
/// and it is not designed to be directly constructed in your application code.
/// </para>
/// </summary>
public class PropertyBuilder : IInfrastructure<InternalPropertyBuilder>
public class PropertyBuilder : IInfrastructure<IConventionPropertyBuilder>
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -40,7 +40,7 @@ public PropertyBuilder([NotNull] IMutableProperty property)
/// <summary>
/// The internal builder being used to configure the property.
/// </summary>
InternalPropertyBuilder IInfrastructure<InternalPropertyBuilder>.Instance => Builder;
IConventionPropertyBuilder IInfrastructure<IConventionPropertyBuilder>.Instance => Builder;

/// <summary>
/// The property being configured.
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore/Metadata/Builders/ReferenceNavigationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Builders
/// and it is not designed to be directly constructed in your application code.
/// </para>
/// </summary>
public class ReferenceNavigationBuilder : IInfrastructure<InternalForeignKeyBuilder>
public class ReferenceNavigationBuilder : IInfrastructure<IConventionForeignKeyBuilder>
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down Expand Up @@ -119,7 +119,7 @@ public ReferenceNavigationBuilder(
/// <summary>
/// Gets the internal builder being used to configure the relationship.
/// </summary>
InternalForeignKeyBuilder IInfrastructure<InternalForeignKeyBuilder>.Instance => Builder;
IConventionForeignKeyBuilder IInfrastructure<IConventionForeignKeyBuilder>.Instance => Builder;

/// <summary>
/// <para>
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore/Metadata/Builders/RelationshipBuilderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Builders
/// <summary>
/// Base class used for configuring a relationship.
/// </summary>
public abstract class RelationshipBuilderBase : IInfrastructure<InternalForeignKeyBuilder>
public abstract class RelationshipBuilderBase : IInfrastructure<IConventionForeignKeyBuilder>
{
private readonly IReadOnlyList<Property> _foreignKeyProperties;
private readonly IReadOnlyList<Property> _principalKeyProperties;
Expand Down Expand Up @@ -107,7 +107,7 @@ protected RelationshipBuilderBase(
/// <summary>
/// Gets the internal builder being used to configure this relationship.
/// </summary>
InternalForeignKeyBuilder IInfrastructure<InternalForeignKeyBuilder>.Instance => Builder;
IConventionForeignKeyBuilder IInfrastructure<IConventionForeignKeyBuilder>.Instance => Builder;

#region Hidden System.Object members

Expand Down
6 changes: 3 additions & 3 deletions src/EFCore/ModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Microsoft.EntityFrameworkCore
/// model externally and set it on a <see cref="DbContextOptions" /> instance that is passed to the context constructor.
/// </para>
/// </summary>
public class ModelBuilder : IInfrastructure<InternalModelBuilder>
public class ModelBuilder : IInfrastructure<IConventionModelBuilder>
{
private readonly InternalModelBuilder _builder;

Expand Down Expand Up @@ -89,7 +89,7 @@ public virtual ModelBuilder HasAnnotation([NotNull] string annotation, [NotNull]
/// application code.
/// </para>
/// </summary>
InternalModelBuilder IInfrastructure<InternalModelBuilder>.Instance => _builder;
IConventionModelBuilder IInfrastructure<IConventionModelBuilder>.Instance => _builder;

/// <summary>
/// Returns an object that can be used to configure a given entity type in the model.
Expand Down Expand Up @@ -373,7 +373,7 @@ public virtual ModelBuilder UsePropertyAccessMode(PropertyAccessMode propertyAcc
/// <returns> The finalized <see cref="IModel" />. </returns>
public virtual IModel FinalizeModel() => Builder.Metadata.FinalizeModel();

private InternalModelBuilder Builder => this.GetInfrastructure();
private InternalModelBuilder Builder => (InternalModelBuilder)this.GetInfrastructure();

#region Hidden System.Object members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class RelationalPropertyMappingValidationConventionTest : PropertyMapping
[ConditionalFact]
public void Throws_when_added_property_is_not_mapped_to_store()
{
var modelBuilder = CreateConventionlessModelBuilder().GetInfrastructure();
var modelBuilder = CreateConventionlessInternalModelBuilder();
var entityTypeBuilder = modelBuilder.Entity(typeof(NonPrimitiveAsPropertyEntity), ConfigurationSource.Convention);
entityTypeBuilder.Property(typeof(Tuple<long>), "LongProperty", ConfigurationSource.Explicit);
entityTypeBuilder.Ignore(nameof(NonPrimitiveAsPropertyEntity.Property), ConfigurationSource.Explicit);
Expand All @@ -31,7 +31,7 @@ public void Throws_when_added_property_is_not_mapped_to_store()
[ConditionalFact]
public void Throws_when_added_property_is_not_mapped_to_store_even_if_configured_to_use_column_type()
{
var modelBuilder = CreateConventionlessModelBuilder().GetInfrastructure();
var modelBuilder = CreateConventionlessInternalModelBuilder();
var entityTypeBuilder = modelBuilder.Entity(typeof(NonPrimitiveNonNavigationAsPropertyEntity), ConfigurationSource.Convention);
entityTypeBuilder.Property(typeof(Tuple<long>), "LongProperty", ConfigurationSource.Explicit)
.HasColumnType("some_int_mapping");
Expand Down
20 changes: 10 additions & 10 deletions test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public virtual void Passes_on_shadow_primary_key_created_by_convention_in_depend
[ConditionalFact]
public virtual void Detects_shadow_key_referenced_by_foreign_key_by_convention()
{
var modelBuilder = CreateConventionlessModelBuilder().GetInfrastructure();
var modelBuilder = CreateConventionlessInternalModelBuilder();
var dependentEntityBuilder = modelBuilder.Entity(typeof(SampleEntityMinimal), ConfigurationSource.Convention);
dependentEntityBuilder.Property(typeof(int), "Id", ConfigurationSource.Convention);
dependentEntityBuilder.Ignore(nameof(SampleEntityMinimal.ReferencedEntity), ConfigurationSource.Explicit);
Expand Down Expand Up @@ -618,7 +618,7 @@ public virtual void Detects_missing_inverse_skip_navigations()
[ConditionalFact]
public virtual void Passes_on_valid_owned_entity_types()
{
var modelBuilder = CreateConventionlessModelBuilder().GetInfrastructure();
var modelBuilder = CreateConventionlessInternalModelBuilder();
var entityTypeBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention);
entityTypeBuilder.PrimaryKey(new[] { nameof(SampleEntity.Id) }, ConfigurationSource.Convention);
entityTypeBuilder.Ignore(nameof(SampleEntity.Name), ConfigurationSource.Explicit);
Expand All @@ -639,7 +639,7 @@ public virtual void Passes_on_valid_owned_entity_types()
[ConditionalFact]
public virtual void Detects_weak_entity_type_without_defining_navigation()
{
var modelBuilder = CreateConventionlessModelBuilder().GetInfrastructure();
var modelBuilder = CreateConventionlessInternalModelBuilder();
var entityTypeBuilder = modelBuilder.Entity(typeof(SampleEntityMinimal), ConfigurationSource.Convention);
entityTypeBuilder.PrimaryKey(new[] { nameof(SampleEntityMinimal.Id) }, ConfigurationSource.Convention);

Expand Down Expand Up @@ -671,7 +671,7 @@ public virtual void Detects_weak_entity_type_without_defining_navigation()
[ConditionalFact]
public virtual void Detects_entity_type_with_multiple_ownerships()
{
var modelBuilder = CreateConventionlessModelBuilder().GetInfrastructure();
var modelBuilder = CreateConventionlessInternalModelBuilder();

var entityTypeBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention);
entityTypeBuilder.PrimaryKey(new[] { nameof(SampleEntity.Id) }, ConfigurationSource.Convention);
Expand Down Expand Up @@ -700,7 +700,7 @@ public virtual void Detects_entity_type_with_multiple_ownerships()
[ConditionalFact]
public virtual void Detects_weak_entity_type_with_non_defining_ownership()
{
var modelBuilder = CreateConventionlessModelBuilder().GetInfrastructure();
var modelBuilder = CreateConventionlessInternalModelBuilder();
var entityTypeBuilder = modelBuilder.Entity(typeof(SampleEntityMinimal), ConfigurationSource.Convention);
entityTypeBuilder.PrimaryKey(new[] { nameof(SampleEntityMinimal.Id) }, ConfigurationSource.Convention);

Expand Down Expand Up @@ -734,7 +734,7 @@ public virtual void Detects_weak_entity_type_with_non_defining_ownership()
[ConditionalFact]
public virtual void Detects_weak_entity_type_without_ownership()
{
var modelBuilder = CreateConventionlessModelBuilder().GetInfrastructure();
var modelBuilder = CreateConventionlessInternalModelBuilder();
var entityTypeBuilder = modelBuilder.Entity(typeof(SampleEntityMinimal), ConfigurationSource.Convention);
entityTypeBuilder.PrimaryKey(new[] { nameof(SampleEntityMinimal.Id) }, ConfigurationSource.Convention);

Expand Down Expand Up @@ -764,7 +764,7 @@ public virtual void Detects_weak_entity_type_without_ownership()
[ConditionalFact]
public virtual void Detects_principal_owned_entity_type()
{
var modelBuilder = CreateConventionlessModelBuilder().GetInfrastructure();
var modelBuilder = CreateConventionlessInternalModelBuilder();

var entityTypeBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention);
entityTypeBuilder.PrimaryKey(new[] { nameof(SampleEntity.Id) }, ConfigurationSource.Convention);
Expand Down Expand Up @@ -798,7 +798,7 @@ public virtual void Detects_principal_owned_entity_type()
[ConditionalFact]
public virtual void Detects_non_owner_navigation_to_owned_entity_type()
{
var modelBuilder = CreateConventionlessModelBuilder().GetInfrastructure();
var modelBuilder = CreateConventionlessInternalModelBuilder();

var entityTypeBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention);
entityTypeBuilder.PrimaryKey(new[] { nameof(SampleEntity.Id) }, ConfigurationSource.Convention);
Expand Down Expand Up @@ -830,7 +830,7 @@ public virtual void Detects_non_owner_navigation_to_owned_entity_type()
[ConditionalFact]
public virtual void Detects_derived_owned_entity_type()
{
var modelBuilder = CreateConventionlessModelBuilder().GetInfrastructure();
var modelBuilder = CreateConventionlessInternalModelBuilder();

var entityTypeBuilder = modelBuilder.Entity(typeof(B), ConfigurationSource.Convention);
entityTypeBuilder.PrimaryKey(new[] { nameof(B.Id) }, ConfigurationSource.Convention);
Expand Down Expand Up @@ -860,7 +860,7 @@ public virtual void Detects_derived_owned_entity_type()
[ConditionalFact]
public virtual void Detects_owned_entity_type_without_ownership()
{
var modelBuilder = CreateConventionlessModelBuilder().GetInfrastructure();
var modelBuilder = CreateConventionlessInternalModelBuilder();
var aBuilder = modelBuilder.Entity(typeof(A), ConfigurationSource.Convention);
aBuilder.Ignore(nameof(A.Id), ConfigurationSource.Explicit);
aBuilder.Ignore(nameof(A.P0), ConfigurationSource.Explicit);
Expand Down
4 changes: 4 additions & 0 deletions test/EFCore.Tests/Infrastructure/ModelValidatorTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -320,5 +321,8 @@ protected ProviderConventionSetBuilderDependencies CreateDependencies(bool sensi
.With(CreateValidationLogger(sensitiveDataLoggingEnabled));

protected virtual TestHelpers TestHelpers => InMemoryTestHelpers.Instance;

protected virtual InternalModelBuilder CreateConventionlessInternalModelBuilder()
=> (InternalModelBuilder)CreateConventionlessModelBuilder().GetInfrastructure();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ private class DerivedEntity : Entity

private static InternalEntityTypeBuilder CreateInternalEntityTypeBuilder<T>()
{
var modelBuilder = InMemoryTestHelpers.Instance.CreateConventionBuilder().GetInfrastructure();
var modelBuilder = (InternalModelBuilder)
InMemoryTestHelpers.Instance.CreateConventionBuilder().GetInfrastructure();

return modelBuilder.Entity(typeof(T), ConfigurationSource.Explicit);
}
Expand Down
Loading