diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ContentResult.cs b/src/Microsoft.AspNetCore.Mvc.Core/ContentResult.cs index f5394defc6..55315f695c 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ContentResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ContentResult.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Mvc.Internal; -using Microsoft.AspNetCore.Mvc.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Net.Http.Headers; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/FileResult.cs b/src/Microsoft.AspNetCore.Mvc.Core/FileResult.cs index 74d9ef329b..a428f5f50c 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/FileResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/FileResult.cs @@ -4,10 +4,9 @@ using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc.Logging; +using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Mvc diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ForbidResult.cs b/src/Microsoft.AspNetCore.Mvc.Core/ForbidResult.cs index c697f50f38..37b86e3e42 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ForbidResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ForbidResult.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Mvc.Logging; +using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/HttpStatusCodeResult.cs b/src/Microsoft.AspNetCore.Mvc.Core/HttpStatusCodeResult.cs index 81b1de3b0e..b47140cd55 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/HttpStatusCodeResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/HttpStatusCodeResult.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Mvc.Logging; +using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ActionSelector.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ActionSelector.cs index bd9f6eb053..c6a6685399 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ActionSelector.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ActionSelector.cs @@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.ActionConstraints; using Microsoft.AspNetCore.Mvc.Core; using Microsoft.AspNetCore.Mvc.Infrastructure; -using Microsoft.AspNetCore.Mvc.Logging; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Logging; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvoker.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvoker.cs index 806e2929d5..bf5b418002 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvoker.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvoker.cs @@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Core; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Formatters; -using Microsoft.AspNetCore.Mvc.Logging; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; using Microsoft.Extensions.Internal; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/FilterActionInvoker.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/FilterActionInvoker.cs index 4754d8556b..3798cd8498 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/FilterActionInvoker.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/FilterActionInvoker.cs @@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.Core; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Formatters; -using Microsoft.AspNetCore.Mvc.Logging; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; using Microsoft.Extensions.Logging; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcCoreLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcCoreLoggerExtensions.cs index 98970281cf..80b2a3f688 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcCoreLoggerExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcCoreLoggerExtensions.cs @@ -6,6 +6,11 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using Microsoft.AspNetCore.Mvc.Abstractions; +using Microsoft.AspNetCore.Mvc.ActionConstraints; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.Formatters; +using Microsoft.AspNetCore.Mvc.Formatters.Internal; +using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Mvc.Internal @@ -21,6 +26,38 @@ namespace Microsoft.AspNetCore.Mvc.Internal private static readonly Action _contentResultExecuting; + private static readonly Action _actionMethodExecuting; + private static readonly Action _actionMethodExecuted; + + private static readonly Action _ambiguousActions; + private static readonly Action _constraintMismatch; + + private static readonly Action _fileResultExecuting; + + private static readonly Action _authorizationFailure; + private static readonly Action _resourceFilterShortCircuit; + private static readonly Action _actionFilterShortCircuit; + private static readonly Action _exceptionFilterShortCircuit; + + private static readonly Action _resultExecuting; + + private static readonly Action _httpStatusCodeResultExecuting; + + private static readonly Action _localRedirectResultExecuting; + + private static readonly Action _objectResultExecuting; + private static readonly Action _noFormatter; + private static readonly Action _formatterSelected; + private static readonly Action _skippedContentNegotiation; + private static readonly Action _noAcceptForNegotiation; + private static readonly Action, Exception> _noFormatterFromNegotiation; + + private static readonly Action _redirectResultExecuting; + + private static readonly Action _redirectToActionResultExecuting; + + private static readonly Action _redirectToRouteResultExecuting; + static MvcCoreLoggerExtensions() { _actionExecuting = LoggerMessage.Define( @@ -42,6 +79,111 @@ namespace Microsoft.AspNetCore.Mvc.Internal LogLevel.Information, 1, "Executing ContentResult with HTTP Response ContentType of {ContentType}"); + + _actionMethodExecuting = LoggerMessage.Define( + LogLevel.Information, + 1, + "Executing action method {ActionName} with arguments ({Arguments}) - ModelState is {ValidationState}'"); + + _actionMethodExecuted = LoggerMessage.Define( + LogLevel.Debug, + 2, + "Executed action method {ActionName}, returned result {ActionResult}.'"); + + _ambiguousActions = LoggerMessage.Define( + LogLevel.Error, + 1, + "Request matched multiple actions resulting in ambiguity. Matching actions: {AmbiguousActions}"); + + _constraintMismatch = LoggerMessage.Define( + LogLevel.Debug, + 2, + "Action '{ActionName}' with id '{ActionId}' did not match the constraint '{ActionConstraint}'"); + + _fileResultExecuting = LoggerMessage.Define( + LogLevel.Information, + 1, + "Executing FileResult, sending file as {FileDownloadName}"); + + _authorizationFailure = LoggerMessage.Define( + LogLevel.Warning, + 1, + "Authorization failed for the request at filter '{AuthorizationFilter}'."); + + _resourceFilterShortCircuit = LoggerMessage.Define( + LogLevel.Debug, + 2, + "Request was short circuited at resource filter '{ResourceFilter}'."); + + _actionFilterShortCircuit = LoggerMessage.Define( + LogLevel.Debug, + 3, + "Request was short circuited at action filter '{ActionFilter}'."); + + _exceptionFilterShortCircuit = LoggerMessage.Define( + LogLevel.Debug, + 4, + "Request was short circuited at exception filter '{ExceptionFilter}'."); + + _resultExecuting = LoggerMessage.Define( + LogLevel.Information, + eventId: 1, + formatString: $"Executing {nameof(ForbidResult)} with authentication schemes ({{Schemes}})."); + + _httpStatusCodeResultExecuting = LoggerMessage.Define( + LogLevel.Information, + 1, + "Executing HttpStatusCodeResult, setting HTTP status code {StatusCode}"); + + _localRedirectResultExecuting = LoggerMessage.Define( + LogLevel.Information, + 1, + "Executing LocalRedirectResult, redirecting to {Destination}."); + + _noFormatter = LoggerMessage.Define( + LogLevel.Warning, + 1, + "No output formatter was found for content type '{ContentType}' to write the response."); + + _objectResultExecuting = LoggerMessage.Define( + LogLevel.Information, + 1, + "Executing ObjectResult, writing value {Value}."); + + _formatterSelected = LoggerMessage.Define( + LogLevel.Debug, + 2, + "Selected output formatter '{OutputFormatter}' and content type '{ContentType}' to write the response."); + + _skippedContentNegotiation = LoggerMessage.Define( + LogLevel.Debug, + 3, + "Skipped content negotiation as content type '{ContentType}' is explicitly set for the response."); + + _noAcceptForNegotiation = LoggerMessage.Define( + LogLevel.Debug, + 4, + "No information found on request to perform content negotiation."); + + _noFormatterFromNegotiation = LoggerMessage.Define>( + LogLevel.Debug, + 5, + "Could not find an output formatter based on content negotiation. Accepted types were ({AcceptTypes})"); + + _redirectResultExecuting = LoggerMessage.Define( + LogLevel.Information, + 1, + "Executing RedirectResult, redirecting to {Destination}."); + + _redirectToActionResultExecuting = LoggerMessage.Define( + LogLevel.Information, + 1, + "Executing RedirectResult, redirecting to {Destination}."); + + _redirectToRouteResultExecuting = LoggerMessage.Define( + LogLevel.Information, + 1, + "Executing RedirectToRouteResult, redirecting to {Destination} from route {RouteName}."); } public static IDisposable ActionScope(this ILogger logger, ActionDescriptor action) @@ -81,6 +223,151 @@ namespace Microsoft.AspNetCore.Mvc.Internal _contentResultExecuting(logger, contentType, null); } + public static void ActionMethodExecuting(this ILogger logger, ActionExecutingContext context, object[] arguments) + { + if (logger.IsEnabled(LogLevel.Information)) + { + var actionName = context.ActionDescriptor.DisplayName; + + string[] convertedArguments; + if (arguments == null) + { + convertedArguments = null; + } + else + { + convertedArguments = new string[arguments.Length]; + for (var i = 0; i < arguments.Length; i++) + { + convertedArguments[i] = Convert.ToString(arguments[i]); + } + } + + var validationState = context.ModelState.ValidationState; + + _actionMethodExecuting(logger, actionName, convertedArguments, validationState, null); + } + } + + public static void ActionMethodExecuted(this ILogger logger, ActionExecutingContext context, IActionResult result) + { + var actionName = context.ActionDescriptor.DisplayName; + _actionMethodExecuted(logger, actionName, Convert.ToString(result), null); + } + + public static void AmbiguousActions(this ILogger logger, string actionNames) + { + _ambiguousActions(logger, actionNames, null); + } + + public static void ConstraintMismatch( + this ILogger logger, + string actionName, + string actionId, + IActionConstraint actionConstraint) + { + _constraintMismatch(logger, actionName, actionId, actionConstraint, null); + } + + public static void FileResultExecuting(this ILogger logger, string fileDownloadName) + { + _fileResultExecuting(logger, fileDownloadName, null); + } + + public static void AuthorizationFailure( + this ILogger logger, + IFilterMetadata filter) + { + _authorizationFailure(logger, filter, null); + } + + public static void ResourceFilterShortCircuited( + this ILogger logger, + IFilterMetadata filter) + { + _resourceFilterShortCircuit(logger, filter, null); + } + + public static void ExceptionFilterShortCircuited( + this ILogger logger, + IFilterMetadata filter) + { + _exceptionFilterShortCircuit(logger, filter, null); + } + + public static void ActionFilterShortCircuited( + this ILogger logger, + IFilterMetadata filter) + { + _actionFilterShortCircuit(logger, filter, null); + } + + public static void ForbidResultExecuting(this ILogger logger, IList authenticationSchemes) + { + _resultExecuting(logger, authenticationSchemes.ToArray(), null); + } + + public static void HttpStatusCodeResultExecuting(this ILogger logger, int statusCode) + { + _httpStatusCodeResultExecuting(logger, statusCode, null); + } + + public static void LocalRedirectResultExecuting(this ILogger logger, string destination) + { + _localRedirectResultExecuting(logger, destination, null); + } + + public static void ObjectResultExecuting(this ILogger logger, object value) + { + _objectResultExecuting(logger, Convert.ToString(value), null); + } + + public static void NoFormatter( + this ILogger logger, + OutputFormatterWriteContext formatterContext) + { + _noFormatter(logger, Convert.ToString(formatterContext.ContentType), null); + } + + public static void FormatterSelected( + this ILogger logger, + IOutputFormatter outputFormatter, + OutputFormatterWriteContext context) + { + var contentType = Convert.ToString(context.ContentType); + _formatterSelected(logger, outputFormatter, contentType, null); + } + + public static void SkippedContentNegotiation(this ILogger logger, string contentType) + { + _skippedContentNegotiation(logger, contentType, null); + } + + public static void NoAcceptForNegotiation(this ILogger logger) + { + _noAcceptForNegotiation(logger, null, null); + } + + public static void NoFormatterFromNegotiation(this ILogger logger, IList acceptTypes) + { + _noFormatterFromNegotiation(logger, acceptTypes, null); + } + + public static void RedirectResultExecuting(this ILogger logger, string destination) + { + _redirectResultExecuting(logger, destination, null); + } + + public static void RedirectToActionResultExecuting(this ILogger logger, string destination) + { + _redirectToActionResultExecuting(logger, destination, null); + } + + public static void RedirectToRouteResultExecuting(this ILogger logger, string destination, string routeName) + { + _redirectToRouteResultExecuting(logger, destination, routeName, null); + } + private class ActionLogScope : ILogValues { private readonly ActionDescriptor _action; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcRouteHandler.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcRouteHandler.cs index 7acfc7a550..a8b372f860 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcRouteHandler.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcRouteHandler.cs @@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.Core; using Microsoft.AspNetCore.Mvc.Infrastructure; -using Microsoft.AspNetCore.Mvc.Logging; using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Routing.Tree; using Microsoft.Extensions.DependencyInjection; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ObjectResultExecutor.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ObjectResultExecutor.cs index b57b794714..9772f3aa38 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ObjectResultExecutor.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ObjectResultExecutor.cs @@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Core; using Microsoft.AspNetCore.Mvc.Formatters; using Microsoft.AspNetCore.Mvc.Formatters.Internal; -using Microsoft.AspNetCore.Mvc.Logging; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/LocalRedirectResult.cs b/src/Microsoft.AspNetCore.Mvc.Core/LocalRedirectResult.cs index 82002493e9..dbc32011c0 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/LocalRedirectResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/LocalRedirectResult.cs @@ -3,7 +3,7 @@ using System; using Microsoft.AspNetCore.Mvc.Core; -using Microsoft.AspNetCore.Mvc.Logging; +using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.Routing; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Logging/ControllerActionInvokerLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Logging/ControllerActionInvokerLoggerExtensions.cs deleted file mode 100644 index cddfc071f0..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Logging/ControllerActionInvokerLoggerExtensions.cs +++ /dev/null @@ -1,61 +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 Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.AspNetCore.Mvc.ModelBinding; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - internal static class ControllerActionInvokerLoggerExtensions - { - private static readonly Action _actionMethodExecuting; - private static readonly Action _actionMethodExecuted; - - static ControllerActionInvokerLoggerExtensions() - { - _actionMethodExecuting = LoggerMessage.Define( - LogLevel.Information, - 1, - "Executing action method {ActionName} with arguments ({Arguments}) - ModelState is {ValidationState}'"); - - _actionMethodExecuted = LoggerMessage.Define( - LogLevel.Debug, - 2, - "Executed action method {ActionName}, returned result {ActionResult}.'"); - } - - public static void ActionMethodExecuting(this ILogger logger, ActionExecutingContext context, object[] arguments) - { - if (logger.IsEnabled(LogLevel.Information)) - { - var actionName = context.ActionDescriptor.DisplayName; - - string[] convertedArguments; - if (arguments == null) - { - convertedArguments = null; - } - else - { - convertedArguments = new string[arguments.Length]; - for (var i = 0; i < arguments.Length; i++) - { - convertedArguments[i] = Convert.ToString(arguments[i]); - } - } - - var validationState = context.ModelState.ValidationState; - - _actionMethodExecuting(logger, actionName, convertedArguments, validationState, null); - } - } - - public static void ActionMethodExecuted(this ILogger logger, ActionExecutingContext context, IActionResult result) - { - var actionName = context.ActionDescriptor.DisplayName; - _actionMethodExecuted(logger, actionName, Convert.ToString(result), null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Logging/DefaultActionSelectorLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Logging/DefaultActionSelectorLoggerExtensions.cs deleted file mode 100644 index 625640f4a1..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Logging/DefaultActionSelectorLoggerExtensions.cs +++ /dev/null @@ -1,41 +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 Microsoft.AspNetCore.Mvc.ActionConstraints; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - internal static class DefaultActionSelectorLoggerExtensions - { - private static readonly Action _ambiguousActions; - private static readonly Action _constraintMismatch; - - static DefaultActionSelectorLoggerExtensions() - { - _ambiguousActions = LoggerMessage.Define( - LogLevel.Error, - 1, - "Request matched multiple actions resulting in ambiguity. Matching actions: {AmbiguousActions}"); - _constraintMismatch = LoggerMessage.Define( - LogLevel.Debug, - 2, - "Action '{ActionName}' with id '{ActionId}' did not match the constraint '{ActionConstraint}'"); - } - - public static void AmbiguousActions(this ILogger logger, string actionNames) - { - _ambiguousActions(logger, actionNames, null); - } - - public static void ConstraintMismatch( - this ILogger logger, - string actionName, - string actionId, - IActionConstraint actionConstraint) - { - _constraintMismatch(logger, actionName, actionId, actionConstraint, null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Logging/FileResultLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Logging/FileResultLoggerExtensions.cs deleted file mode 100644 index 07b5c735bd..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Logging/FileResultLoggerExtensions.cs +++ /dev/null @@ -1,26 +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 Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - internal static class FileResultLoggerExtensions - { - private static readonly Action _fileResultExecuting; - - static FileResultLoggerExtensions() - { - _fileResultExecuting = LoggerMessage.Define( - LogLevel.Information, - 1, - "Executing FileResult, sending file as {FileDownloadName}"); - } - - public static void FileResultExecuting(this ILogger logger, string fileDownloadName) - { - _fileResultExecuting(logger, fileDownloadName, null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Logging/FilterActionInvokerLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Logging/FilterActionInvokerLoggerExtensions.cs deleted file mode 100644 index 41fd5cb30a..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Logging/FilterActionInvokerLoggerExtensions.cs +++ /dev/null @@ -1,65 +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 Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - internal static class FilterActionInvokerLoggerExtensions - { - private static readonly Action _authorizationFailure; - private static readonly Action _resourceFilterShortCircuit; - private static readonly Action _actionFilterShortCircuit; - private static readonly Action _exceptionFilterShortCircuit; - - static FilterActionInvokerLoggerExtensions() - { - _authorizationFailure = LoggerMessage.Define( - LogLevel.Warning, - 1, - "Authorization failed for the request at filter '{AuthorizationFilter}'."); - _resourceFilterShortCircuit = LoggerMessage.Define( - LogLevel.Debug, - 2, - "Request was short circuited at resource filter '{ResourceFilter}'."); - _actionFilterShortCircuit = LoggerMessage.Define( - LogLevel.Debug, - 3, - "Request was short circuited at action filter '{ActionFilter}'."); - _exceptionFilterShortCircuit = LoggerMessage.Define( - LogLevel.Debug, - 4, - "Request was short circuited at exception filter '{ExceptionFilter}'."); - } - - public static void AuthorizationFailure( - this ILogger logger, - IFilterMetadata filter) - { - _authorizationFailure(logger, filter, null); - } - - public static void ResourceFilterShortCircuited( - this ILogger logger, - IFilterMetadata filter) - { - _resourceFilterShortCircuit(logger, filter, null); - } - - public static void ExceptionFilterShortCircuited( - this ILogger logger, - IFilterMetadata filter) - { - _exceptionFilterShortCircuit(logger, filter, null); - } - - public static void ActionFilterShortCircuited( - this ILogger logger, - IFilterMetadata filter) - { - _actionFilterShortCircuit(logger, filter, null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Logging/ForbidResultLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Logging/ForbidResultLoggerExtensions.cs deleted file mode 100644 index 9d442f9341..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Logging/ForbidResultLoggerExtensions.cs +++ /dev/null @@ -1,24 +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 System.Linq; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - internal static class ForbidResultLoggerExtensions - { - private static readonly Action _resultExecuting = - LoggerMessage.Define( - LogLevel.Information, - eventId: 1, - formatString: $"Executing {nameof(ForbidResult)} with authentication schemes ({{Schemes}})."); - - public static void ForbidResultExecuting(this ILogger logger, IList authenticationSchemes) - { - _resultExecuting(logger, authenticationSchemes.ToArray(), null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Logging/HttpStatusCodeResultLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Logging/HttpStatusCodeResultLoggerExtensions.cs deleted file mode 100644 index 12f2a4de92..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Logging/HttpStatusCodeResultLoggerExtensions.cs +++ /dev/null @@ -1,26 +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 Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - internal static class HttpStatusCodeLoggerExtensions - { - private static readonly Action _httpStatusCodeResultExecuting; - - static HttpStatusCodeLoggerExtensions() - { - _httpStatusCodeResultExecuting = LoggerMessage.Define( - LogLevel.Information, - 1, - "Executing HttpStatusCodeResult, setting HTTP status code {StatusCode}"); - } - - public static void HttpStatusCodeResultExecuting(this ILogger logger, int statusCode) - { - _httpStatusCodeResultExecuting(logger, statusCode, null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Logging/LocalRedirectResultLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Logging/LocalRedirectResultLoggerExtensions.cs deleted file mode 100644 index ddb87a7b48..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Logging/LocalRedirectResultLoggerExtensions.cs +++ /dev/null @@ -1,26 +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 Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - internal static class LocalRedirectResultLoggerExtensions - { - private static readonly Action _localRedirectResultExecuting; - - static LocalRedirectResultLoggerExtensions() - { - _localRedirectResultExecuting = LoggerMessage.Define( - LogLevel.Information, - 1, - "Executing LocalRedirectResult, redirecting to {Destination}."); - } - - public static void LocalRedirectResultExecuting(this ILogger logger, string destination) - { - _localRedirectResultExecuting(logger, destination, null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Logging/ObjectResultExecutorLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Logging/ObjectResultExecutorLoggerExtensions.cs deleted file mode 100644 index aa93f3ff74..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Logging/ObjectResultExecutorLoggerExtensions.cs +++ /dev/null @@ -1,85 +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 Microsoft.AspNetCore.Mvc.Formatters; -using Microsoft.AspNetCore.Mvc.Formatters.Internal; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - internal static class ObjectResultExecutorLoggerExtensions - { - private static readonly Action _objectResultExecuting; - private static readonly Action _noFormatter; - private static readonly Action _formatterSelected; - private static readonly Action _skippedContentNegotiation; - private static readonly Action _noAcceptForNegotiation; - private static readonly Action, Exception> _noFormatterFromNegotiation; - - static ObjectResultExecutorLoggerExtensions() - { - _noFormatter = LoggerMessage.Define( - LogLevel.Warning, - 1, - "No output formatter was found for content type '{ContentType}' to write the response."); - _objectResultExecuting = LoggerMessage.Define( - LogLevel.Information, - 1, - "Executing ObjectResult, writing value {Value}."); - _formatterSelected = LoggerMessage.Define( - LogLevel.Debug, - 2, - "Selected output formatter '{OutputFormatter}' and content type '{ContentType}' to write the response."); - _skippedContentNegotiation = LoggerMessage.Define( - LogLevel.Debug, - 3, - "Skipped content negotiation as content type '{ContentType}' is explicitly set for the response."); - _noAcceptForNegotiation = LoggerMessage.Define( - LogLevel.Debug, - 4, - "No information found on request to perform content negotiation."); - _noFormatterFromNegotiation = LoggerMessage.Define>( - LogLevel.Debug, - 5, - "Could not find an output formatter based on content negotiation. Accepted types were ({AcceptTypes})"); - } - - public static void ObjectResultExecuting(this ILogger logger, object value) - { - _objectResultExecuting(logger, Convert.ToString(value), null); - } - - public static void NoFormatter( - this ILogger logger, - OutputFormatterWriteContext formatterContext) - { - _noFormatter(logger, Convert.ToString(formatterContext.ContentType), null); - } - - public static void FormatterSelected( - this ILogger logger, - IOutputFormatter outputFormatter, - OutputFormatterWriteContext context) - { - var contentType = Convert.ToString(context.ContentType); - _formatterSelected(logger, outputFormatter, contentType, null); - } - - public static void SkippedContentNegotiation(this ILogger logger, string contentType) - { - _skippedContentNegotiation(logger, contentType, null); - } - - public static void NoAcceptForNegotiation(this ILogger logger) - { - _noAcceptForNegotiation(logger, null, null); - } - - public static void NoFormatterFromNegotiation(this ILogger logger, IList acceptTypes) - { - _noFormatterFromNegotiation(logger, acceptTypes, null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Logging/RedirectResultLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Logging/RedirectResultLoggerExtensions.cs deleted file mode 100644 index 97b20441a6..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Logging/RedirectResultLoggerExtensions.cs +++ /dev/null @@ -1,26 +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 Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - internal static class RedirectResultLoggerExtensions - { - private static readonly Action _redirectResultExecuting; - - static RedirectResultLoggerExtensions() - { - _redirectResultExecuting = LoggerMessage.Define( - LogLevel.Information, - 1, - "Executing RedirectResult, redirecting to {Destination}."); - } - - public static void RedirectResultExecuting(this ILogger logger, string destination) - { - _redirectResultExecuting(logger, destination, null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Logging/RedirectToActionResultLoggerExtension.cs b/src/Microsoft.AspNetCore.Mvc.Core/Logging/RedirectToActionResultLoggerExtension.cs deleted file mode 100644 index 81682b0f13..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Logging/RedirectToActionResultLoggerExtension.cs +++ /dev/null @@ -1,26 +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 Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - internal static class RedirectToActionResultLoggerExtensions - { - private static readonly Action _redirectToActionResultExecuting; - - static RedirectToActionResultLoggerExtensions() - { - _redirectToActionResultExecuting = LoggerMessage.Define( - LogLevel.Information, - 1, - "Executing RedirectResult, redirecting to {Destination}."); - } - - public static void RedirectToActionResultExecuting(this ILogger logger, string destination) - { - _redirectToActionResultExecuting(logger, destination, null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Logging/RedirectToRouteResultLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Logging/RedirectToRouteResultLoggerExtensions.cs deleted file mode 100644 index 150d346aa3..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Logging/RedirectToRouteResultLoggerExtensions.cs +++ /dev/null @@ -1,26 +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 Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - internal static class RedirectToRouteResultLoggerExtensions - { - private static readonly Action _redirectToRouteResultExecuting; - - static RedirectToRouteResultLoggerExtensions() - { - _redirectToRouteResultExecuting = LoggerMessage.Define( - LogLevel.Information, - 1, - "Executing RedirectToRouteResult, redirecting to {Destination} from route {RouteName}."); - } - - public static void RedirectToRouteResultExecuting(this ILogger logger, string destination, string routeName) - { - _redirectToRouteResultExecuting(logger, destination, routeName, null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Logging/ViewResultExecutorLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Logging/ViewResultExecutorLoggerExtensions.cs deleted file mode 100644 index 66b7d80b0e..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Logging/ViewResultExecutorLoggerExtensions.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - internal static class ViewResultExecutorLoggerExtensions - { - private static readonly Action _viewFound; - private static readonly Action, Exception> _viewNotFound; - - static ViewResultExecutorLoggerExtensions() - { - _viewFound = LoggerMessage.Define( - LogLevel.Debug, - 1, - "The view '{ViewName}' was found."); - _viewNotFound = LoggerMessage.Define>( - LogLevel.Error, - 2, - "The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}"); - } - - public static void ViewFound(this ILogger logger, string viewName) - { - _viewFound(logger, viewName, null); - } - - public static void ViewNotFound( - this ILogger logger, - string viewName, - IEnumerable searchedLocations) - { - _viewNotFound(logger, viewName, searchedLocations, null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/RedirectResult.cs b/src/Microsoft.AspNetCore.Mvc.Core/RedirectResult.cs index ec57c33df9..26b40c3a58 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/RedirectResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/RedirectResult.cs @@ -3,7 +3,7 @@ using System; using Microsoft.AspNetCore.Mvc.Core; -using Microsoft.AspNetCore.Mvc.Logging; +using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.Routing; using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.Extensions.DependencyInjection; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/RedirectToActionResult.cs b/src/Microsoft.AspNetCore.Mvc.Core/RedirectToActionResult.cs index 15a645f77f..4e43a3751f 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/RedirectToActionResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/RedirectToActionResult.cs @@ -3,7 +3,7 @@ using System; using Microsoft.AspNetCore.Mvc.Core; -using Microsoft.AspNetCore.Mvc.Logging; +using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.Routing; using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Routing; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/RedirectToRouteResult.cs b/src/Microsoft.AspNetCore.Mvc.Core/RedirectToRouteResult.cs index f1a9af4259..994033c676 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/RedirectToRouteResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/RedirectToRouteResult.cs @@ -3,7 +3,7 @@ using System; using Microsoft.AspNetCore.Mvc.Core; -using Microsoft.AspNetCore.Mvc.Logging; +using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.Routing; using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Routing; diff --git a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Infrastructure/JsonResultExecutor.cs b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/JsonResultExecutor.cs similarity index 97% rename from src/Microsoft.AspNetCore.Mvc.Formatters.Json/Infrastructure/JsonResultExecutor.cs rename to src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/JsonResultExecutor.cs index fd26034751..a0e12cfd94 100644 --- a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Infrastructure/JsonResultExecutor.cs +++ b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/JsonResultExecutor.cs @@ -5,13 +5,12 @@ using System; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Internal; -using Microsoft.AspNetCore.Mvc.Logging; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Net.Http.Headers; using Newtonsoft.Json; -namespace Microsoft.AspNetCore.Mvc.Infrastructure +namespace Microsoft.AspNetCore.Mvc.Formatters.Json.Internal { /// /// Executes a to write to the response. diff --git a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Infrastructure/JsonSerializerObjectPolicy.cs b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/JsonSerializerObjectPolicy.cs similarity index 95% rename from src/Microsoft.AspNetCore.Mvc.Formatters.Json/Infrastructure/JsonSerializerObjectPolicy.cs rename to src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/JsonSerializerObjectPolicy.cs index e2ff43ddf6..5cd0a0e3d6 100644 --- a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Infrastructure/JsonSerializerObjectPolicy.cs +++ b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/JsonSerializerObjectPolicy.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.ObjectPool; using Newtonsoft.Json; -namespace Microsoft.AspNetCore.Mvc.Formatters.Internal +namespace Microsoft.AspNetCore.Mvc.Formatters.Json.Internal { /// /// for . diff --git a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/MediaTypeHeaderValues.cs b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/MediaTypeHeaderValues.cs index c8109b042e..0b45cff678 100644 --- a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/MediaTypeHeaderValues.cs +++ b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/MediaTypeHeaderValues.cs @@ -3,7 +3,7 @@ using Microsoft.Net.Http.Headers; -namespace Microsoft.AspNetCore.Mvc.Internal +namespace Microsoft.AspNetCore.Mvc.Formatters.Json.Internal { internal class MediaTypeHeaderValues { diff --git a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/MvcJsonLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/MvcJsonLoggerExtensions.cs new file mode 100644 index 0000000000..df064c4bb6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/MvcJsonLoggerExtensions.cs @@ -0,0 +1,38 @@ +// 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.Mvc.Formatters.Json.Internal +{ + internal static class MvcJsonLoggerExtensions + { + private static readonly Action _jsonInputFormatterCrashed; + + private static readonly Action _jsonResultExecuting; + + static MvcJsonLoggerExtensions() + { + _jsonInputFormatterCrashed = LoggerMessage.Define( + LogLevel.Debug, + 1, + "JSON input formatter threw an exception."); + + _jsonResultExecuting = LoggerMessage.Define( + LogLevel.Information, + 1, + "Executing JsonResult, writing value {Value}."); + } + + public static void JsonInputException(this ILogger logger, Exception exception) + { + _jsonInputFormatterCrashed(logger, exception.ToString(), exception); + } + + public static void JsonResultExecuting(this ILogger logger, object value) + { + _jsonResultExecuting(logger, Convert.ToString(value), null); + } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/SerializerSettingsProvider.cs b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/SerializerSettingsProvider.cs index 68f73f1e90..b80fcb137f 100644 --- a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/SerializerSettingsProvider.cs +++ b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/SerializerSettingsProvider.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace Microsoft.AspNetCore.Mvc.Internal +namespace Microsoft.AspNetCore.Mvc.Formatters.Json.Internal { /// /// Helper class which provides . diff --git a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/JsonInputFormatter.cs b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/JsonInputFormatter.cs index 6813387970..98ab34056c 100644 --- a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/JsonInputFormatter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/JsonInputFormatter.cs @@ -4,10 +4,7 @@ using System; using System.Buffers; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Formatters.Internal; using Microsoft.AspNetCore.Mvc.Formatters.Json.Internal; -using Microsoft.AspNetCore.Mvc.Formatters.Json.Logging; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.Extensions.Logging; using Microsoft.Extensions.ObjectPool; diff --git a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/JsonPatchInputFormatter.cs b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/JsonPatchInputFormatter.cs index e7915ea1bc..ab6c79ea7f 100644 --- a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/JsonPatchInputFormatter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/JsonPatchInputFormatter.cs @@ -6,7 +6,7 @@ using System.Buffers; using System.Reflection; using System.Threading.Tasks; using Microsoft.AspNetCore.JsonPatch; -using Microsoft.AspNetCore.Mvc.Internal; +using Microsoft.AspNetCore.Mvc.Formatters.Json.Internal; using Microsoft.Extensions.Logging; using Microsoft.Extensions.ObjectPool; using Newtonsoft.Json; diff --git a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/JsonResult.cs b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/JsonResult.cs index 9cb0ceae61..b470eafc4f 100644 --- a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/JsonResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/JsonResult.cs @@ -3,9 +3,8 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Infrastructure; +using Microsoft.AspNetCore.Mvc.Formatters.Json.Internal; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Net.Http.Headers; using Newtonsoft.Json; namespace Microsoft.AspNetCore.Mvc diff --git a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Logging/JsonInputFormatterLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Logging/JsonInputFormatterLoggerExtensions.cs deleted file mode 100644 index d7e23f940b..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Logging/JsonInputFormatterLoggerExtensions.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Formatters.Json.Logging -{ - internal static class JsonInputFormatterLoggerExtensions - { - private static readonly Action _jsonInputFormatterCrashed; - - static JsonInputFormatterLoggerExtensions() - { - _jsonInputFormatterCrashed = LoggerMessage.Define( - LogLevel.Debug, - 1, - "JSON input formatter threw an exception."); - } - - public static void JsonInputException(this ILogger logger, Exception exception) - { - _jsonInputFormatterCrashed(logger, exception.ToString(), exception); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Logging/JsonResultExecutorLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Logging/JsonResultExecutorLoggerExtensions.cs deleted file mode 100644 index b12a073c49..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Logging/JsonResultExecutorLoggerExtensions.cs +++ /dev/null @@ -1,26 +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 Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - internal static class JsonResultExecutorLoggerExtensions - { - private static readonly Action _jsonResultExecuting; - - static JsonResultExecutorLoggerExtensions() - { - _jsonResultExecuting = LoggerMessage.Define( - LogLevel.Information, - 1, - "Executing JsonResult, writing value {Value}."); - } - - public static void JsonResultExecuting(this ILogger logger, object value) - { - _jsonResultExecuting(logger, Convert.ToString(value), null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/MvcJsonOptions.cs b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/MvcJsonOptions.cs index 9188702937..b273c96fad 100644 --- a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/MvcJsonOptions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/MvcJsonOptions.cs @@ -1,7 +1,7 @@ // 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 Microsoft.AspNetCore.Mvc.Internal; +using Microsoft.AspNetCore.Mvc.Formatters.Json.Internal; using Newtonsoft.Json; namespace Microsoft.AspNetCore.Mvc diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/RazorCompilationService.cs b/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/RazorCompilationService.cs index 5206ef8a31..e41141d923 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/RazorCompilationService.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/RazorCompilationService.cs @@ -7,12 +7,11 @@ using System.Diagnostics; using System.IO; using System.Linq; using Microsoft.AspNetCore.Diagnostics; -using Microsoft.AspNetCore.Mvc.Logging; +using Microsoft.AspNetCore.Mvc.Razor.Internal; using Microsoft.AspNetCore.Razor; using Microsoft.AspNetCore.Razor.CodeGenerators; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Mvc.Razor.Compilation { diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/RoslynCompilationService.cs b/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/RoslynCompilationService.cs index c86466c78f..47ef124a82 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/RoslynCompilationService.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/RoslynCompilationService.cs @@ -14,7 +14,6 @@ using System.Runtime.Loader; #endif using System.Runtime.Versioning; using Microsoft.AspNetCore.Diagnostics; -using Microsoft.AspNetCore.Mvc.Logging; using Microsoft.AspNetCore.Mvc.Razor.Internal; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/Internal/MvcRazorLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor/Internal/MvcRazorLoggerExtensions.cs new file mode 100644 index 0000000000..cf6fff2865 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor/Internal/MvcRazorLoggerExtensions.cs @@ -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; +using System.Diagnostics; +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.Mvc.Razor.Internal +{ + internal static class MvcRazorLoggerExtensions + { + private static readonly double TimestampToTicks = TimeSpan.TicksPerSecond / (double)Stopwatch.Frequency; + + private static readonly Action _generatedCodeToAssemblyCompilationStart; + private static readonly Action _generatedCodeToAssemblyCompilationEnd; + + private static readonly Action _razorFileToCodeCompilationStart; + private static readonly Action _razorFileToCodeCompilationEnd; + + private static readonly Action _viewLookupCacheMiss; + private static readonly Action _viewLookupCacheHit; + + static MvcRazorLoggerExtensions() + { + _razorFileToCodeCompilationStart = LoggerMessage.Define( + LogLevel.Debug, + 1, + "Code generation for the Razor file at '{FilePath}' started."); + + _razorFileToCodeCompilationEnd = LoggerMessage.Define( + LogLevel.Debug, + 2, + "Code generation for the Razor file at '{FilePath}' completed in {ElapsedMilliseconds}ms."); + + _viewLookupCacheMiss = LoggerMessage.Define( + LogLevel.Debug, + 1, + "View lookup cache miss for view '{ViewName}' in controller '{ControllerName}'."); + + _viewLookupCacheHit = LoggerMessage.Define( + LogLevel.Debug, + 2, + "View lookup cache hit for view '{ViewName}' in controller '{ControllerName}'."); + + _generatedCodeToAssemblyCompilationStart = LoggerMessage.Define( + LogLevel.Debug, + 1, + "Compilation of the generated code for the Razor file at '{FilePath}' started."); + + _generatedCodeToAssemblyCompilationEnd = LoggerMessage.Define( + LogLevel.Debug, + 2, + "Compilation of the generated code for the Razor file at '{FilePath}' completed in {ElapsedMilliseconds}ms."); + } + + public static void RazorFileToCodeCompilationStart(this ILogger logger, string filePath) + { + _razorFileToCodeCompilationStart(logger, filePath, null); + } + + public static void RazorFileToCodeCompilationEnd(this ILogger logger, string filePath, long startTimestamp) + { + // Don't log if logging wasn't enabled at start of request as time will be wildly wrong. + if (startTimestamp != 0) + { + var currentTimestamp = Stopwatch.GetTimestamp(); + var elapsed = new TimeSpan((long)(TimestampToTicks * (currentTimestamp - startTimestamp))); + _razorFileToCodeCompilationEnd(logger, filePath, elapsed.TotalMilliseconds, null); + } + } + + public static void ViewLookupCacheMiss(this ILogger logger, string viewName, string controllerName) + { + _viewLookupCacheMiss(logger, viewName, controllerName, null); + } + + public static void ViewLookupCacheHit(this ILogger logger, string viewName, string controllerName) + { + _viewLookupCacheHit(logger, viewName, controllerName, null); + } + + public static void GeneratedCodeToAssemblyCompilationStart(this ILogger logger, string filePath) + { + _generatedCodeToAssemblyCompilationStart(logger, filePath, null); + } + + public static void GeneratedCodeToAssemblyCompilationEnd(this ILogger logger, string filePath, long startTimestamp) + { + // Don't log if logging wasn't enabled at start of request as time will be wildly wrong. + if (startTimestamp != 0) + { + var currentTimestamp = Stopwatch.GetTimestamp(); + var elapsed = new TimeSpan((long)(TimestampToTicks * (currentTimestamp - startTimestamp))); + _generatedCodeToAssemblyCompilationEnd(logger, filePath, elapsed.TotalMilliseconds, null); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/Logging/RazorCompilationServiceLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor/Logging/RazorCompilationServiceLoggerExtensions.cs deleted file mode 100644 index b6aee41289..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Razor/Logging/RazorCompilationServiceLoggerExtensions.cs +++ /dev/null @@ -1,45 +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.Diagnostics; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - public static class RazorCompilationServiceLoggerExtensions - { - private static readonly double TimestampToTicks = TimeSpan.TicksPerSecond / (double)Stopwatch.Frequency; - private static readonly Action _razorFileToCodeCompilationStart; - private static readonly Action _razorFileToCodeCompilationEnd; - - static RazorCompilationServiceLoggerExtensions() - { - _razorFileToCodeCompilationStart = LoggerMessage.Define( - LogLevel.Debug, - 1, - "Code generation for the Razor file at '{FilePath}' started."); - - _razorFileToCodeCompilationEnd = LoggerMessage.Define( - LogLevel.Debug, - 2, - "Code generation for the Razor file at '{FilePath}' completed in {ElapsedMilliseconds}ms."); - } - - public static void RazorFileToCodeCompilationStart(this ILogger logger, string filePath) - { - _razorFileToCodeCompilationStart(logger, filePath, null); - } - - public static void RazorFileToCodeCompilationEnd(this ILogger logger, string filePath, long startTimestamp) - { - // Don't log if logging wasn't enabled at start of request as time will be wildly wrong. - if (startTimestamp != 0) - { - var currentTimestamp = Stopwatch.GetTimestamp(); - var elapsed = new TimeSpan((long)(TimestampToTicks * (currentTimestamp - startTimestamp))); - _razorFileToCodeCompilationEnd(logger, filePath, elapsed.TotalMilliseconds, null); - } - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/Logging/RazorViewEngineLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor/Logging/RazorViewEngineLoggerExtensions.cs deleted file mode 100644 index 7ad0919a2b..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Razor/Logging/RazorViewEngineLoggerExtensions.cs +++ /dev/null @@ -1,37 +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 Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - public static class RazorViewEngineLoggerExtensions - { - private static readonly Action _viewLookupCacheMiss; - private static readonly Action _viewLookupCacheHit; - - static RazorViewEngineLoggerExtensions() - { - _viewLookupCacheMiss = LoggerMessage.Define( - LogLevel.Debug, - 1, - "View lookup cache miss for view '{ViewName}' in controller '{ControllerName}'."); - - _viewLookupCacheHit = LoggerMessage.Define( - LogLevel.Debug, - 2, - "View lookup cache hit for view '{ViewName}' in controller '{ControllerName}'."); - } - - public static void ViewLookupCacheMiss(this ILogger logger, string viewName, string controllerName) - { - _viewLookupCacheMiss(logger, viewName, controllerName, null); - } - - public static void ViewLookupCacheHit(this ILogger logger, string viewName, string controllerName) - { - _viewLookupCacheHit(logger, viewName, controllerName, null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/Logging/RoslynCompilationServiceLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor/Logging/RoslynCompilationServiceLoggerExtensions.cs deleted file mode 100644 index c1ef6ab2fe..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Razor/Logging/RoslynCompilationServiceLoggerExtensions.cs +++ /dev/null @@ -1,45 +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.Diagnostics; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - public static class RoslynCompilationServiceLoggerExtensions - { - private static readonly double TimestampToTicks = TimeSpan.TicksPerSecond / (double)Stopwatch.Frequency; - private static readonly Action _generatedCodeToAssemblyCompilationStart; - private static readonly Action _generatedCodeToAssemblyCompilationEnd; - - static RoslynCompilationServiceLoggerExtensions() - { - _generatedCodeToAssemblyCompilationStart = LoggerMessage.Define( - LogLevel.Debug, - 1, - "Compilation of the generated code for the Razor file at '{FilePath}' started."); - - _generatedCodeToAssemblyCompilationEnd = LoggerMessage.Define( - LogLevel.Debug, - 2, - "Compilation of the generated code for the Razor file at '{FilePath}' completed in {ElapsedMilliseconds}ms."); - } - - public static void GeneratedCodeToAssemblyCompilationStart(this ILogger logger, string filePath) - { - _generatedCodeToAssemblyCompilationStart(logger, filePath, null); - } - - public static void GeneratedCodeToAssemblyCompilationEnd(this ILogger logger, string filePath, long startTimestamp) - { - // Don't log if logging wasn't enabled at start of request as time will be wildly wrong. - if (startTimestamp != 0) - { - var currentTimestamp = Stopwatch.GetTimestamp(); - var elapsed = new TimeSpan((long)(TimestampToTicks * (currentTimestamp - startTimestamp))); - _generatedCodeToAssemblyCompilationEnd(logger, filePath, elapsed.TotalMilliseconds, null); - } - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/RazorViewEngine.cs b/src/Microsoft.AspNetCore.Mvc.Razor/RazorViewEngine.cs index f2d73213e6..6c422b13ae 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor/RazorViewEngine.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor/RazorViewEngine.cs @@ -7,7 +7,7 @@ using System.Diagnostics; using System.Globalization; using System.Linq; using System.Text.Encodings.Web; -using Microsoft.AspNetCore.Mvc.Logging; +using Microsoft.AspNetCore.Mvc.Razor.Internal; using Microsoft.AspNetCore.Mvc.Routing; using Microsoft.AspNetCore.Mvc.ViewEngines; using Microsoft.Extensions.Caching.Memory; diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/DiagnosticSource/ViewExecutorDiagnosticSourceExtensions.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/DiagnosticSource/ViewExecutorDiagnosticSourceExtensions.cs deleted file mode 100644 index 7a0a0d6f4a..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/DiagnosticSource/ViewExecutorDiagnosticSourceExtensions.cs +++ /dev/null @@ -1,85 +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.Collections.Generic; -using System.Diagnostics; -using Microsoft.AspNetCore.Mvc.Rendering; -using Microsoft.AspNetCore.Mvc.ViewEngines; - -namespace Microsoft.AspNetCore.Mvc.Diagnostics -{ - public static class ViewExecutorDiagnosticSourceExtensions - { - public static void BeforeView( - this DiagnosticSource diagnosticSource, - IView view, - ViewContext viewContext) - { - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeView")) - { - diagnosticSource.Write( - "Microsoft.AspNetCore.Mvc.BeforeView", - new { view = view, viewContext = viewContext, }); - } - } - - public static void AfterView( - this DiagnosticSource diagnosticSource, - IView view, - ViewContext viewContext) - { - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterView")) - { - diagnosticSource.Write( - "Microsoft.AspNetCore.Mvc.AfterView", - new { view = view, viewContext = viewContext, }); - } - } - - public static void ViewFound( - this DiagnosticSource diagnosticSource, - ActionContext actionContext, - bool isMainPage, - PartialViewResult viewResult, - string viewName, - IView view) - { - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewFound")) - { - diagnosticSource.Write( - "Microsoft.AspNetCore.Mvc.ViewFound", - new - { - actionContext = actionContext, - isMainPage = isMainPage, - result = viewResult, - viewName = viewName, - view = view, - }); - } - } - - public static void ViewNotFound( - this DiagnosticSource diagnosticSource, - ActionContext actionContext, - bool isMainPage, - PartialViewResult viewResult, - string viewName, - IEnumerable searchedLocations) - { - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewNotFound")) - { - diagnosticSource.Write( - "Microsoft.AspNetCore.Mvc.ViewNotFound", - new - { - actionContext = actionContext, - isMainPage = isMainPage, - result = viewResult, - viewName = viewName, - searchedLocations = searchedLocations, - }); - } - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/DiagnosticSource/ViewComponentDiagnosticSourceExtensions.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/MvcViewFeaturesDiagnosticSourceExtensions.cs similarity index 52% rename from src/Microsoft.AspNetCore.Mvc.ViewFeatures/DiagnosticSource/ViewComponentDiagnosticSourceExtensions.cs rename to src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/MvcViewFeaturesDiagnosticSourceExtensions.cs index cca16d7da2..305b16a87d 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/DiagnosticSource/ViewComponentDiagnosticSourceExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/MvcViewFeaturesDiagnosticSourceExtensions.cs @@ -1,14 +1,15 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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.Collections.Generic; using System.Diagnostics; -using Microsoft.AspNetCore.Mvc.Abstractions; +using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewComponents; using Microsoft.AspNetCore.Mvc.ViewEngines; -namespace Microsoft.AspNetCore.Mvc.Diagnostics +namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal { - public static class ViewComponentDiagnosticSourceExtensions + internal static class MvcViewFeaturesDiagnosticSourceExtensions { public static void BeforeViewComponent( this DiagnosticSource diagnosticSource, @@ -83,5 +84,77 @@ namespace Microsoft.AspNetCore.Mvc.Diagnostics }); } } + + public static void BeforeView( + this DiagnosticSource diagnosticSource, + IView view, + ViewContext viewContext) + { + if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeView")) + { + diagnosticSource.Write( + "Microsoft.AspNetCore.Mvc.BeforeView", + new { view = view, viewContext = viewContext, }); + } + } + + public static void AfterView( + this DiagnosticSource diagnosticSource, + IView view, + ViewContext viewContext) + { + if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterView")) + { + diagnosticSource.Write( + "Microsoft.AspNetCore.Mvc.AfterView", + new { view = view, viewContext = viewContext, }); + } + } + + public static void ViewFound( + this DiagnosticSource diagnosticSource, + ActionContext actionContext, + bool isMainPage, + PartialViewResult viewResult, + string viewName, + IView view) + { + if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewFound")) + { + diagnosticSource.Write( + "Microsoft.AspNetCore.Mvc.ViewFound", + new + { + actionContext = actionContext, + isMainPage = isMainPage, + result = viewResult, + viewName = viewName, + view = view, + }); + } + } + + public static void ViewNotFound( + this DiagnosticSource diagnosticSource, + ActionContext actionContext, + bool isMainPage, + PartialViewResult viewResult, + string viewName, + IEnumerable searchedLocations) + { + if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewNotFound")) + { + diagnosticSource.Write( + "Microsoft.AspNetCore.Mvc.ViewNotFound", + new + { + actionContext = actionContext, + isMainPage = isMainPage, + result = viewResult, + viewName = viewName, + searchedLocations = searchedLocations, + }); + } + } } } diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/MvcViewFeaturesLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/MvcViewFeaturesLoggerExtensions.cs new file mode 100644 index 0000000000..6b604aa2cd --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/MvcViewFeaturesLoggerExtensions.cs @@ -0,0 +1,219 @@ +// 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 System.Diagnostics; +using Microsoft.AspNetCore.Mvc.ViewComponents; +using Microsoft.AspNetCore.Mvc.ViewEngines; +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal +{ + internal static class MvcViewFeaturesLoggerExtensions + { + private static readonly double TimestampToTicks = TimeSpan.TicksPerSecond / (double)Stopwatch.Frequency; + private static readonly string[] EmptyArguments = new string[0]; + + private static readonly Action _viewComponentExecuting; + private static readonly Action _viewComponentExecuted; + + private static readonly Action _partialViewFound; + private static readonly Action, Exception> _partialViewNotFound; + private static readonly Action _partialViewResultExecuting; + + private static readonly Action _antiforgeryTokenInvalid; + + private static readonly Action _viewComponentResultExecuting; + + private static readonly Action _viewResultExecuting; + private static readonly Action _viewFound; + private static readonly Action, Exception> _viewNotFound; + + static MvcViewFeaturesLoggerExtensions() + { + _viewComponentExecuting = LoggerMessage.Define( + LogLevel.Debug, + 1, + "Executing view component {ViewComponentName} with arguments ({Arguments})."); + + _viewComponentExecuted = LoggerMessage.Define( + LogLevel.Debug, + 2, + "Executed view component {ViewComponentName} in {ElapsedMilliseconds}ms and returned " + + "{ViewComponentResult}"); + + _partialViewResultExecuting = LoggerMessage.Define( + LogLevel.Information, + 1, + "Executing PartialViewResult, running view at path {Path}."); + + _partialViewFound = LoggerMessage.Define( + LogLevel.Debug, + 2, + "The partial view '{PartialViewName}' was found."); + + _partialViewNotFound = LoggerMessage.Define>( + LogLevel.Error, + 3, + "The partial view '{PartialViewName}' was not found. Searched locations: {SearchedViewLocations}"); + + _antiforgeryTokenInvalid = LoggerMessage.Define( + LogLevel.Information, + 1, + "Antiforgery token validation failed. {Message}"); + + _viewComponentResultExecuting = LoggerMessage.Define( + LogLevel.Information, + 1, + "Executing ViewComponentResult, running {ViewComponentName}."); + + _viewResultExecuting = LoggerMessage.Define( + LogLevel.Information, + 1, + "Executing ViewResult, running view at path {Path}."); + + _viewFound = LoggerMessage.Define( + LogLevel.Debug, + 2, + "The view '{ViewName}' was found."); + + _viewNotFound = LoggerMessage.Define>( + LogLevel.Error, + 3, + "The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}"); + } + + public static IDisposable ViewComponentScope(this ILogger logger, ViewComponentContext context) + { + return logger.BeginScopeImpl(new ViewComponentLogScope(context.ViewComponentDescriptor)); + } + + public static void ViewComponentExecuting( + this ILogger logger, + ViewComponentContext context, + object[] arguments) + { + var formattedArguments = GetFormattedArguments(arguments); + _viewComponentExecuting(logger, context.ViewComponentDescriptor.DisplayName, formattedArguments, null); + } + + private static string[] GetFormattedArguments(object[] arguments) + { + if (arguments == null || arguments.Length == 0) + { + return EmptyArguments; + } + + var formattedArguments = new string[arguments.Length]; + for (var i = 0; i < formattedArguments.Length; i++) + { + formattedArguments[i] = Convert.ToString(arguments[i]); + } + + return formattedArguments; + } + + public static void ViewComponentExecuted( + this ILogger logger, + ViewComponentContext context, + long startTimestamp, + object result) + { + // Don't log if logging wasn't enabled at start of request as time will be wildly wrong. + if (startTimestamp != 0) + { + var currentTimestamp = Stopwatch.GetTimestamp(); + var elapsed = new TimeSpan((long)(TimestampToTicks * (currentTimestamp - startTimestamp))); + + _viewComponentExecuted( + logger, + context.ViewComponentDescriptor.DisplayName, + elapsed.TotalMilliseconds, + Convert.ToString(result), + null); + } + } + + public static void PartialViewFound( + this ILogger logger, + string partialViewName) + { + _partialViewFound(logger, partialViewName, null); + } + + public static void PartialViewNotFound( + this ILogger logger, + string partialViewName, + IEnumerable searchedLocations) + { + _partialViewNotFound(logger, partialViewName, searchedLocations, null); + } + + public static void PartialViewResultExecuting(this ILogger logger, IView view) + { + _partialViewResultExecuting(logger, view.Path, null); + } + + public static void AntiforgeryTokenInvalid(this ILogger logger, string message, Exception exception) + { + _antiforgeryTokenInvalid(logger, message, exception); + } + + public static void ViewComponentResultExecuting(this ILogger logger, string viewComponentName) + { + if (logger.IsEnabled(LogLevel.Information)) + { + _viewComponentResultExecuting(logger, viewComponentName, null); + } + } + + public static void ViewComponentResultExecuting(this ILogger logger, Type viewComponentType) + { + if (logger.IsEnabled(LogLevel.Information)) + { + _viewComponentResultExecuting(logger, viewComponentType.Name, null); + } + } + + public static void ViewResultExecuting(this ILogger logger, IView view) + { + _viewResultExecuting(logger, view.Path, null); + } + + public static void ViewFound(this ILogger logger, string viewName) + { + _viewFound(logger, viewName, null); + } + + public static void ViewNotFound(this ILogger logger, string viewName, + IEnumerable searchedLocations) + { + _viewNotFound(logger, viewName, searchedLocations, null); + } + + private class ViewComponentLogScope : ILogValues + { + private readonly ViewComponentDescriptor _descriptor; + + public ViewComponentLogScope(ViewComponentDescriptor descriptor) + { + _descriptor = descriptor; + } + + public IEnumerable> GetValues() + { + return new KeyValuePair[] + { + new KeyValuePair("ViewComponentName", _descriptor.DisplayName), + new KeyValuePair("ViewComponentId", _descriptor.Id), + }; + } + + public override string ToString() + { + return _descriptor.DisplayName; + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/ValidateAntiforgeryTokenAuthorizationFilter.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/ValidateAntiforgeryTokenAuthorizationFilter.cs index 955d11f537..f981c33484 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/ValidateAntiforgeryTokenAuthorizationFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/ValidateAntiforgeryTokenAuthorizationFilter.cs @@ -7,8 +7,6 @@ using System.Diagnostics; using System.Threading.Tasks; using Microsoft.AspNetCore.Antiforgery; using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.AspNetCore.Mvc.Internal; -using Microsoft.AspNetCore.Mvc.Logging; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/DefaultViewComponentInvokerLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/DefaultViewComponentInvokerLoggerExtensions.cs deleted file mode 100644 index d623e5ea67..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/DefaultViewComponentInvokerLoggerExtensions.cs +++ /dev/null @@ -1,113 +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 System.Diagnostics; -using Microsoft.AspNetCore.Mvc.ViewComponents; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Logging -{ - public static class DefaultViewComponentInvokerLoggerExtensions - { - private static readonly double TimestampToTicks = TimeSpan.TicksPerSecond / (double)Stopwatch.Frequency; - private static readonly string[] EmptyArguments = -#if NET451 - new string[0]; -#else - Array.Empty(); -#endif - private static readonly Action _viewComponentExecuting; - private static readonly Action _viewComponentExecuted; - - static DefaultViewComponentInvokerLoggerExtensions() - { - _viewComponentExecuting = LoggerMessage.Define( - LogLevel.Debug, - 1, - "Executing view component {ViewComponentName} with arguments ({Arguments})."); - - _viewComponentExecuted = LoggerMessage.Define( - LogLevel.Debug, - 2, - "Executed view component {ViewComponentName} in {ElapsedMilliseconds}ms and returned " + - "{ViewComponentResult}"); - } - - public static IDisposable ViewComponentScope(this ILogger logger, ViewComponentContext context) - { - return logger.BeginScopeImpl(new ViewComponentLogScope(context.ViewComponentDescriptor)); - } - - public static void ViewComponentExecuting( - this ILogger logger, - ViewComponentContext context, - object[] arguments) - { - var formattedArguments = GetFormattedArguments(arguments); - _viewComponentExecuting(logger, context.ViewComponentDescriptor.DisplayName, formattedArguments, null); - } - - private static string[] GetFormattedArguments(object[] arguments) - { - if (arguments == null || arguments.Length == 0) - { - return EmptyArguments; - } - - var formattedArguments = new string[arguments.Length]; - for (var i = 0; i < formattedArguments.Length; i++) - { - formattedArguments[i] = Convert.ToString(arguments[i]); - } - - return formattedArguments; - } - - public static void ViewComponentExecuted( - this ILogger logger, - ViewComponentContext context, - long startTimestamp, - object result) - { - // Don't log if logging wasn't enabled at start of request as time will be wildly wrong. - if (startTimestamp != 0) - { - var currentTimestamp = Stopwatch.GetTimestamp(); - var elapsed = new TimeSpan((long)(TimestampToTicks * (currentTimestamp - startTimestamp))); - - _viewComponentExecuted( - logger, - context.ViewComponentDescriptor.DisplayName, - elapsed.TotalMilliseconds, - Convert.ToString(result), - null); - } - } - - private class ViewComponentLogScope : ILogValues - { - private readonly ViewComponentDescriptor _descriptor; - - public ViewComponentLogScope(ViewComponentDescriptor descriptor) - { - _descriptor = descriptor; - } - - public IEnumerable> GetValues() - { - return new KeyValuePair[] - { - new KeyValuePair("ViewComponentName", _descriptor.DisplayName), - new KeyValuePair("ViewComponentId", _descriptor.Id), - }; - } - - public override string ToString() - { - return _descriptor.DisplayName; - } - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/PartialViewResultExecutorLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/PartialViewResultExecutorLoggerExtensions.cs deleted file mode 100644 index cfb7d28b55..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/PartialViewResultExecutorLoggerExtensions.cs +++ /dev/null @@ -1,53 +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 Microsoft.AspNetCore.Mvc.ViewEngines; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Logging -{ - internal static class PartialViewResultExecutorLoggerExtensions - { - private static readonly Action _partialViewFound; - private static readonly Action, Exception> _partialViewNotFound; - private static readonly Action _partialViewResultExecuting; - - static PartialViewResultExecutorLoggerExtensions() - { - _partialViewResultExecuting = LoggerMessage.Define( - LogLevel.Information, - 1, - "Executing PartialViewResult, running view at path {Path}."); - _partialViewFound = LoggerMessage.Define( - LogLevel.Debug, - 2, - "The partial view '{PartialViewName}' was found."); - _partialViewNotFound = LoggerMessage.Define>( - LogLevel.Error, - 3, - "The partial view '{PartialViewName}' was not found. Searched locations: {SearchedViewLocations}"); - } - - public static void PartialViewFound( - this ILogger logger, - string partialViewName) - { - _partialViewFound(logger, partialViewName, null); - } - - public static void PartialViewNotFound( - this ILogger logger, - string partialViewName, - IEnumerable searchedLocations) - { - _partialViewNotFound(logger, partialViewName, searchedLocations, null); - } - - public static void PartialViewResultExecuting(this ILogger logger, IView view) - { - _partialViewResultExecuting(logger, view.Path, null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/ValidateAntiforgeryTokenAuthorizationFilterLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/ValidateAntiforgeryTokenAuthorizationFilterLoggerExtensions.cs deleted file mode 100644 index 2757e495b3..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/ValidateAntiforgeryTokenAuthorizationFilterLoggerExtensions.cs +++ /dev/null @@ -1,26 +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 Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - public static class ValidateAntiforgeryTokenAuthorizationFilterLoggerExtensions - { - private static readonly Action _antiforgeryTokenInvalid; - - static ValidateAntiforgeryTokenAuthorizationFilterLoggerExtensions() - { - _antiforgeryTokenInvalid = LoggerMessage.Define( - LogLevel.Information, - 1, - "Antiforgery token validation failed. {Message}"); - } - - public static void AntiforgeryTokenInvalid(this ILogger logger, string message, Exception exception) - { - _antiforgeryTokenInvalid(logger, message, exception); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/ViewComponentResultLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/ViewComponentResultLoggerExtensions.cs deleted file mode 100644 index 3b3b9d56b5..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/ViewComponentResultLoggerExtensions.cs +++ /dev/null @@ -1,37 +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 Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - public static class ViewComponentResultLoggerExtensions - { - private static readonly Action _viewComponentResultExecuting; - - static ViewComponentResultLoggerExtensions() - { - _viewComponentResultExecuting = LoggerMessage.Define( - LogLevel.Information, - 1, - "Executing ViewComponentResult, running {ViewComponentName}."); - } - - public static void ViewComponentResultExecuting(this ILogger logger, string viewComponentName) - { - if (logger.IsEnabled(LogLevel.Information)) - { - _viewComponentResultExecuting(logger, viewComponentName, null); - } - } - - public static void ViewComponentResultExecuting(this ILogger logger, Type viewComponentType) - { - if (logger.IsEnabled(LogLevel.Information)) - { - _viewComponentResultExecuting(logger, viewComponentType.Name, null); - } - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/ViewResultExecutorLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/ViewResultExecutorLoggerExtensions.cs deleted file mode 100644 index ffc69b299d..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Logging/ViewResultExecutorLoggerExtensions.cs +++ /dev/null @@ -1,49 +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 Microsoft.AspNetCore.Mvc.ViewEngines; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Mvc.Logging -{ - public static class ViewResultExecutorLoggerExtensions - { - private static readonly Action _viewResultExecuting; - private static readonly Action _viewFound; - private static readonly Action, Exception> _viewNotFound; - - static ViewResultExecutorLoggerExtensions() - { - _viewResultExecuting = LoggerMessage.Define( - LogLevel.Information, - 1, - "Executing ViewResult, running view at path {Path}."); - _viewFound = LoggerMessage.Define( - LogLevel.Debug, - 2, - "The view '{ViewName}' was found."); - _viewNotFound = LoggerMessage.Define>( - LogLevel.Error, - 3, - "The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}"); - } - - public static void ViewResultExecuting(this ILogger logger, IView view) - { - _viewResultExecuting(logger, view.Path, null); - } - - public static void ViewFound(this ILogger logger, string viewName) - { - _viewFound(logger, viewName, null); - } - - public static void ViewNotFound(this ILogger logger, string viewName, - IEnumerable searchedLocations) - { - _viewNotFound(logger, viewName, searchedLocations, null); - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponentResult.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponentResult.cs index 284adbf65e..3e29a5c8de 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponentResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponentResult.cs @@ -7,7 +7,6 @@ using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Html; using Microsoft.AspNetCore.Mvc.Internal; -using Microsoft.AspNetCore.Mvc.Logging; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewEngines; diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentInvoker.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentInvoker.cs index dd83e32eb8..853298f95b 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentInvoker.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentInvoker.cs @@ -7,12 +7,9 @@ using System.Reflection; using System.Runtime.ExceptionServices; using System.Threading.Tasks; using Microsoft.AspNetCore.Html; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.AspNetCore.Mvc.Diagnostics; -using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.ViewFeatures; -using Microsoft.AspNetCore.Mvc.ViewFeatures.Logging; +using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Mvc.ViewComponents diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/ViewViewComponentResult.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/ViewViewComponentResult.cs index 0b1dc73691..eac0f7bd81 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/ViewViewComponentResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/ViewViewComponentResult.cs @@ -6,10 +6,10 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Diagnostics; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewEngines; using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Mvc.ViewComponents diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/PartialViewResultExecutor.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/PartialViewResultExecutor.cs index 18f601d68e..6b9f29b5ea 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/PartialViewResultExecutor.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/PartialViewResultExecutor.cs @@ -6,11 +6,9 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Diagnostics; using Microsoft.AspNetCore.Mvc.Internal; -using Microsoft.AspNetCore.Mvc.Logging; using Microsoft.AspNetCore.Mvc.ViewEngines; -using Microsoft.AspNetCore.Mvc.ViewFeatures.Logging; +using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewExecutor.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewExecutor.cs index aa1486c2b1..85fe08f8a7 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewExecutor.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewExecutor.cs @@ -5,15 +5,13 @@ using System; using System.Diagnostics; using System.Text; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Diagnostics; -using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewEngines; +using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Mvc.ViewFeatures { diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewResultExecutor.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewResultExecutor.cs index 213771b831..64cdd74c94 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewResultExecutor.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewResultExecutor.cs @@ -7,8 +7,8 @@ using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Internal; -using Microsoft.AspNetCore.Mvc.Logging; using Microsoft.AspNetCore.Mvc.ViewEngines; +using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; diff --git a/test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/Infrastructure/JsonResultExecutorTest.cs b/test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/Internal/JsonResultExecutorTest.cs similarity index 98% rename from test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/Infrastructure/JsonResultExecutorTest.cs rename to test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/Internal/JsonResultExecutorTest.cs index 34cbaf7b44..8de07601a7 100644 --- a/test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/Infrastructure/JsonResultExecutorTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/Internal/JsonResultExecutorTest.cs @@ -1,9 +1,7 @@ // 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.IO; -using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; @@ -17,7 +15,7 @@ using Microsoft.Net.Http.Headers; using Newtonsoft.Json; using Xunit; -namespace Microsoft.AspNetCore.Mvc.Infrastructure +namespace Microsoft.AspNetCore.Mvc.Formatters.Json.Internal { public class JsonResultExecutorTest { diff --git a/test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/JsonOutputFormatterTests.cs b/test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/JsonOutputFormatterTests.cs index 36345d7fda..30b03f6816 100644 --- a/test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/JsonOutputFormatterTests.cs +++ b/test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/JsonOutputFormatterTests.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.Internal; +using Microsoft.AspNetCore.Mvc.Formatters.Json.Internal; using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.Logging; diff --git a/test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/JsonResultTest.cs b/test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/JsonResultTest.cs index 4805ddc61c..1d35d1cffd 100644 --- a/test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/JsonResultTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Formatters.Json.Test/JsonResultTest.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.Infrastructure; +using Microsoft.AspNetCore.Mvc.Formatters.Json.Internal; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Testing;