From d22bb2c908f5aed83aefe4ca8a94227251ba820c Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Fri, 15 Sep 2017 14:26:47 -0700 Subject: [PATCH] Add logger extensions with event ids (#405) Addresses #393 --- .../ElmCaptureMiddleware.cs | 1 - .../DatabaseErrorPageMiddleware.cs | 34 +- ...ticsEntityFrameworkCoreLoggerExtensions.cs | 153 +++++++++ .../MigrationsEndPointMiddleware.cs | 15 +- .../Properties/Strings.Designer.cs | 290 ++++-------------- .../Strings.resx | 23 +- .../DeveloperExceptionPageMiddleware.cs | 10 +- .../ExceptionHandlerMiddleware.cs | 7 +- .../Internal/DiagnosticsLoggerExtensions.cs | 54 ++++ .../Properties/Resources.Designer.cs | 246 +++++---------- ...agnostics.EntityFrameworkCore.Tests.csproj | 4 + ...rosoft.AspNetCore.Diagnostics.Tests.csproj | 4 + 12 files changed, 393 insertions(+), 448 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Internal/DiagnosticsEntityFrameworkCoreLoggerExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Diagnostics/Internal/DiagnosticsLoggerExtensions.cs diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/ElmCaptureMiddleware.cs b/src/Microsoft.AspNetCore.Diagnostics.Elm/ElmCaptureMiddleware.cs index afaae82a65..e71d21dcfa 100644 --- a/src/Microsoft.AspNetCore.Diagnostics.Elm/ElmCaptureMiddleware.cs +++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/ElmCaptureMiddleware.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.Logging; diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/DatabaseErrorPageMiddleware.cs b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/DatabaseErrorPageMiddleware.cs index 53ba0e0cfd..3dffe8818d 100644 --- a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/DatabaseErrorPageMiddleware.cs +++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/DatabaseErrorPageMiddleware.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Internal; using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Views; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; @@ -115,7 +116,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore if (context == null) { - _logger.LogError(Strings.FormatDatabaseErrorPageMiddleware_ContextNotRegistered(contextType.FullName)); + _logger.ContextNotRegisteredDatabaseErrorPageMiddleware(contextType.FullName); } else { @@ -123,7 +124,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore if (relationalDatabaseCreator == null) { - _logger.LogDebug(Strings.DatabaseErrorPage_NotRelationalDatabase); + _logger.NotRelationalDatabase(); } else { @@ -164,10 +165,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore } catch (Exception e) { - _logger.LogError( - eventId: 0, - exception: e, - message: Strings.DatabaseErrorPageMiddleware_Exception); + _logger.DatabaseErrorPageMiddlewareException(e); } throw; @@ -176,13 +174,13 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore private bool ShouldDisplayErrorPage(Exception exception) { - _logger.LogDebug(Strings.FormatDatabaseErrorPage_AttemptingToMatchException(exception.GetType())); + _logger.AttemptingToMatchException(exception.GetType()); var lastRecordedException = _localDiagnostic.Value.Exception; if (lastRecordedException == null) { - _logger.LogDebug(Strings.DatabaseErrorPage_NoRecordedException); + _logger.NoRecordedException(); return false; } @@ -196,12 +194,12 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore if (!match) { - _logger.LogDebug(Strings.DatabaseErrorPage_NoMatch); + _logger.NoMatch(); return false; } - _logger.LogDebug(Strings.DatabaseErrorPage_Matched); + _logger.Matched(); return true; } @@ -219,17 +217,17 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore switch (keyValuePair.Value) { case DbContextErrorEventData contextErrorEventData: - { - _localDiagnostic.Value.Hold(contextErrorEventData.Exception, contextErrorEventData.Context.GetType()); + { + _localDiagnostic.Value.Hold(contextErrorEventData.Exception, contextErrorEventData.Context.GetType()); - break; - } + break; + } case DbContextTypeErrorEventData contextTypeErrorEventData: - { - _localDiagnostic.Value.Hold(contextTypeErrorEventData.Exception, contextTypeErrorEventData.ContextType); + { + _localDiagnostic.Value.Hold(contextTypeErrorEventData.Exception, contextTypeErrorEventData.ContextType); - break; - } + break; + } } } diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Internal/DiagnosticsEntityFrameworkCoreLoggerExtensions.cs b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Internal/DiagnosticsEntityFrameworkCoreLoggerExtensions.cs new file mode 100644 index 0000000000..e7749f488a --- /dev/null +++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Internal/DiagnosticsEntityFrameworkCoreLoggerExtensions.cs @@ -0,0 +1,153 @@ +// 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 Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Internal +{ + internal static class DiagnosticsEntityFrameworkCoreLoggerExtensions + { + // MigrationsEndPointMiddleware + private static readonly Action _noContextType = LoggerMessage.Define( + LogLevel.Error, + new EventId(1, "NoContextType"), + "No context type was specified. Ensure the form data from the request includes a contextTypeName value, specifying the context to apply migrations for."); + + private static readonly Action _invalidContextType = LoggerMessage.Define( + LogLevel.Error, + new EventId(2, "InvalidContextType"), + "The context type '{ContextTypeName}' could not be loaded. Ensure this is the correct type name for the context you are trying to apply migrations for."); + + private static readonly Action _contextNotRegistered = LoggerMessage.Define( + LogLevel.Error, + new EventId(3, "ContextNotRegistered"), + "The context type '{ContextTypeName}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<>() inside the UseServices(...) call in your application startup code."); + + private static readonly Action _requestPathMatched = LoggerMessage.Define( + LogLevel.Debug, + new EventId(4, "RequestPathMatched"), + "Request path matched the path configured for this migrations endpoint({RequestPath}). Attempting to process the migrations request."); + + private static readonly Action _applyingMigrations = LoggerMessage.Define( + LogLevel.Debug, + new EventId(5, "ApplyingMigrations"), + "Request is valid, applying migrations for context '{ContextTypeName}'"); + + private static readonly Action _migrationsApplied = LoggerMessage.Define( + LogLevel.Debug, + new EventId(6, "MigrationsApplied"), + "Migrations successfully applied for context '{ContextTypeName}'."); + + private static readonly Action _migrationsEndPointMiddlewareException = LoggerMessage.Define( + LogLevel.Error, + new EventId(7, "MigrationsEndPointException"), + "An error occurred while applying the migrations for '{ContextTypeName}'. See InnerException for details:"); + + // DatabaseErrorPageMiddleware + private static readonly Action _attemptingToMatchException = LoggerMessage.Define( + LogLevel.Debug, + new EventId(1, "AttemptingToMatchException"), + "{ExceptionType} occurred, checking if Entity Framework recorded this exception as resulting from a failed database operation."); + + private static readonly Action _noRecordedException = LoggerMessage.Define( + LogLevel.Debug, + new EventId(2, "NoRecordedException"), + "Entity Framework did not record any exceptions due to failed database operations. This means the current exception is not a failed Entity Framework database operation, or the current exception occurred from a DbContext that was not obtained from request services."); + + private static readonly Action _noMatch = LoggerMessage.Define( + LogLevel.Debug, + new EventId(3, "NoMatchFound"), + "The current exception (and its inner exceptions) do not match the last exception Entity Framework recorded due to a failed database operation. This means the database operation exception was handled and another exception occurred later in the request."); + + private static readonly Action _matched = LoggerMessage.Define( + LogLevel.Debug, + new EventId(4, "MatchFound"), + "Entity Framework recorded that the current exception was due to a failed database operation. Attempting to show database error page."); + + private static readonly Action _contextNotRegisteredDatabaseErrorPageMiddleware = LoggerMessage.Define( + LogLevel.Error, + new EventId(5, "ContextNotRegistered"), + "The context type '{ContextTypeName}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<>() inside the UseServices(...) call in your application startup code. Skipping display of the database error page."); + + private static readonly Action _notRelationalDatabase = LoggerMessage.Define( + LogLevel.Debug, + new EventId(6, "NotRelationalDatabase"), + "The target data store is not a relational database. Skipping the database error page."); + + private static readonly Action _databaseErrorPageMiddlewareException = LoggerMessage.Define( + LogLevel.Error, + new EventId(7, "DatabaseErrorPageException"), + "An exception occurred while calculating the database error page content. Skipping display of the database error page."); + + public static void NoContextType(this ILogger logger) + { + _noContextType(logger, null); + } + + public static void InvalidContextType(this ILogger logger, string contextTypeName) + { + _invalidContextType(logger, contextTypeName, null); + } + + public static void ContextNotRegistered(this ILogger logger, string contextTypeName) + { + _contextNotRegistered(logger, contextTypeName, null); + } + + public static void RequestPathMatched(this ILogger logger, string requestPath) + { + _requestPathMatched(logger, requestPath, null); + } + + public static void ApplyingMigrations(this ILogger logger, string contextTypeName) + { + _applyingMigrations(logger, contextTypeName, null); + } + + public static void MigrationsApplied(this ILogger logger, string contextTypeName) + { + _migrationsApplied(logger, contextTypeName, null); + } + + public static void MigrationsEndPointMiddlewareException(this ILogger logger, string context, Exception exception) + { + _migrationsEndPointMiddlewareException(logger, context, exception); + } + + public static void AttemptingToMatchException(this ILogger logger, Type exceptionType) + { + _attemptingToMatchException(logger, exceptionType, null); + } + + public static void NoRecordedException(this ILogger logger) + { + _noRecordedException(logger, null); + } + + public static void NoMatch(this ILogger logger) + { + _noMatch(logger, null); + } + + public static void Matched(this ILogger logger) + { + _matched(logger, null); + } + + public static void NotRelationalDatabase(this ILogger logger) + { + _notRelationalDatabase(logger, null); + } + + public static void ContextNotRegisteredDatabaseErrorPageMiddleware(this ILogger logger, string contextTypeName) + { + _contextNotRegisteredDatabaseErrorPageMiddleware(logger, contextTypeName, null); + } + + public static void DatabaseErrorPageMiddlewareException(this ILogger logger, Exception exception) + { + _databaseErrorPageMiddlewareException(logger, exception); + } + } +} diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/MigrationsEndPointMiddleware.cs b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/MigrationsEndPointMiddleware.cs index 68166b3e90..4562bf4218 100644 --- a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/MigrationsEndPointMiddleware.cs +++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/MigrationsEndPointMiddleware.cs @@ -5,6 +5,7 @@ using System; using System.Net; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Internal; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; @@ -66,7 +67,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore if (context.Request.Path.Equals(_options.Path)) { - _logger.LogDebug(Strings.FormatMigrationsEndPointMiddleware_RequestPathMatched(context.Request.Path)); + _logger.RequestPathMatched(context.Request.Path); var db = await GetDbContext(context, _logger); @@ -74,7 +75,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore { try { - _logger.LogDebug(Strings.FormatMigrationsEndPointMiddleware_ApplyingMigrations(db.GetType().FullName)); + _logger.ApplyingMigrations(db.GetType().FullName); db.Database.Migrate(); @@ -82,13 +83,13 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore context.Response.Headers.Add("Pragma", new[] { "no-cache" }); context.Response.Headers.Add("Cache-Control", new[] { "no-cache" }); - _logger.LogDebug(Strings.FormatMigrationsEndPointMiddleware_Applied(db.GetType().FullName)); + _logger.MigrationsApplied(db.GetType().FullName); } catch (Exception ex) { var message = Strings.FormatMigrationsEndPointMiddleware_Exception(db.GetType().FullName) + ex; - _logger.LogError(message); + _logger.MigrationsEndPointMiddlewareException(db.GetType().FullName, ex); throw new InvalidOperationException(message, ex); } @@ -107,7 +108,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore if (string.IsNullOrWhiteSpace(contextTypeName)) { - logger.LogError(Strings.MigrationsEndPointMiddleware_NoContextType); + logger.NoContextType(); await WriteErrorToResponse(context.Response, Strings.MigrationsEndPointMiddleware_NoContextType); @@ -120,7 +121,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore { var message = Strings.FormatMigrationsEndPointMiddleware_InvalidContextType(contextTypeName); - logger.LogError(message); + logger.InvalidContextType(contextTypeName); await WriteErrorToResponse(context.Response, message); @@ -133,7 +134,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore { var message = Strings.FormatMigrationsEndPointMiddleware_ContextNotRegistered(contextType.FullName); - logger.LogError(message); + logger.ContextNotRegistered(contextType.FullName); await WriteErrorToResponse(context.Response, message); diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Properties/Strings.Designer.cs b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Properties/Strings.Designer.cs index b076689f62..3266d2f144 100644 --- a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Properties/Strings.Designer.cs +++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Properties/Strings.Designer.cs @@ -11,548 +11,382 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore = new ResourceManager("Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Strings", typeof(Strings).GetTypeInfo().Assembly); /// - /// The context type '{0}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<{0}>() inside the UseServices(...) call in your application startup code. Skipping display of the database error page. + /// The context type '{0}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<>() inside the UseServices(...) call in your application startup code. Skipping display of the database error page. /// internal static string DatabaseErrorPageMiddleware_ContextNotRegistered { - get { return GetString("DatabaseErrorPageMiddleware_ContextNotRegistered"); } + get => GetString("DatabaseErrorPageMiddleware_ContextNotRegistered"); } /// - /// The context type '{0}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<{0}>() inside the UseServices(...) call in your application startup code. Skipping display of the database error page. + /// The context type '{0}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<>() inside the UseServices(...) call in your application startup code. Skipping display of the database error page. /// internal static string FormatDatabaseErrorPageMiddleware_ContextNotRegistered(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPageMiddleware_ContextNotRegistered"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPageMiddleware_ContextNotRegistered"), p0); /// /// An exception occurred while calculating the database error page content. Skipping display of the database error page. /// internal static string DatabaseErrorPageMiddleware_Exception { - get { return GetString("DatabaseErrorPageMiddleware_Exception"); } + get => GetString("DatabaseErrorPageMiddleware_Exception"); } /// /// An exception occurred while calculating the database error page content. Skipping display of the database error page. /// internal static string FormatDatabaseErrorPageMiddleware_Exception() - { - return GetString("DatabaseErrorPageMiddleware_Exception"); - } + => GetString("DatabaseErrorPageMiddleware_Exception"); /// /// > dotnet ef migrations add [migration name] /// internal static string DatabaseErrorPage_AddMigrationCommandCLI { - get { return GetString("DatabaseErrorPage_AddMigrationCommandCLI"); } + get => GetString("DatabaseErrorPage_AddMigrationCommandCLI"); } /// /// > dotnet ef migrations add [migration name] /// internal static string FormatDatabaseErrorPage_AddMigrationCommandCLI() - { - return GetString("DatabaseErrorPage_AddMigrationCommandCLI"); - } + => GetString("DatabaseErrorPage_AddMigrationCommandCLI"); /// /// Apply Migrations /// internal static string DatabaseErrorPage_ApplyMigrationsButton { - get { return GetString("DatabaseErrorPage_ApplyMigrationsButton"); } + get => GetString("DatabaseErrorPage_ApplyMigrationsButton"); } /// /// Apply Migrations /// internal static string FormatDatabaseErrorPage_ApplyMigrationsButton() - { - return GetString("DatabaseErrorPage_ApplyMigrationsButton"); - } + => GetString("DatabaseErrorPage_ApplyMigrationsButton"); /// /// Migrations Applied /// internal static string DatabaseErrorPage_ApplyMigrationsButtonDone { - get { return GetString("DatabaseErrorPage_ApplyMigrationsButtonDone"); } + get => GetString("DatabaseErrorPage_ApplyMigrationsButtonDone"); } /// /// Migrations Applied /// internal static string FormatDatabaseErrorPage_ApplyMigrationsButtonDone() - { - return GetString("DatabaseErrorPage_ApplyMigrationsButtonDone"); - } + => GetString("DatabaseErrorPage_ApplyMigrationsButtonDone"); /// /// Applying Migrations... /// internal static string DatabaseErrorPage_ApplyMigrationsButtonRunning { - get { return GetString("DatabaseErrorPage_ApplyMigrationsButtonRunning"); } + get => GetString("DatabaseErrorPage_ApplyMigrationsButtonRunning"); } /// /// Applying Migrations... /// internal static string FormatDatabaseErrorPage_ApplyMigrationsButtonRunning() - { - return GetString("DatabaseErrorPage_ApplyMigrationsButtonRunning"); - } + => GetString("DatabaseErrorPage_ApplyMigrationsButtonRunning"); /// /// An error occurred applying migrations, try applying them from the command line /// internal static string DatabaseErrorPage_ApplyMigrationsFailed { - get { return GetString("DatabaseErrorPage_ApplyMigrationsFailed"); } + get => GetString("DatabaseErrorPage_ApplyMigrationsFailed"); } /// /// An error occurred applying migrations, try applying them from the command line /// internal static string FormatDatabaseErrorPage_ApplyMigrationsFailed() - { - return GetString("DatabaseErrorPage_ApplyMigrationsFailed"); - } + => GetString("DatabaseErrorPage_ApplyMigrationsFailed"); /// - /// In Visual Studio, you can use Package Manager Console apply pending migrations to the database: + /// In Visual Studio, you can use the Package Manager Console to apply pending migrations to the database: /// internal static string DatabaseErrorPage_HowToApplyFromPMC { - get { return GetString("DatabaseErrorPage_HowToApplyFromPMC"); } + get => GetString("DatabaseErrorPage_HowToApplyFromPMC"); } /// - /// In Visual Studio, you can use Package Manager Console apply pending migrations to the database: + /// In Visual Studio, you can use the Package Manager Console to apply pending migrations to the database: /// internal static string FormatDatabaseErrorPage_HowToApplyFromPMC() - { - return GetString("DatabaseErrorPage_HowToApplyFromPMC"); - } + => GetString("DatabaseErrorPage_HowToApplyFromPMC"); /// /// Try refreshing the page /// internal static string DatabaseErrorPage_MigrationsAppliedRefresh { - get { return GetString("DatabaseErrorPage_MigrationsAppliedRefresh"); } + get => GetString("DatabaseErrorPage_MigrationsAppliedRefresh"); } /// /// Try refreshing the page /// internal static string FormatDatabaseErrorPage_MigrationsAppliedRefresh() - { - return GetString("DatabaseErrorPage_MigrationsAppliedRefresh"); - } + => GetString("DatabaseErrorPage_MigrationsAppliedRefresh"); /// - /// In Visual Studio, use Package Manager Console to scaffold a new migration and apply it to the database: + /// In Visual Studio, use the Package Manager Console to scaffold a new migration and apply it to the database: /// internal static string DatabaseErrorPage_NoDbOrMigrationsInfoPMC { - get { return GetString("DatabaseErrorPage_NoDbOrMigrationsInfoPMC"); } + get => GetString("DatabaseErrorPage_NoDbOrMigrationsInfoPMC"); } /// - /// In Visual Studio, use Package Manager Console to scaffold a new migration and apply it to the database: + /// In Visual Studio, use the Package Manager Console to scaffold a new migration and apply it to the database: /// internal static string FormatDatabaseErrorPage_NoDbOrMigrationsInfoPMC() - { - return GetString("DatabaseErrorPage_NoDbOrMigrationsInfoPMC"); - } + => GetString("DatabaseErrorPage_NoDbOrMigrationsInfoPMC"); /// /// Use migrations to create the database for {0} /// internal static string DatabaseErrorPage_NoDbOrMigrationsTitle { - get { return GetString("DatabaseErrorPage_NoDbOrMigrationsTitle"); } + get => GetString("DatabaseErrorPage_NoDbOrMigrationsTitle"); } /// /// Use migrations to create the database for {0} /// internal static string FormatDatabaseErrorPage_NoDbOrMigrationsTitle(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_NoDbOrMigrationsTitle"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_NoDbOrMigrationsTitle"), p0); /// - /// In Visual Studio, use Package Manager Console to scaffold a new migration for these changes and apply them to the database: + /// In Visual Studio, use the Package Manager Console to scaffold a new migration for these changes and apply them to the database: /// internal static string DatabaseErrorPage_PendingChangesInfoPMC { - get { return GetString("DatabaseErrorPage_PendingChangesInfoPMC"); } + get => GetString("DatabaseErrorPage_PendingChangesInfoPMC"); } /// - /// In Visual Studio, use Package Manager Console to scaffold a new migration for these changes and apply them to the database: + /// In Visual Studio, use the Package Manager Console to scaffold a new migration for these changes and apply them to the database: /// internal static string FormatDatabaseErrorPage_PendingChangesInfoPMC() - { - return GetString("DatabaseErrorPage_PendingChangesInfoPMC"); - } + => GetString("DatabaseErrorPage_PendingChangesInfoPMC"); /// /// There are pending model changes for {0} /// internal static string DatabaseErrorPage_PendingChangesTitle { - get { return GetString("DatabaseErrorPage_PendingChangesTitle"); } + get => GetString("DatabaseErrorPage_PendingChangesTitle"); } /// /// There are pending model changes for {0} /// internal static string FormatDatabaseErrorPage_PendingChangesTitle(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_PendingChangesTitle"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_PendingChangesTitle"), p0); /// /// There are migrations for {0} that have not been applied to the database /// internal static string DatabaseErrorPage_PendingMigrationsInfo { - get { return GetString("DatabaseErrorPage_PendingMigrationsInfo"); } + get => GetString("DatabaseErrorPage_PendingMigrationsInfo"); } /// /// There are migrations for {0} that have not been applied to the database /// internal static string FormatDatabaseErrorPage_PendingMigrationsInfo(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_PendingMigrationsInfo"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_PendingMigrationsInfo"), p0); /// /// Applying existing migrations for {0} may resolve this issue /// internal static string DatabaseErrorPage_PendingMigrationsTitle { - get { return GetString("DatabaseErrorPage_PendingMigrationsTitle"); } + get => GetString("DatabaseErrorPage_PendingMigrationsTitle"); } /// /// Applying existing migrations for {0} may resolve this issue /// internal static string FormatDatabaseErrorPage_PendingMigrationsTitle(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_PendingMigrationsTitle"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_PendingMigrationsTitle"), p0); /// /// > dotnet ef database update /// internal static string DatabaseErrorPage_ApplyMigrationsCommandCLI { - get { return GetString("DatabaseErrorPage_ApplyMigrationsCommandCLI"); } + get => GetString("DatabaseErrorPage_ApplyMigrationsCommandCLI"); } /// /// > dotnet ef database update /// internal static string FormatDatabaseErrorPage_ApplyMigrationsCommandCLI() - { - return GetString("DatabaseErrorPage_ApplyMigrationsCommandCLI"); - } - - /// - /// Migrations successfully applied for context '{0}'. - /// - internal static string MigrationsEndPointMiddleware_Applied - { - get { return GetString("MigrationsEndPointMiddleware_Applied"); } - } - - /// - /// Migrations successfully applied for context '{0}'. - /// - internal static string FormatMigrationsEndPointMiddleware_Applied(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_Applied"), p0); - } - - /// - /// Request is valid, applying migrations for context '{0}'. - /// - internal static string MigrationsEndPointMiddleware_ApplyingMigrations - { - get { return GetString("MigrationsEndPointMiddleware_ApplyingMigrations"); } - } - - /// - /// Request is valid, applying migrations for context '{0}'. - /// - internal static string FormatMigrationsEndPointMiddleware_ApplyingMigrations(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_ApplyingMigrations"), p0); - } + => GetString("DatabaseErrorPage_ApplyMigrationsCommandCLI"); /// /// The context type '{0}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<{0}>() inside the UseServices(...) call in your application startup code. /// internal static string MigrationsEndPointMiddleware_ContextNotRegistered { - get { return GetString("MigrationsEndPointMiddleware_ContextNotRegistered"); } + get => GetString("MigrationsEndPointMiddleware_ContextNotRegistered"); } /// /// The context type '{0}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<{0}>() inside the UseServices(...) call in your application startup code. /// internal static string FormatMigrationsEndPointMiddleware_ContextNotRegistered(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_ContextNotRegistered"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_ContextNotRegistered"), p0); /// /// An error occurred while applying the migrations for '{0}'. See InnerException for details. /// internal static string MigrationsEndPointMiddleware_Exception { - get { return GetString("MigrationsEndPointMiddleware_Exception"); } + get => GetString("MigrationsEndPointMiddleware_Exception"); } /// /// An error occurred while applying the migrations for '{0}'. See InnerException for details. /// internal static string FormatMigrationsEndPointMiddleware_Exception(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_Exception"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_Exception"), p0); /// /// The context type '{0}' could not be loaded. Ensure this is the correct type name for the context you are trying to apply migrations for. /// internal static string MigrationsEndPointMiddleware_InvalidContextType { - get { return GetString("MigrationsEndPointMiddleware_InvalidContextType"); } + get => GetString("MigrationsEndPointMiddleware_InvalidContextType"); } /// /// The context type '{0}' could not be loaded. Ensure this is the correct type name for the context you are trying to apply migrations for. /// internal static string FormatMigrationsEndPointMiddleware_InvalidContextType(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_InvalidContextType"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_InvalidContextType"), p0); /// /// No context type was specified. Ensure the form data from the request includes a contextTypeName value, specifying the context to apply migrations for. /// internal static string MigrationsEndPointMiddleware_NoContextType { - get { return GetString("MigrationsEndPointMiddleware_NoContextType"); } + get => GetString("MigrationsEndPointMiddleware_NoContextType"); } /// /// No context type was specified. Ensure the form data from the request includes a contextTypeName value, specifying the context to apply migrations for. /// internal static string FormatMigrationsEndPointMiddleware_NoContextType() - { - return GetString("MigrationsEndPointMiddleware_NoContextType"); - } - - /// - /// Request path matched the path configured for this migrations endpoint ({0}). Attempting to process the migrations request. - /// - internal static string MigrationsEndPointMiddleware_RequestPathMatched - { - get { return GetString("MigrationsEndPointMiddleware_RequestPathMatched"); } - } - - /// - /// Request path matched the path configured for this migrations endpoint ({0}). Attempting to process the migrations request. - /// - internal static string FormatMigrationsEndPointMiddleware_RequestPathMatched(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("MigrationsEndPointMiddleware_RequestPathMatched"), p0); - } + => GetString("MigrationsEndPointMiddleware_NoContextType"); /// /// A database operation failed while processing the request. /// internal static string DatabaseErrorPage_Title { - get { return GetString("DatabaseErrorPage_Title"); } + get => GetString("DatabaseErrorPage_Title"); } /// /// A database operation failed while processing the request. /// internal static string FormatDatabaseErrorPage_Title() - { - return GetString("DatabaseErrorPage_Title"); - } - - /// - /// {0} occurred, checking if Entity Framework recorded this exception as resulting from a failed database operation. - /// - internal static string DatabaseErrorPage_AttemptingToMatchException - { - get { return GetString("DatabaseErrorPage_AttemptingToMatchException"); } - } - - /// - /// {0} occurred, checking if Entity Framework recorded this exception as resulting from a failed database operation. - /// - internal static string FormatDatabaseErrorPage_AttemptingToMatchException(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_AttemptingToMatchException"), p0); - } - - /// - /// Entity Framework recorded that the current exception was due to a failed database operation. Attempting to show database error page. - /// - internal static string DatabaseErrorPage_Matched - { - get { return GetString("DatabaseErrorPage_Matched"); } - } - - /// - /// Entity Framework recorded that the current exception was due to a failed database operation. Attempting to show database error page. - /// - internal static string FormatDatabaseErrorPage_Matched() - { - return GetString("DatabaseErrorPage_Matched"); - } + => GetString("DatabaseErrorPage_Title"); /// /// Entity Framework did not record any exceptions due to failed database operations. This means the current exception is not a failed Entity Framework database operation, or the current exception occurred from a DbContext that was not obtained from request services. /// internal static string DatabaseErrorPage_NoRecordedException { - get { return GetString("DatabaseErrorPage_NoRecordedException"); } + get => GetString("DatabaseErrorPage_NoRecordedException"); } /// /// Entity Framework did not record any exceptions due to failed database operations. This means the current exception is not a failed Entity Framework database operation, or the current exception occurred from a DbContext that was not obtained from request services. /// internal static string FormatDatabaseErrorPage_NoRecordedException() - { - return GetString("DatabaseErrorPage_NoRecordedException"); - } - - /// - /// The target data store is not a relational database. Skipping the database error page. - /// - internal static string DatabaseErrorPage_NotRelationalDatabase - { - get { return GetString("DatabaseErrorPage_NotRelationalDatabase"); } - } - - /// - /// The target data store is not a relational database. Skipping the database error page. - /// - internal static string FormatDatabaseErrorPage_NotRelationalDatabase() - { - return GetString("DatabaseErrorPage_NotRelationalDatabase"); - } - - /// - /// The current exception (and its inner exceptions) do not match the last exception Entity Framework recorded due to a failed database operation. This means the database operation exception was handled and another exception occurred later in the request. - /// - internal static string DatabaseErrorPage_NoMatch - { - get { return GetString("DatabaseErrorPage_NoMatch"); } - } - - /// - /// The current exception (and its inner exceptions) do not match the last exception Entity Framework recorded due to a failed database operation. This means the database operation exception was handled and another exception occurred later in the request. - /// - internal static string FormatDatabaseErrorPage_NoMatch() - { - return GetString("DatabaseErrorPage_NoMatch"); - } + => GetString("DatabaseErrorPage_NoRecordedException"); /// /// PM> Add-Migration [migration name] /// internal static string DatabaseErrorPage_AddMigrationCommandPMC { - get { return GetString("DatabaseErrorPage_AddMigrationCommandPMC"); } + get => GetString("DatabaseErrorPage_AddMigrationCommandPMC"); } /// /// PM> Add-Migration [migration name] /// internal static string FormatDatabaseErrorPage_AddMigrationCommandPMC() - { - return GetString("DatabaseErrorPage_AddMigrationCommandPMC"); - } + => GetString("DatabaseErrorPage_AddMigrationCommandPMC"); /// /// PM> Update-Database /// internal static string DatabaseErrorPage_ApplyMigrationsCommandPMC { - get { return GetString("DatabaseErrorPage_ApplyMigrationsCommandPMC"); } + get => GetString("DatabaseErrorPage_ApplyMigrationsCommandPMC"); } /// /// PM> Update-Database /// internal static string FormatDatabaseErrorPage_ApplyMigrationsCommandPMC() - { - return GetString("DatabaseErrorPage_ApplyMigrationsCommandPMC"); - } + => GetString("DatabaseErrorPage_ApplyMigrationsCommandPMC"); /// /// Alternatively, you can scaffold a new migration and apply it from a command prompt at your project directory: /// internal static string DatabaseErrorPage_NoDbOrMigrationsInfoCLI { - get { return GetString("DatabaseErrorPage_NoDbOrMigrationsInfoCLI"); } + get => GetString("DatabaseErrorPage_NoDbOrMigrationsInfoCLI"); } /// /// Alternatively, you can scaffold a new migration and apply it from a command prompt at your project directory: /// internal static string FormatDatabaseErrorPage_NoDbOrMigrationsInfoCLI() - { - return GetString("DatabaseErrorPage_NoDbOrMigrationsInfoCLI"); - } + => GetString("DatabaseErrorPage_NoDbOrMigrationsInfoCLI"); /// /// Alternatively, you can scaffold a new migration and apply it from a command prompt at your project directory: /// internal static string DatabaseErrorPage_PendingChangesInfoCLI { - get { return GetString("DatabaseErrorPage_PendingChangesInfoCLI"); } + get => GetString("DatabaseErrorPage_PendingChangesInfoCLI"); } /// /// Alternatively, you can scaffold a new migration and apply it from a command prompt at your project directory: /// internal static string FormatDatabaseErrorPage_PendingChangesInfoCLI() - { - return GetString("DatabaseErrorPage_PendingChangesInfoCLI"); - } + => GetString("DatabaseErrorPage_PendingChangesInfoCLI"); /// /// Alternatively, you can apply pending migrations from a command prompt at your project directory: /// internal static string DatabaseErrorPage_HowToApplyFromCLI { - get { return GetString("DatabaseErrorPage_HowToApplyFromCLI"); } + get => GetString("DatabaseErrorPage_HowToApplyFromCLI"); } /// /// Alternatively, you can apply pending migrations from a command prompt at your project directory: /// internal static string FormatDatabaseErrorPage_HowToApplyFromCLI() - { - return GetString("DatabaseErrorPage_HowToApplyFromCLI"); - } + => GetString("DatabaseErrorPage_HowToApplyFromCLI"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Strings.resx b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Strings.resx index 57dc98c9c4..3f987c8716 100644 --- a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Strings.resx +++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Strings.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - The context type '{0}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<{0}>() inside the UseServices(...) call in your application startup code. Skipping display of the database error page. + The context type '{0}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<>() inside the UseServices(...) call in your application startup code. Skipping display of the database error page. An exception occurred while calculating the database error page content. Skipping display of the database error page. @@ -165,12 +165,6 @@ > dotnet ef database update - - Migrations successfully applied for context '{0}'. - - - Request is valid, applying migrations for context '{0}'. - The context type '{0}' was not found in services. This usually means the context was not registered in services during startup. You probably want to call AddScoped<{0}>() inside the UseServices(...) call in your application startup code. @@ -183,27 +177,12 @@ No context type was specified. Ensure the form data from the request includes a contextTypeName value, specifying the context to apply migrations for. - - Request path matched the path configured for this migrations endpoint ({0}). Attempting to process the migrations request. - A database operation failed while processing the request. - - {0} occurred, checking if Entity Framework recorded this exception as resulting from a failed database operation. - - - Entity Framework recorded that the current exception was due to a failed database operation. Attempting to show database error page. - Entity Framework did not record any exceptions due to failed database operations. This means the current exception is not a failed Entity Framework database operation, or the current exception occurred from a DbContext that was not obtained from request services. - - The target data store is not a relational database. Skipping the database error page. - - - The current exception (and its inner exceptions) do not match the last exception Entity Framework recorded due to a failed database operation. This means the database operation exception was handled and another exception occurred later in the request. - PM> Add-Migration [migration name] diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs index 07dab33fcf..c58c53ce8b 100644 --- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs +++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs @@ -4,9 +4,9 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Diagnostics.Internal; using Microsoft.AspNetCore.Diagnostics.RazorViews; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Diagnostics IOptions options, ILoggerFactory loggerFactory, IHostingEnvironment hostingEnvironment, - System.Diagnostics.DiagnosticSource diagnosticSource) + DiagnosticSource diagnosticSource) { if (next == null) { @@ -75,11 +75,11 @@ namespace Microsoft.AspNetCore.Diagnostics } catch (Exception ex) { - _logger.LogError(0, ex, "An unhandled exception has occurred while executing the request"); + _logger.UnhandledException(ex); if (context.Response.HasStarted) { - _logger.LogWarning("The response has already started, the error page middleware will not be executed."); + _logger.ResponseStartedErrorPageMiddleware(); throw; } @@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Diagnostics catch (Exception ex2) { // If there's a Exception while generating the error page, re-throw the original exception. - _logger.LogError(0, ex2, "An exception was thrown attempting to display the error page."); + _logger.DisplayErrorPageException(ex2); } throw; } diff --git a/src/Microsoft.AspNetCore.Diagnostics/ExceptionHandler/ExceptionHandlerMiddleware.cs b/src/Microsoft.AspNetCore.Diagnostics/ExceptionHandler/ExceptionHandlerMiddleware.cs index 4cca406320..49e8b0a981 100644 --- a/src/Microsoft.AspNetCore.Diagnostics/ExceptionHandler/ExceptionHandlerMiddleware.cs +++ b/src/Microsoft.AspNetCore.Diagnostics/ExceptionHandler/ExceptionHandlerMiddleware.cs @@ -5,6 +5,7 @@ using System; using System.Diagnostics; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Diagnostics.Internal; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -45,11 +46,11 @@ namespace Microsoft.AspNetCore.Diagnostics } catch (Exception ex) { - _logger.LogError(0, ex, "An unhandled exception has occurred: " + ex.Message); + _logger.UnhandledException(ex); // We can't do anything if the response has already started, just abort. if (context.Response.HasStarted) { - _logger.LogWarning("The response has already started, the error handler will not be executed."); + _logger.ResponseStartedErrorHandler(); throw; } @@ -84,7 +85,7 @@ namespace Microsoft.AspNetCore.Diagnostics catch (Exception ex2) { // Suppress secondary exceptions, re-throw the original. - _logger.LogError(0, ex2, "An exception was thrown attempting to execute the error handler."); + _logger.ErrorHandlerException(ex2); } finally { diff --git a/src/Microsoft.AspNetCore.Diagnostics/Internal/DiagnosticsLoggerExtensions.cs b/src/Microsoft.AspNetCore.Diagnostics/Internal/DiagnosticsLoggerExtensions.cs new file mode 100644 index 0000000000..347cc622b1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Diagnostics/Internal/DiagnosticsLoggerExtensions.cs @@ -0,0 +1,54 @@ +// 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 Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.Diagnostics.Internal +{ + internal static class DiagnosticsLoggerExtensions + { + // ExceptionHandlerMiddleware & DeveloperExceptionPageMiddleware + private static readonly Action _unhandledException = + LoggerMessage.Define(LogLevel.Error, new EventId(1, "UnhandledException"), "An unhandled exception has occurred while executing the request."); + + // ExceptionHandlerMiddleware + private static readonly Action _responseStartedErrorHandler = + LoggerMessage.Define(LogLevel.Warning, new EventId(2, "ResponseStarted"), "The response has already started, the error handler will not be executed."); + + private static readonly Action _errorHandlerException = + LoggerMessage.Define(LogLevel.Error, new EventId(3, "Exception"), "An exception was thrown attempting to execute the error handler."); + + // DeveloperExceptionPageMiddleware + private static readonly Action _responseStartedErrorPageMiddleware = + LoggerMessage.Define(LogLevel.Warning, new EventId(2, "ResponseStarted"), "The response has already started, the error page middleware will not be executed."); + + private static readonly Action _displayErrorPageException = + LoggerMessage.Define(LogLevel.Error, new EventId(3, "DisplayErrorPageException"), "An exception was thrown attempting to display the error page."); + + public static void UnhandledException(this ILogger logger, Exception exception) + { + _unhandledException(logger, exception); + } + + public static void ResponseStartedErrorHandler(this ILogger logger) + { + _responseStartedErrorHandler(logger, null); + } + + public static void ErrorHandlerException(this ILogger logger, Exception exception) + { + _errorHandlerException(logger, exception); + } + + public static void ResponseStartedErrorPageMiddleware(this ILogger logger) + { + _responseStartedErrorPageMiddleware(logger, null); + } + + public static void DisplayErrorPageException(this ILogger logger, Exception exception) + { + _displayErrorPageException(logger, exception); + } + } +} diff --git a/src/Microsoft.AspNetCore.Diagnostics/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Diagnostics/Properties/Resources.Designer.cs index 417c86659b..ae107bc3cf 100644 --- a/src/Microsoft.AspNetCore.Diagnostics/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Diagnostics/Properties/Resources.Designer.cs @@ -15,656 +15,574 @@ namespace Microsoft.AspNetCore.Diagnostics /// internal static string DiagnosticsPageHtml_Information { - get { return GetString("DiagnosticsPageHtml_Information"); } + get => GetString("DiagnosticsPageHtml_Information"); } /// /// You are seeing this page because DiagnosticsPageMiddleware was added to your web application. /// internal static string FormatDiagnosticsPageHtml_Information() - { - return GetString("DiagnosticsPageHtml_Information"); - } + => GetString("DiagnosticsPageHtml_Information"); /// /// Test Error Message /// internal static string DiagnosticsPageHtml_TestErrorMessage { - get { return GetString("DiagnosticsPageHtml_TestErrorMessage"); } + get => GetString("DiagnosticsPageHtml_TestErrorMessage"); } /// /// Test Error Message /// internal static string FormatDiagnosticsPageHtml_TestErrorMessage() - { - return GetString("DiagnosticsPageHtml_TestErrorMessage"); - } + => GetString("DiagnosticsPageHtml_TestErrorMessage"); /// /// Test Error Page /// internal static string DiagnosticsPageHtml_TestErrorSection { - get { return GetString("DiagnosticsPageHtml_TestErrorSection"); } + get => GetString("DiagnosticsPageHtml_TestErrorSection"); } /// /// Test Error Page /// internal static string FormatDiagnosticsPageHtml_TestErrorSection() - { - return GetString("DiagnosticsPageHtml_TestErrorSection"); - } + => GetString("DiagnosticsPageHtml_TestErrorSection"); /// /// Diagnostics Page /// internal static string DiagnosticsPageHtml_Title { - get { return GetString("DiagnosticsPageHtml_Title"); } + get => GetString("DiagnosticsPageHtml_Title"); } /// /// Diagnostics Page /// internal static string FormatDiagnosticsPageHtml_Title() - { - return GetString("DiagnosticsPageHtml_Title"); - } + => GetString("DiagnosticsPageHtml_Title"); /// /// Cookies /// internal static string ErrorPageHtml_CookiesButton { - get { return GetString("ErrorPageHtml_CookiesButton"); } + get => GetString("ErrorPageHtml_CookiesButton"); } /// /// Cookies /// internal static string FormatErrorPageHtml_CookiesButton() - { - return GetString("ErrorPageHtml_CookiesButton"); - } + => GetString("ErrorPageHtml_CookiesButton"); /// /// Headers /// internal static string ErrorPageHtml_HeadersButton { - get { return GetString("ErrorPageHtml_HeadersButton"); } + get => GetString("ErrorPageHtml_HeadersButton"); } /// /// Headers /// internal static string FormatErrorPageHtml_HeadersButton() - { - return GetString("ErrorPageHtml_HeadersButton"); - } + => GetString("ErrorPageHtml_HeadersButton"); /// /// No cookie data. /// internal static string ErrorPageHtml_NoCookieData { - get { return GetString("ErrorPageHtml_NoCookieData"); } + get => GetString("ErrorPageHtml_NoCookieData"); } /// /// No cookie data. /// internal static string FormatErrorPageHtml_NoCookieData() - { - return GetString("ErrorPageHtml_NoCookieData"); - } + => GetString("ErrorPageHtml_NoCookieData"); /// /// No header data. /// internal static string ErrorPageHtml_NoHeaderData { - get { return GetString("ErrorPageHtml_NoHeaderData"); } + get => GetString("ErrorPageHtml_NoHeaderData"); } /// /// No header data. /// internal static string FormatErrorPageHtml_NoHeaderData() - { - return GetString("ErrorPageHtml_NoHeaderData"); - } + => GetString("ErrorPageHtml_NoHeaderData"); /// /// No QueryString data. /// internal static string ErrorPageHtml_NoQueryStringData { - get { return GetString("ErrorPageHtml_NoQueryStringData"); } + get => GetString("ErrorPageHtml_NoQueryStringData"); } /// /// No QueryString data. /// internal static string FormatErrorPageHtml_NoQueryStringData() - { - return GetString("ErrorPageHtml_NoQueryStringData"); - } + => GetString("ErrorPageHtml_NoQueryStringData"); /// /// Query /// internal static string ErrorPageHtml_QueryButton { - get { return GetString("ErrorPageHtml_QueryButton"); } + get => GetString("ErrorPageHtml_QueryButton"); } /// /// Query /// internal static string FormatErrorPageHtml_QueryButton() - { - return GetString("ErrorPageHtml_QueryButton"); - } + => GetString("ErrorPageHtml_QueryButton"); /// /// Stack /// internal static string ErrorPageHtml_StackButton { - get { return GetString("ErrorPageHtml_StackButton"); } + get => GetString("ErrorPageHtml_StackButton"); } /// /// Stack /// internal static string FormatErrorPageHtml_StackButton() - { - return GetString("ErrorPageHtml_StackButton"); - } + => GetString("ErrorPageHtml_StackButton"); /// /// Internal Server Error /// internal static string ErrorPageHtml_Title { - get { return GetString("ErrorPageHtml_Title"); } + get => GetString("ErrorPageHtml_Title"); } /// /// Internal Server Error /// internal static string FormatErrorPageHtml_Title() - { - return GetString("ErrorPageHtml_Title"); - } + => GetString("ErrorPageHtml_Title"); /// /// An unhandled exception occurred while processing the request. /// internal static string ErrorPageHtml_UnhandledException { - get { return GetString("ErrorPageHtml_UnhandledException"); } + get => GetString("ErrorPageHtml_UnhandledException"); } /// /// An unhandled exception occurred while processing the request. /// internal static string FormatErrorPageHtml_UnhandledException() - { - return GetString("ErrorPageHtml_UnhandledException"); - } + => GetString("ErrorPageHtml_UnhandledException"); /// /// Unknown location /// internal static string ErrorPageHtml_UnknownLocation { - get { return GetString("ErrorPageHtml_UnknownLocation"); } + get => GetString("ErrorPageHtml_UnknownLocation"); } /// /// Unknown location /// internal static string FormatErrorPageHtml_UnknownLocation() - { - return GetString("ErrorPageHtml_UnknownLocation"); - } + => GetString("ErrorPageHtml_UnknownLocation"); /// /// Value /// internal static string ErrorPageHtml_ValueColumn { - get { return GetString("ErrorPageHtml_ValueColumn"); } + get => GetString("ErrorPageHtml_ValueColumn"); } /// /// Value /// internal static string FormatErrorPageHtml_ValueColumn() - { - return GetString("ErrorPageHtml_ValueColumn"); - } + => GetString("ErrorPageHtml_ValueColumn"); /// /// Variable /// internal static string ErrorPageHtml_VariableColumn { - get { return GetString("ErrorPageHtml_VariableColumn"); } + get => GetString("ErrorPageHtml_VariableColumn"); } /// /// Variable /// internal static string FormatErrorPageHtml_VariableColumn() - { - return GetString("ErrorPageHtml_VariableColumn"); - } + => GetString("ErrorPageHtml_VariableColumn"); /// /// The path must start with a '/'. /// internal static string Exception_PathMustStartWithSlash { - get { return GetString("Exception_PathMustStartWithSlash"); } + get => GetString("Exception_PathMustStartWithSlash"); } /// /// The path must start with a '/'. /// internal static string FormatException_PathMustStartWithSlash() - { - return GetString("Exception_PathMustStartWithSlash"); - } + => GetString("Exception_PathMustStartWithSlash"); /// /// Name /// internal static string RuntimeInfoPage_PackageNameColumnName { - get { return GetString("RuntimeInfoPage_PackageNameColumnName"); } + get => GetString("RuntimeInfoPage_PackageNameColumnName"); } /// /// Name /// internal static string FormatRuntimeInfoPage_PackageNameColumnName() - { - return GetString("RuntimeInfoPage_PackageNameColumnName"); - } + => GetString("RuntimeInfoPage_PackageNameColumnName"); /// /// Path /// internal static string RuntimeInfoPage_PackagePathColumnName { - get { return GetString("RuntimeInfoPage_PackagePathColumnName"); } + get => GetString("RuntimeInfoPage_PackagePathColumnName"); } /// /// Path /// internal static string FormatRuntimeInfoPage_PackagePathColumnName() - { - return GetString("RuntimeInfoPage_PackagePathColumnName"); - } + => GetString("RuntimeInfoPage_PackagePathColumnName"); /// /// Packages: /// internal static string RuntimeInfoPage_Packages { - get { return GetString("RuntimeInfoPage_Packages"); } + get => GetString("RuntimeInfoPage_Packages"); } /// /// Packages: /// internal static string FormatRuntimeInfoPage_Packages() - { - return GetString("RuntimeInfoPage_Packages"); - } + => GetString("RuntimeInfoPage_Packages"); /// /// Could not retrieve the list of loaded packages. /// internal static string RuntimeInfoPage_PackagesFail { - get { return GetString("RuntimeInfoPage_PackagesFail"); } + get => GetString("RuntimeInfoPage_PackagesFail"); } /// /// Could not retrieve the list of loaded packages. /// internal static string FormatRuntimeInfoPage_PackagesFail() - { - return GetString("RuntimeInfoPage_PackagesFail"); - } + => GetString("RuntimeInfoPage_PackagesFail"); /// /// Version /// internal static string RuntimeInfoPage_PackageVersionColumnName { - get { return GetString("RuntimeInfoPage_PackageVersionColumnName"); } + get => GetString("RuntimeInfoPage_PackageVersionColumnName"); } /// /// Version /// internal static string FormatRuntimeInfoPage_PackageVersionColumnName() - { - return GetString("RuntimeInfoPage_PackageVersionColumnName"); - } + => GetString("RuntimeInfoPage_PackageVersionColumnName"); /// /// Runtime Version: /// internal static string RuntimeInfoPage_RuntimeVersion { - get { return GetString("RuntimeInfoPage_RuntimeVersion"); } + get => GetString("RuntimeInfoPage_RuntimeVersion"); } /// /// Runtime Version: /// internal static string FormatRuntimeInfoPage_RuntimeVersion() - { - return GetString("RuntimeInfoPage_RuntimeVersion"); - } + => GetString("RuntimeInfoPage_RuntimeVersion"); /// /// Could not determine the runtime version. /// internal static string RuntimeInfoPage_RuntimeVersionFail { - get { return GetString("RuntimeInfoPage_RuntimeVersionFail"); } + get => GetString("RuntimeInfoPage_RuntimeVersionFail"); } /// /// Could not determine the runtime version. /// internal static string FormatRuntimeInfoPage_RuntimeVersionFail() - { - return GetString("RuntimeInfoPage_RuntimeVersionFail"); - } + => GetString("RuntimeInfoPage_RuntimeVersionFail"); /// /// Runtime Information /// internal static string RuntimeInfoPage_Title { - get { return GetString("RuntimeInfoPage_Title"); } + get => GetString("RuntimeInfoPage_Title"); } /// /// Runtime Information /// internal static string FormatRuntimeInfoPage_Title() - { - return GetString("RuntimeInfoPage_Title"); - } + => GetString("RuntimeInfoPage_Title"); /// /// Welcome /// internal static string WelcomeHeader { - get { return GetString("WelcomeHeader"); } + get => GetString("WelcomeHeader"); } /// /// Welcome /// internal static string FormatWelcomeHeader() - { - return GetString("WelcomeHeader"); - } + => GetString("WelcomeHeader"); /// /// Learn more about the Microsoft ASP.NET Core components /// internal static string WelcomeLearnMicrosoftAspNet { - get { return GetString("WelcomeLearnMicrosoftAspNet"); } + get => GetString("WelcomeLearnMicrosoftAspNet"); } /// /// Learn more about the Microsoft ASP.NET Core components /// internal static string FormatWelcomeLearnMicrosoftAspNet() - { - return GetString("WelcomeLearnMicrosoftAspNet"); - } + => GetString("WelcomeLearnMicrosoftAspNet"); /// /// Browser /// internal static string WelcomePageImageText_Browser { - get { return GetString("WelcomePageImageText_Browser"); } + get => GetString("WelcomePageImageText_Browser"); } /// /// Browser /// internal static string FormatWelcomePageImageText_Browser() - { - return GetString("WelcomePageImageText_Browser"); - } + => GetString("WelcomePageImageText_Browser"); /// /// Learn More /// internal static string WelcomePageImageText_LearnMore { - get { return GetString("WelcomePageImageText_LearnMore"); } + get => GetString("WelcomePageImageText_LearnMore"); } /// /// Learn More /// internal static string FormatWelcomePageImageText_LearnMore() - { - return GetString("WelcomePageImageText_LearnMore"); - } + => GetString("WelcomePageImageText_LearnMore"); /// /// Light Bulb /// internal static string WelcomePageImageText_LightBulb { - get { return GetString("WelcomePageImageText_LightBulb"); } + get => GetString("WelcomePageImageText_LightBulb"); } /// /// Light Bulb /// internal static string FormatWelcomePageImageText_LightBulb() - { - return GetString("WelcomePageImageText_LightBulb"); - } + => GetString("WelcomePageImageText_LightBulb"); /// /// Skyline /// internal static string WelcomePageImageText_Skyline { - get { return GetString("WelcomePageImageText_Skyline"); } + get => GetString("WelcomePageImageText_Skyline"); } /// /// Skyline /// internal static string FormatWelcomePageImageText_Skyline() - { - return GetString("WelcomePageImageText_Skyline"); - } + => GetString("WelcomePageImageText_Skyline"); /// /// Your ASP.NET Core application has been successfully started /// internal static string WelcomeStarted { - get { return GetString("WelcomeStarted"); } + get => GetString("WelcomeStarted"); } /// /// Your ASP.NET Core application has been successfully started /// internal static string FormatWelcomeStarted() - { - return GetString("WelcomeStarted"); - } + => GetString("WelcomeStarted"); /// /// Your ASP.NET Core application has been successfully started. /// internal static string WelcomeTitle { - get { return GetString("WelcomeTitle"); } + get => GetString("WelcomeTitle"); } /// /// Your ASP.NET Core application has been successfully started. /// internal static string FormatWelcomeTitle() - { - return GetString("WelcomeTitle"); - } + => GetString("WelcomeTitle"); /// /// An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately. /// internal static string ErrorPageHtml_CompilationException { - get { return GetString("ErrorPageHtml_CompilationException"); } + get => GetString("ErrorPageHtml_CompilationException"); } /// /// An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately. /// internal static string FormatErrorPageHtml_CompilationException() - { - return GetString("ErrorPageHtml_CompilationException"); - } + => GetString("ErrorPageHtml_CompilationException"); /// /// Operating System: /// internal static string RuntimeInfoPage_OperatingSystem { - get { return GetString("RuntimeInfoPage_OperatingSystem"); } + get => GetString("RuntimeInfoPage_OperatingSystem"); } /// /// Operating System: /// internal static string FormatRuntimeInfoPage_OperatingSystem() - { - return GetString("RuntimeInfoPage_OperatingSystem"); - } + => GetString("RuntimeInfoPage_OperatingSystem"); /// /// Runtime Architecture: /// internal static string RuntimeInfoPage_RuntimeArchitecture { - get { return GetString("RuntimeInfoPage_RuntimeArchitecture"); } + get => GetString("RuntimeInfoPage_RuntimeArchitecture"); } /// /// Runtime Architecture: /// internal static string FormatRuntimeInfoPage_RuntimeArchitecture() - { - return GetString("RuntimeInfoPage_RuntimeArchitecture"); - } + => GetString("RuntimeInfoPage_RuntimeArchitecture"); /// /// Runtime Type: /// internal static string RuntimeInfoPage_RuntimeType { - get { return GetString("RuntimeInfoPage_RuntimeType"); } + get => GetString("RuntimeInfoPage_RuntimeType"); } /// /// Runtime Type: /// internal static string FormatRuntimeInfoPage_RuntimeType() - { - return GetString("RuntimeInfoPage_RuntimeType"); - } + => GetString("RuntimeInfoPage_RuntimeType"); /// /// Could not determine the operating system. /// internal static string RuntimeInfoPage_OperatingSystemFail { - get { return GetString("RuntimeInfoPage_OperatingSystemFail"); } + get => GetString("RuntimeInfoPage_OperatingSystemFail"); } /// /// Could not determine the operating system. /// internal static string FormatRuntimeInfoPage_OperatingSystemFail() - { - return GetString("RuntimeInfoPage_OperatingSystemFail"); - } + => GetString("RuntimeInfoPage_OperatingSystemFail"); /// /// Could not determine the runtime architecture. /// internal static string RuntimeInfoPage_RuntimeArchitectureFail { - get { return GetString("RuntimeInfoPage_RuntimeArchitectureFail"); } + get => GetString("RuntimeInfoPage_RuntimeArchitectureFail"); } /// /// Could not determine the runtime architecture. /// internal static string FormatRuntimeInfoPage_RuntimeArchitectureFail() - { - return GetString("RuntimeInfoPage_RuntimeArchitectureFail"); - } + => GetString("RuntimeInfoPage_RuntimeArchitectureFail"); /// /// Could not determine the runtime type. /// internal static string RuntimeInfoPage_RuntimeTypeFail { - get { return GetString("RuntimeInfoPage_RuntimeTypeFail"); } + get => GetString("RuntimeInfoPage_RuntimeTypeFail"); } /// /// Could not determine the runtime type. /// internal static string FormatRuntimeInfoPage_RuntimeTypeFail() - { - return GetString("RuntimeInfoPage_RuntimeTypeFail"); - } + => GetString("RuntimeInfoPage_RuntimeTypeFail"); /// /// Environment: /// internal static string RuntimeInfoPage_Environment { - get { return GetString("RuntimeInfoPage_Environment"); } + get => GetString("RuntimeInfoPage_Environment"); } /// /// Environment: /// internal static string FormatRuntimeInfoPage_Environment() - { - return GetString("RuntimeInfoPage_Environment"); - } + => GetString("RuntimeInfoPage_Environment"); private static string GetString(string name, params string[] formatterNames) { diff --git a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests.csproj b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests.csproj index e265c2fbe5..54182bca8e 100644 --- a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests.csproj +++ b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests.csproj @@ -18,4 +18,8 @@ + + + + diff --git a/test/Microsoft.AspNetCore.Diagnostics.Tests/Microsoft.AspNetCore.Diagnostics.Tests.csproj b/test/Microsoft.AspNetCore.Diagnostics.Tests/Microsoft.AspNetCore.Diagnostics.Tests.csproj index 86fb30f123..c4dc55d9d9 100644 --- a/test/Microsoft.AspNetCore.Diagnostics.Tests/Microsoft.AspNetCore.Diagnostics.Tests.csproj +++ b/test/Microsoft.AspNetCore.Diagnostics.Tests/Microsoft.AspNetCore.Diagnostics.Tests.csproj @@ -28,4 +28,8 @@ + + + +