diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageExtensions.cs b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageExtensions.cs index a650eb090b..4ca7f0bf43 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageExtensions.cs @@ -8,33 +8,54 @@ using System; namespace Microsoft.AspNet.Builder { + /// + /// extension methods for the . + /// public static class DatabaseErrorPageExtensions { - public static IApplicationBuilder UseDatabaseErrorPage([NotNull] this IApplicationBuilder builder) + /// + /// Captures synchronous and asynchronous database related exceptions from the pipeline that may be resolved using Entity Framework + /// migrations. When these exceptions occur an HTML response with details of possible actions to resolve the issue is generated. The + /// options for the middleware are set to display the maximum amount of information available. + /// + /// The to register the middleware with. + /// The same instance so that multiple calls can be chained. + public static IApplicationBuilder UseDatabaseErrorPage([NotNull] this IApplicationBuilder app) { - Check.NotNull(builder, nameof(builder)); + Check.NotNull(app, nameof(app)); - return builder.UseDatabaseErrorPage(options => options.EnableAll()); + return app.UseDatabaseErrorPage(options => options.EnableAll()); } - public static IApplicationBuilder UseDatabaseErrorPage([NotNull] this IApplicationBuilder builder, [NotNull] Action optionsAction) + /// + /// Captures synchronous and asynchronous database related exceptions from the pipeline that may be resolved using Entity Framework + /// migrations. When these exceptions occur an HTML response with details of possible actions to resolve the issue is generated. + /// + /// The to register the middleware with. + /// An action to set the options for the middleware. All options are disabled by default. + /// The same instance so that multiple calls can be chained. + public static IApplicationBuilder UseDatabaseErrorPage([NotNull] this IApplicationBuilder app, [NotNull] Action optionsAction) { - Check.NotNull(builder, nameof(builder)); + Check.NotNull(app, nameof(app)); Check.NotNull(optionsAction, nameof(optionsAction)); var options = new DatabaseErrorPageOptions(); optionsAction(options); - builder = builder.UseMiddleware(options); + app = app.UseMiddleware(options); if(options.EnableMigrationCommands) { - builder.UseMigrationsEndPoint(o => o.Path = options.MigrationsEndPointPath); + app.UseMigrationsEndPoint(o => o.Path = options.MigrationsEndPointPath); } - return builder; + return app; } + /// + /// Sets the options to display the maximum amount of information available. + /// + /// The options to be configured. public static void EnableAll([NotNull] this DatabaseErrorPageOptions options) { Check.NotNull(options, nameof(options)); diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs index bad1698582..a0cc65f002 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs @@ -17,6 +17,10 @@ using Microsoft.Extensions.Logging; namespace Microsoft.AspNet.Diagnostics.Entity { + /// + /// Captures synchronous and asynchronous database related exceptions from the pipeline that may be resolved using Entity Framework + /// migrations. When these exceptions occur an HTML response with details of possible actions to resolve the issue is generated. + /// public class DatabaseErrorPageMiddleware { private readonly RequestDelegate _next; @@ -25,6 +29,16 @@ namespace Microsoft.AspNet.Diagnostics.Entity private readonly ILogger _logger; private readonly DataStoreErrorLoggerProvider _loggerProvider; + /// + /// Initializes a new instance of the class + /// + /// Delegate to execute the next piece of middleware in the request pipeline. + /// The to resolve services from. + /// + /// The for the application. This middleware both produces logging messages and + /// consumes them to detect database related exception. + /// + /// The options to control what information is displayed on the error page. public DatabaseErrorPageMiddleware([NotNull] RequestDelegate next, [NotNull] IServiceProvider serviceProvider, [NotNull] ILoggerFactory loggerFactory, [NotNull] DatabaseErrorPageOptions options) { Check.NotNull(next, nameof(next)); @@ -41,6 +55,11 @@ namespace Microsoft.AspNet.Diagnostics.Entity loggerFactory.AddProvider(_loggerProvider); } + /// + /// Process an individual request. + /// + /// The context for the current request. + /// A task that represents the asynchronous operation. public virtual async Task Invoke([NotNull] HttpContext context) { Check.NotNull(context, "context"); diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageOptions.cs b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageOptions.cs index 4cacd57f06..38d9318b47 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageOptions.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageOptions.cs @@ -5,11 +5,34 @@ using Microsoft.AspNet.Http; namespace Microsoft.AspNet.Diagnostics.Entity { + /// + /// Options for the . + /// public class DatabaseErrorPageOptions { + /// + /// Gets or sets a value indicating whether details about the exception that occurred + /// are displayed on the error page. + /// public virtual bool ShowExceptionDetails { get; set; } + + /// + /// Gets or sets a value indicating whether the names of pending migrations are listed + /// on the error page. + /// public virtual bool ListMigrations { get; set; } + + /// + /// Gets or sets a value indicating whether the error page will allow the execution of + /// migrations related commands when they may help solve the current error. + /// public virtual bool EnableMigrationCommands { get; set; } + + /// + /// Gets or sets the path that will listen + /// for requests to execute migrations commands. The middleware is only registered if + /// is set to true. + /// public virtual PathString MigrationsEndPointPath { get; set; } } } diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointExtensions.cs b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointExtensions.cs index 0c40f827ea..0467cb5d22 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointExtensions.cs @@ -8,24 +8,38 @@ using Microsoft.AspNet.Diagnostics.Entity.Utilities; namespace Microsoft.AspNet.Builder { + /// + /// extension methods for the . + /// public static class MigrationsEndPointExtensions { - public static IApplicationBuilder UseMigrationsEndPoint([NotNull] this IApplicationBuilder builder) + /// + /// Processes requests to execute migrations operations. The middleware will listen for requests made to . + /// + /// The to register the middleware with. + /// The same instance so that multiple calls can be chained. + public static IApplicationBuilder UseMigrationsEndPoint([NotNull] this IApplicationBuilder app) { - Check.NotNull(builder, "builder"); + Check.NotNull(app, "builder"); - return builder.UseMigrationsEndPoint(options => { }); + return app.UseMigrationsEndPoint(options => { }); } - public static IApplicationBuilder UseMigrationsEndPoint([NotNull] this IApplicationBuilder builder, [NotNull] Action optionsAction) + /// + /// Processes requests to execute migrations operations. The middleware will listen for requests to the path configured in . + /// + /// The to register the middleware with. + /// An action to set the options for the middleware. + /// The same instance so that multiple calls can be chained. + public static IApplicationBuilder UseMigrationsEndPoint([NotNull] this IApplicationBuilder app, [NotNull] Action optionsAction) { - Check.NotNull(builder, "builder"); + Check.NotNull(app, "builder"); Check.NotNull(optionsAction, "optionsAction"); var options = new MigrationsEndPointOptions(); optionsAction(options); - return builder.UseMiddleware(options); + return app.UseMiddleware(options); } } } diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs index eefc1370ff..d1be0df65a 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs @@ -13,6 +13,9 @@ using Microsoft.Extensions.Logging; namespace Microsoft.AspNet.Diagnostics.Entity { + /// + /// Processes requests to execute migrations operations. The middleware will listen for requests to the path configured in the supplied options. + /// public class MigrationsEndPointMiddleware { private readonly RequestDelegate _next; @@ -20,6 +23,13 @@ namespace Microsoft.AspNet.Diagnostics.Entity private readonly ILogger _logger; private readonly MigrationsEndPointOptions _options; + /// + /// Initializes a new instance of the class + /// + /// Delegate to execute the next piece of middleware in the request pipeline. + /// The to resolve services from. + /// The to write messages to. + /// The options to control the behavior of the middleware. public MigrationsEndPointMiddleware( [NotNull] RequestDelegate next, [NotNull] IServiceProvider serviceProvider, @@ -37,6 +47,11 @@ namespace Microsoft.AspNet.Diagnostics.Entity _options = options; } + /// + /// Process an individual request. + /// + /// The context for the current request. + /// A task that represents the asynchronous operation. public virtual async Task Invoke([NotNull] HttpContext context) { Check.NotNull(context, "context"); diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointOptions.cs b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointOptions.cs index a2cf6b201d..1f9bb2d780 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointOptions.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointOptions.cs @@ -5,10 +5,20 @@ using Microsoft.AspNet.Http; namespace Microsoft.AspNet.Diagnostics.Entity { + /// + /// Options for the . + /// public class MigrationsEndPointOptions { + /// + /// The default value for . + /// public static PathString DefaultPath = new PathString("/ApplyDatabaseMigrations"); + /// + /// Gets or sets the path that the will listen + /// for requests to execute migrations commands. + /// public virtual PathString Path { get; set; } = DefaultPath; } }