From 7e71cba1cc9553868992913af6d553d7f1195eb5 Mon Sep 17 00:00:00 2001 From: Arthur Vickers Date: Sun, 29 Mar 2020 12:51:01 -0700 Subject: [PATCH] Make IDbSetFinder public Fixes #20385 Also annotated internal service properties on public dependency objects. --- .../MigrationsScaffolderDependencies.cs | 4 +++ .../RelationalConnectionDependencies.cs | 2 ++ .../Internal/StateManagerDependencies.cs | 4 +++ .../Infrastructure/DbSetFinderExtensions.cs | 1 - src/EFCore/Infrastructure/IDbSetFinder.cs | 30 ++++++++++++++++ .../ModelCustomizerDependencies.cs | 1 - .../ModelValidatorDependencies.cs | 2 ++ src/EFCore/Internal/DbSetInitializer.cs | 1 + src/EFCore/Internal/IDbSetFinder.cs | 35 ------------------- ...roviderConventionSetBuilderDependencies.cs | 3 +- 10 files changed, 45 insertions(+), 38 deletions(-) create mode 100644 src/EFCore/Infrastructure/IDbSetFinder.cs delete mode 100644 src/EFCore/Internal/IDbSetFinder.cs diff --git a/src/EFCore.Design/Migrations/Design/MigrationsScaffolderDependencies.cs b/src/EFCore.Design/Migrations/Design/MigrationsScaffolderDependencies.cs index 402f9629ff0..d6f0d7c848a 100644 --- a/src/EFCore.Design/Migrations/Design/MigrationsScaffolderDependencies.cs +++ b/src/EFCore.Design/Migrations/Design/MigrationsScaffolderDependencies.cs @@ -132,6 +132,7 @@ public MigrationsScaffolderDependencies( /// /// The operation reporter. /// + [EntityFrameworkInternal] public IOperationReporter OperationReporter { get; } /// @@ -142,6 +143,7 @@ public MigrationsScaffolderDependencies( /// /// The snapshot model processor. /// + [EntityFrameworkInternal] public ISnapshotModelProcessor SnapshotModelProcessor { get; } /// @@ -287,6 +289,7 @@ public MigrationsScaffolderDependencies With([NotNull] IHistoryRepository histor /// /// A replacement for the current dependency of this type. /// A new parameter object with the given service replaced. + [EntityFrameworkInternal] public MigrationsScaffolderDependencies With([NotNull] IOperationReporter operationReporter) => new MigrationsScaffolderDependencies( CurrentContext, @@ -325,6 +328,7 @@ public MigrationsScaffolderDependencies With([NotNull] IDatabaseProvider databas /// /// A replacement for the current dependency of this type. /// A new parameter object with the given service replaced. + [EntityFrameworkInternal] public MigrationsScaffolderDependencies With([NotNull] ISnapshotModelProcessor snapshotModelProcessor) => new MigrationsScaffolderDependencies( CurrentContext, diff --git a/src/EFCore.Relational/Storage/RelationalConnectionDependencies.cs b/src/EFCore.Relational/Storage/RelationalConnectionDependencies.cs index a323f78070f..b6c8b9faead 100644 --- a/src/EFCore.Relational/Storage/RelationalConnectionDependencies.cs +++ b/src/EFCore.Relational/Storage/RelationalConnectionDependencies.cs @@ -96,6 +96,7 @@ public RelationalConnectionDependencies( /// /// A service for resolving a connection string from a name. /// + [EntityFrameworkInternal] public INamedConnectionStringResolver ConnectionStringResolver { get; } /// @@ -155,6 +156,7 @@ public RelationalConnectionDependencies With([NotNull] IDiagnosticsLogger /// A replacement for the current dependency of this type. /// A new parameter object with the given service replaced. + [EntityFrameworkInternal] public RelationalConnectionDependencies With([NotNull] INamedConnectionStringResolver connectionStringResolver) => new RelationalConnectionDependencies( ContextOptions, diff --git a/src/EFCore/ChangeTracking/Internal/StateManagerDependencies.cs b/src/EFCore/ChangeTracking/Internal/StateManagerDependencies.cs index 55d89aafab8..b8d58d85fac 100644 --- a/src/EFCore/ChangeTracking/Internal/StateManagerDependencies.cs +++ b/src/EFCore/ChangeTracking/Internal/StateManagerDependencies.cs @@ -167,6 +167,7 @@ public StateManagerDependencies( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// + [EntityFrameworkInternal] public IDbSetSource SetSource { get; } /// @@ -175,6 +176,7 @@ public StateManagerDependencies( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// + [EntityFrameworkInternal] public IEntityFinderSource EntityFinderSource { get; } /// @@ -406,6 +408,7 @@ public StateManagerDependencies With([NotNull] ICurrentDbContext currentContext) /// /// A replacement for the current dependency of this type. /// A new parameter object with the given service replaced. + [EntityFrameworkInternal] public StateManagerDependencies With([NotNull] IEntityFinderSource entityFinderSource) => new StateManagerDependencies( InternalEntityEntryFactory, @@ -429,6 +432,7 @@ public StateManagerDependencies With([NotNull] IEntityFinderSource entityFinderS /// /// A replacement for the current dependency of this type. /// A new parameter object with the given service replaced. + [EntityFrameworkInternal] public StateManagerDependencies With([NotNull] IDbSetSource setSource) => new StateManagerDependencies( InternalEntityEntryFactory, diff --git a/src/EFCore/Infrastructure/DbSetFinderExtensions.cs b/src/EFCore/Infrastructure/DbSetFinderExtensions.cs index 07109558337..3a11206e0c7 100644 --- a/src/EFCore/Infrastructure/DbSetFinderExtensions.cs +++ b/src/EFCore/Infrastructure/DbSetFinderExtensions.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Internal; namespace Microsoft.EntityFrameworkCore.Infrastructure { diff --git a/src/EFCore/Infrastructure/IDbSetFinder.cs b/src/EFCore/Infrastructure/IDbSetFinder.cs new file mode 100644 index 00000000000..59b7489ce75 --- /dev/null +++ b/src/EFCore/Infrastructure/IDbSetFinder.cs @@ -0,0 +1,30 @@ +// 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 JetBrains.Annotations; +using Microsoft.Extensions.DependencyInjection; + +namespace Microsoft.EntityFrameworkCore.Infrastructure +{ + /// + /// + /// A service for finding properties on a type that inherits from . + /// + /// + /// The service lifetime is . This means a single instance + /// is used by many instances. The implementation must be thread-safe. + /// This service cannot depend on services registered as . + /// + /// + public interface IDbSetFinder + { + /// + /// Finds properties on a type that inherits from . + /// + /// A type that inherits from + /// A list of the found properties. + IReadOnlyList FindSets([NotNull] Type contextType); + } +} diff --git a/src/EFCore/Infrastructure/ModelCustomizerDependencies.cs b/src/EFCore/Infrastructure/ModelCustomizerDependencies.cs index d6e289b635a..f8e86beaf00 100644 --- a/src/EFCore/Infrastructure/ModelCustomizerDependencies.cs +++ b/src/EFCore/Infrastructure/ModelCustomizerDependencies.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; diff --git a/src/EFCore/Infrastructure/ModelValidatorDependencies.cs b/src/EFCore/Infrastructure/ModelValidatorDependencies.cs index 2e0c97eeccd..6d470eba83a 100644 --- a/src/EFCore/Infrastructure/ModelValidatorDependencies.cs +++ b/src/EFCore/Infrastructure/ModelValidatorDependencies.cs @@ -77,6 +77,7 @@ public ModelValidatorDependencies( /// /// The member classifier. /// + [EntityFrameworkInternal] public IMemberClassifier MemberClassifier { get; } /// @@ -92,6 +93,7 @@ public ModelValidatorDependencies With([NotNull] ITypeMappingSource typeMappingS /// /// A replacement for the current dependency of this type. /// A new parameter object with the given service replaced. + [EntityFrameworkInternal] public ModelValidatorDependencies With([NotNull] IMemberClassifier memberClassifier) => new ModelValidatorDependencies(TypeMappingSource, memberClassifier); } diff --git a/src/EFCore/Internal/DbSetInitializer.cs b/src/EFCore/Internal/DbSetInitializer.cs index f5b168d643a..9bcd19368aa 100644 --- a/src/EFCore/Internal/DbSetInitializer.cs +++ b/src/EFCore/Internal/DbSetInitializer.cs @@ -3,6 +3,7 @@ using System.Linq; using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Internal diff --git a/src/EFCore/Internal/IDbSetFinder.cs b/src/EFCore/Internal/IDbSetFinder.cs deleted file mode 100644 index 9ac24743f81..00000000000 --- a/src/EFCore/Internal/IDbSetFinder.cs +++ /dev/null @@ -1,35 +0,0 @@ -// 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 JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.Extensions.DependencyInjection; - -namespace Microsoft.EntityFrameworkCore.Internal -{ - /// - /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// any release. You should only use it directly in your code with extreme caution and knowing that - /// doing so can result in application failures when updating to a new Entity Framework Core release. - /// - /// - /// The service lifetime is . This means a single instance - /// is used by many instances. The implementation must be thread-safe. - /// This service cannot depend on services registered as . - /// - /// - public interface IDbSetFinder - { - /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// any release. You should only use it directly in your code with extreme caution and knowing that - /// doing so can result in application failures when updating to a new Entity Framework Core release. - /// - IReadOnlyList FindSets([NotNull] Type contextType); - } -} diff --git a/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs b/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs index 2bc829215bc..deb67b167cd 100644 --- a/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs +++ b/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs @@ -5,7 +5,6 @@ using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Utilities; @@ -116,6 +115,7 @@ public ProviderConventionSetBuilderDependencies( /// /// The member classifier. /// + [EntityFrameworkInternal] public IMemberClassifier MemberClassifier { get; } /// @@ -204,6 +204,7 @@ public ProviderConventionSetBuilderDependencies With([NotNull] IParameterBinding /// /// A replacement for the current dependency of this type. /// A new parameter object with the given service replaced. + [EntityFrameworkInternal] public ProviderConventionSetBuilderDependencies With([NotNull] IMemberClassifier memberClassifier) => new ProviderConventionSetBuilderDependencies( TypeMappingSource, ConstructorBindingFactory, ParameterBindingFactories, memberClassifier, Logger, ValidationLogger,