-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
RevEng: Make some APIs public (non-Internal) #10517
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
src/EFCore.Design/Design/DesignTimeServiceCollectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// 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.Diagnostics; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Design.Internal; | ||
using Microsoft.EntityFrameworkCore.Diagnostics; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Internal; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
using Microsoft.EntityFrameworkCore.Migrations.Design; | ||
using Microsoft.EntityFrameworkCore.Migrations.Internal; | ||
using Microsoft.EntityFrameworkCore.Scaffolding; | ||
using Microsoft.EntityFrameworkCore.Scaffolding.Internal; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Design | ||
{ | ||
/// <summary> | ||
/// Extension methods for adding Entity Framework Core design-time services to an <see cref="IServiceCollection" />. | ||
/// </summary> | ||
public static class DesignTimeServiceCollectionExtensions | ||
{ | ||
/// <summary> | ||
/// Adds the Entity Framework Core design-time services. | ||
/// </summary> | ||
/// <param name="services"> The <see cref="IServiceCollection" /> the services will be added to. </param> | ||
/// <returns> The <paramref name="services" />. This enables chaining additional method calls. </returns> | ||
public static IServiceCollection AddEntityFrameworkDesignTimeServices([NotNull] this IServiceCollection services) | ||
=> services.AddEntityFrameworkDesignTimeServices(new OperationReporter(handler: null)); | ||
|
||
/// <summary> | ||
/// Adds the Entity Framework Core design-time services. | ||
/// </summary> | ||
/// <param name="services"> The <see cref="IServiceCollection" /> the services will be added to. </param> | ||
/// <param name="reporter"> Used to report design-time messages. </param> | ||
/// <returns> The <paramref name="services" />. This enables chaining additional method calls. </returns> | ||
public static IServiceCollection AddEntityFrameworkDesignTimeServices( | ||
[NotNull] this IServiceCollection services, | ||
[NotNull] IOperationReporter reporter) | ||
=> services | ||
.AddSingleton<AnnotationCodeGeneratorDependencies>() | ||
.AddSingleton<CoreTypeMapperDependencies>() | ||
.AddSingleton<CSharpMigrationOperationGeneratorDependencies>() | ||
.AddSingleton<CSharpMigrationsGeneratorDependencies>() | ||
.AddSingleton<CSharpSnapshotGeneratorDependencies>() | ||
.AddSingleton<MigrationsCodeGeneratorDependencies>() | ||
.AddSingleton<ModelCodeGeneratorDependencies>() | ||
.AddSingleton<ProviderCodeGeneratorDependencies>() | ||
.AddSingleton<RelationalTypeMapperDependencies>() | ||
.AddSingleton<ICandidateNamingService, CandidateNamingService>() | ||
.AddSingleton<ICSharpDbContextGenerator, CSharpDbContextGenerator>() | ||
.AddSingleton<ICSharpEntityTypeGenerator, CSharpEntityTypeGenerator>() | ||
.AddSingleton<ICSharpHelper, CSharpHelper>() | ||
.AddSingleton<ICSharpMigrationOperationGenerator, CSharpMigrationOperationGenerator>() | ||
.AddSingleton<ICSharpSnapshotGenerator, CSharpSnapshotGenerator>() | ||
.AddSingleton<ICSharpUtilities, CSharpUtilities>() | ||
.AddSingleton(typeof(IDiagnosticsLogger<>), typeof(DiagnosticsLogger<>)) | ||
.AddSingleton<DiagnosticSource>(new DiagnosticListener(DbLoggerCategory.Name)) | ||
.AddSingleton<ILoggingOptions, LoggingOptions>() | ||
.AddSingleton<IMigrationsCodeGenerator, CSharpMigrationsGenerator>() | ||
.AddSingleton<IMigrationsCodeGeneratorSelector, MigrationsCodeGeneratorSelector>() | ||
.AddSingleton<IModelCodeGenerator, CSharpModelGenerator>() | ||
.AddSingleton<IModelCodeGeneratorSelector, ModelCodeGeneratorSelector>() | ||
.AddSingleton(reporter) | ||
.AddSingleton<IPluralizer, NullPluralizer>() | ||
.AddSingleton<IReverseEngineerScaffolder, ReverseEngineerScaffolder>() | ||
.AddSingleton<IScaffoldingModelFactory, RelationalScaffoldingModelFactory>() | ||
.AddSingleton<IScaffoldingTypeMapper, ScaffoldingTypeMapper>() | ||
.AddTransient<MigrationsScaffolderDependencies>() | ||
.AddTransient<IMigrationsScaffolder, MigrationsScaffolder>() | ||
.AddTransient<ISnapshotModelProcessor, SnapshotModelProcessor>() | ||
.AddLogging(b => b.SetMinimumLevel(LogLevel.Debug).AddProvider(new OperationLoggerProvider(reporter))); | ||
|
||
/// <summary> | ||
/// Adds services from the <see cref="DbContext" /> which are used at design time. | ||
/// </summary> | ||
/// <param name="services"> The <see cref="IServiceCollection" /> the services will be added to. </param> | ||
/// <param name="context"> The <see cref="DbContext" /> the services will be added from. </param> | ||
/// <returns> The <paramref name="services" />. This enables chaining additional method calls. </returns> | ||
public static IServiceCollection AddDbContextDesignTimeServices( | ||
[NotNull] this IServiceCollection services, | ||
[NotNull] DbContext context) | ||
=> services | ||
.AddTransient(_ => context.GetService<ICurrentDbContext>()) | ||
.AddTransient(_ => context.GetService<IDatabaseProvider>()) | ||
.AddTransient(_ => context.GetService<IDbContextOptions>()) | ||
.AddTransient(_ => context.GetService<IHistoryRepository>()) | ||
.AddTransient(_ => context.GetService<IMigrationsAssembly>()) | ||
.AddTransient(_ => context.GetService<IMigrationsIdGenerator>()) | ||
.AddTransient(_ => context.GetService<IMigrationsModelDiffer>()) | ||
.AddTransient(_ => context.GetService<IMigrator>()) | ||
.AddTransient(_ => context.GetService<IModel>()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/EFCore.Design/Migrations/Design/IMigrationsCodeGeneratorSelector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// 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 JetBrains.Annotations; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Migrations.Design | ||
{ | ||
/// <summary> | ||
/// Selects an <see cref="IMigrationsCodeGenerator" /> service for a given programming language. | ||
/// </summary> | ||
public interface IMigrationsCodeGeneratorSelector | ||
{ | ||
/// <summary> | ||
/// Selects an <see cref="IMigrationsCodeGenerator" /> service for a given programming language. | ||
/// </summary> | ||
/// <param name="language"> The programming language. </param> | ||
/// <returns> The <see cref="IMigrationsCodeGenerator" />. </returns> | ||
IMigrationsCodeGenerator Select([CanBeNull] string language); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these args converted to full path specification rather than relative paths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to do a bit verification in this area before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
projectDir
is.outputDir
is as it was entered by the userThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will normalize outputDir here.