Zero cost(ish) diagnositcs when disabled

Inlinable fast-path check if Diagnositcs is enabled
This commit is contained in:
Ben Adams 2018-08-28 14:05:49 -07:00 committed by Pranav K
parent 98c10b6879
commit 2414db256f
36 changed files with 960 additions and 395 deletions

View File

@ -26,12 +26,12 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
internal ControllerActionInvoker(
ILogger logger,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
IActionResultTypeMapper mapper,
ControllerContext controllerContext,
ControllerActionInvokerCacheEntry cacheEntry,
IFilterMetadata[] filters)
: base(diagnosticSource, logger, mapper, controllerContext, filters, controllerContext.ValueProviderFactories)
: base(diagnosticListener, logger, mapper, controllerContext, filters, controllerContext.ValueProviderFactories)
{
if (cacheEntry == null)
{
@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var filter = (IAsyncActionFilter)state;
var actionExecutingContext = _actionExecutingContext;
_diagnosticSource.BeforeOnActionExecution(actionExecutingContext, filter);
_diagnosticListener.BeforeOnActionExecution(actionExecutingContext, filter);
_logger.BeforeExecutingMethodOnFilter(
MvcCoreLoggerExtensions.ActionFilter,
nameof(IAsyncActionFilter.OnActionExecutionAsync),
@ -152,7 +152,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
};
}
_diagnosticSource.AfterOnActionExecution(_actionExecutedContext, filter);
_diagnosticListener.AfterOnActionExecution(_actionExecutedContext, filter);
_logger.AfterExecutingMethodOnFilter(
MvcCoreLoggerExtensions.ActionFilter,
nameof(IAsyncActionFilter.OnActionExecutionAsync),
@ -169,7 +169,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var filter = (IActionFilter)state;
var actionExecutingContext = _actionExecutingContext;
_diagnosticSource.BeforeOnActionExecuting(actionExecutingContext, filter);
_diagnosticListener.BeforeOnActionExecuting(actionExecutingContext, filter);
_logger.BeforeExecutingMethodOnFilter(
MvcCoreLoggerExtensions.ActionFilter,
nameof(IActionFilter.OnActionExecuting),
@ -177,7 +177,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
filter.OnActionExecuting(actionExecutingContext);
_diagnosticSource.AfterOnActionExecuting(actionExecutingContext, filter);
_diagnosticListener.AfterOnActionExecuting(actionExecutingContext, filter);
_logger.AfterExecutingMethodOnFilter(
MvcCoreLoggerExtensions.ActionFilter,
nameof(IActionFilter.OnActionExecuting),
@ -219,7 +219,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var filter = (IActionFilter)state;
var actionExecutedContext = _actionExecutedContext;
_diagnosticSource.BeforeOnActionExecuted(actionExecutedContext, filter);
_diagnosticListener.BeforeOnActionExecuted(actionExecutedContext, filter);
_logger.BeforeExecutingMethodOnFilter(
MvcCoreLoggerExtensions.ActionFilter,
nameof(IActionFilter.OnActionExecuted),
@ -227,7 +227,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
filter.OnActionExecuted(actionExecutedContext);
_diagnosticSource.AfterOnActionExecuted(actionExecutedContext, filter);
_diagnosticListener.AfterOnActionExecuted(actionExecutedContext, filter);
_logger.AfterExecutingMethodOnFilter(
MvcCoreLoggerExtensions.ActionFilter,
nameof(IActionFilter.OnActionExecuted),
@ -335,13 +335,13 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var actionMethodExecutor = _cacheEntry.ActionMethodExecutor;
var orderedArguments = PrepareArguments(arguments, objectMethodExecutor);
var diagnosticSource = _diagnosticSource;
var diagnosticListener = _diagnosticListener;
var logger = _logger;
IActionResult result = null;
try
{
diagnosticSource.BeforeActionMethod(
diagnosticListener.BeforeActionMethod(
controllerContext,
arguments,
controller);
@ -362,7 +362,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
}
finally
{
diagnosticSource.AfterActionMethod(
diagnosticListener.AfterActionMethod(
controllerContext,
arguments,
controllerContext,

View File

@ -19,21 +19,21 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
private readonly IReadOnlyList<IValueProviderFactory> _valueProviderFactories;
private readonly int _maxModelValidationErrors;
private readonly ILogger _logger;
private readonly DiagnosticSource _diagnosticSource;
private readonly DiagnosticListener _diagnosticListener;
private readonly IActionResultTypeMapper _mapper;
public ControllerActionInvokerProvider(
ControllerActionInvokerCache controllerActionInvokerCache,
IOptions<MvcOptions> optionsAccessor,
ILoggerFactory loggerFactory,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
IActionResultTypeMapper mapper)
{
_controllerActionInvokerCache = controllerActionInvokerCache;
_valueProviderFactories = optionsAccessor.Value.ValueProviderFactories.ToArray();
_maxModelValidationErrors = optionsAccessor.Value.MaxModelValidationErrors;
_logger = loggerFactory.CreateLogger<ControllerActionInvoker>();
_diagnosticSource = diagnosticSource;
_diagnosticListener = diagnosticListener;
_mapper = mapper;
}
@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var invoker = new ControllerActionInvoker(
_logger,
_diagnosticSource,
_diagnosticListener,
_mapper,
controllerContext,
cacheResult.cacheEntry,

View File

@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
{
internal abstract class ResourceInvoker
{
protected readonly DiagnosticSource _diagnosticSource;
protected readonly DiagnosticListener _diagnosticListener;
protected readonly ILogger _logger;
protected readonly IActionResultTypeMapper _mapper;
protected readonly ActionContext _actionContext;
@ -37,14 +37,14 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
protected object _instance;
public ResourceInvoker(
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
ILogger logger,
IActionResultTypeMapper mapper,
ActionContext actionContext,
IFilterMetadata[] filters,
IList<IValueProviderFactory> valueProviderFactories)
{
_diagnosticSource = diagnosticSource ?? throw new ArgumentNullException(nameof(diagnosticSource));
_diagnosticListener = diagnosticListener ?? throw new ArgumentNullException(nameof(diagnosticListener));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
_actionContext = actionContext ?? throw new ArgumentNullException(nameof(actionContext));
@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
{
try
{
_diagnosticSource.BeforeAction(
_diagnosticListener.BeforeAction(
_actionContext.ActionDescriptor,
_actionContext.HttpContext,
_actionContext.RouteData);
@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
}
finally
{
_diagnosticSource.AfterAction(
_diagnosticListener.AfterAction(
_actionContext.ActionDescriptor,
_actionContext.HttpContext,
_actionContext.RouteData);
@ -129,7 +129,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
{
var actionContext = _actionContext;
_diagnosticSource.BeforeActionResult(actionContext, result);
_diagnosticListener.BeforeActionResult(actionContext, result);
_logger.BeforeExecutingActionResult(result);
try
@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
}
finally
{
_diagnosticSource.AfterActionResult(actionContext, result);
_diagnosticListener.AfterActionResult(actionContext, result);
_logger.AfterExecutingActionResult(result);
}
}
@ -195,7 +195,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var filter = (IAsyncAuthorizationFilter)state;
var authorizationContext = _authorizationContext;
_diagnosticSource.BeforeOnAuthorizationAsync(authorizationContext, filter);
_diagnosticListener.BeforeOnAuthorizationAsync(authorizationContext, filter);
_logger.BeforeExecutingMethodOnFilter(
FilterTypeConstants.AuthorizationFilter,
nameof(IAsyncAuthorizationFilter.OnAuthorizationAsync),
@ -219,7 +219,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var filter = (IAsyncAuthorizationFilter)state;
var authorizationContext = _authorizationContext;
_diagnosticSource.AfterOnAuthorizationAsync(authorizationContext, filter);
_diagnosticListener.AfterOnAuthorizationAsync(authorizationContext, filter);
_logger.AfterExecutingMethodOnFilter(
FilterTypeConstants.AuthorizationFilter,
nameof(IAsyncAuthorizationFilter.OnAuthorizationAsync),
@ -241,7 +241,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var filter = (IAuthorizationFilter)state;
var authorizationContext = _authorizationContext;
_diagnosticSource.BeforeOnAuthorization(authorizationContext, filter);
_diagnosticListener.BeforeOnAuthorization(authorizationContext, filter);
_logger.BeforeExecutingMethodOnFilter(
FilterTypeConstants.AuthorizationFilter,
nameof(IAuthorizationFilter.OnAuthorization),
@ -249,7 +249,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
filter.OnAuthorization(authorizationContext);
_diagnosticSource.AfterOnAuthorization(authorizationContext, filter);
_diagnosticListener.AfterOnAuthorization(authorizationContext, filter);
_logger.AfterExecutingMethodOnFilter(
FilterTypeConstants.AuthorizationFilter,
nameof(IAuthorizationFilter.OnAuthorization),
@ -332,7 +332,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var filter = (IAsyncResourceFilter)state;
var resourceExecutingContext = _resourceExecutingContext;
_diagnosticSource.BeforeOnResourceExecution(resourceExecutingContext, filter);
_diagnosticListener.BeforeOnResourceExecution(resourceExecutingContext, filter);
_logger.BeforeExecutingMethodOnFilter(
FilterTypeConstants.ResourceFilter,
nameof(IAsyncResourceFilter.OnResourceExecutionAsync),
@ -363,7 +363,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
Result = _resourceExecutingContext.Result,
};
_diagnosticSource.AfterOnResourceExecution(_resourceExecutedContext, filter);
_diagnosticListener.AfterOnResourceExecution(_resourceExecutedContext, filter);
_logger.AfterExecutingMethodOnFilter(
FilterTypeConstants.ResourceFilter,
nameof(IAsyncResourceFilter.OnResourceExecutionAsync),
@ -387,7 +387,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var filter = (IResourceFilter)state;
var resourceExecutingContext = _resourceExecutingContext;
_diagnosticSource.BeforeOnResourceExecuting(resourceExecutingContext, filter);
_diagnosticListener.BeforeOnResourceExecuting(resourceExecutingContext, filter);
_logger.BeforeExecutingMethodOnFilter(
FilterTypeConstants.ResourceFilter,
nameof(IResourceFilter.OnResourceExecuting),
@ -395,7 +395,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
filter.OnResourceExecuting(resourceExecutingContext);
_diagnosticSource.AfterOnResourceExecuting(resourceExecutingContext, filter);
_diagnosticListener.AfterOnResourceExecuting(resourceExecutingContext, filter);
_logger.AfterExecutingMethodOnFilter(
FilterTypeConstants.ResourceFilter,
nameof(IResourceFilter.OnResourceExecuting),
@ -431,7 +431,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var filter = (IResourceFilter)state;
var resourceExecutedContext = _resourceExecutedContext;
_diagnosticSource.BeforeOnResourceExecuted(resourceExecutedContext, filter);
_diagnosticListener.BeforeOnResourceExecuted(resourceExecutedContext, filter);
_logger.BeforeExecutingMethodOnFilter(
FilterTypeConstants.ResourceFilter,
nameof(IResourceFilter.OnResourceExecuted),
@ -439,7 +439,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
filter.OnResourceExecuted(resourceExecutedContext);
_diagnosticSource.AfterOnResourceExecuted(resourceExecutedContext, filter);
_diagnosticListener.AfterOnResourceExecuted(resourceExecutedContext, filter);
_logger.AfterExecutingMethodOnFilter(
FilterTypeConstants.ResourceFilter,
nameof(IResourceFilter.OnResourceExecuted),
@ -527,7 +527,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
// we'll call the filter. Otherwise there's nothing to do.
if (exceptionContext?.Exception != null && !exceptionContext.ExceptionHandled)
{
_diagnosticSource.BeforeOnExceptionAsync(exceptionContext, filter);
_diagnosticListener.BeforeOnExceptionAsync(exceptionContext, filter);
_logger.BeforeExecutingMethodOnFilter(
FilterTypeConstants.ExceptionFilter,
nameof(IAsyncExceptionFilter.OnExceptionAsync),
@ -554,7 +554,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var filter = (IAsyncExceptionFilter)state;
var exceptionContext = _exceptionContext;
_diagnosticSource.AfterOnExceptionAsync(exceptionContext, filter);
_diagnosticListener.AfterOnExceptionAsync(exceptionContext, filter);
_logger.AfterExecutingMethodOnFilter(
FilterTypeConstants.ExceptionFilter,
nameof(IAsyncExceptionFilter.OnExceptionAsync),
@ -594,7 +594,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
// we'll call the filter. Otherwise there's nothing to do.
if (exceptionContext?.Exception != null && !exceptionContext.ExceptionHandled)
{
_diagnosticSource.BeforeOnException(exceptionContext, filter);
_diagnosticListener.BeforeOnException(exceptionContext, filter);
_logger.BeforeExecutingMethodOnFilter(
FilterTypeConstants.ExceptionFilter,
nameof(IExceptionFilter.OnException),
@ -602,7 +602,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
filter.OnException(exceptionContext);
_diagnosticSource.AfterOnException(exceptionContext, filter);
_diagnosticListener.AfterOnException(exceptionContext, filter);
_logger.AfterExecutingMethodOnFilter(
FilterTypeConstants.ExceptionFilter,
nameof(IExceptionFilter.OnException),
@ -904,7 +904,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var filter = (TFilterAsync)state;
var resultExecutingContext = _resultExecutingContext;
_diagnosticSource.BeforeOnResultExecution(resultExecutingContext, filter);
_diagnosticListener.BeforeOnResultExecution(resultExecutingContext, filter);
_logger.BeforeExecutingMethodOnFilter(
resultFilterKind,
nameof(IAsyncResultFilter.OnResultExecutionAsync),
@ -944,7 +944,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
};
}
_diagnosticSource.AfterOnResultExecution(_resultExecutedContext, filter);
_diagnosticListener.AfterOnResultExecution(_resultExecutedContext, filter);
_logger.AfterExecutingMethodOnFilter(
resultFilterKind,
nameof(IAsyncResultFilter.OnResultExecutionAsync),
@ -961,7 +961,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var filter = (TFilter)state;
var resultExecutingContext = _resultExecutingContext;
_diagnosticSource.BeforeOnResultExecuting(resultExecutingContext, filter);
_diagnosticListener.BeforeOnResultExecuting(resultExecutingContext, filter);
_logger.BeforeExecutingMethodOnFilter(
resultFilterKind,
nameof(IResultFilter.OnResultExecuting),
@ -969,7 +969,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
filter.OnResultExecuting(resultExecutingContext);
_diagnosticSource.AfterOnResultExecuting(resultExecutingContext, filter);
_diagnosticListener.AfterOnResultExecuting(resultExecutingContext, filter);
_logger.AfterExecutingMethodOnFilter(
resultFilterKind,
nameof(IResultFilter.OnResultExecuting),
@ -1011,7 +1011,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
var filter = (TFilter)state;
var resultExecutedContext = _resultExecutedContext;
_diagnosticSource.BeforeOnResultExecuted(resultExecutedContext, filter);
_diagnosticListener.BeforeOnResultExecuted(resultExecutedContext, filter);
_logger.BeforeExecutingMethodOnFilter(
resultFilterKind,
nameof(IResultFilter.OnResultExecuted),
@ -1019,7 +1019,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
filter.OnResultExecuted(resultExecutedContext);
_diagnosticSource.AfterOnResultExecuted(resultExecutedContext, filter);
_diagnosticListener.AfterOnResultExecuted(resultExecutedContext, filter);
_logger.AfterExecutingMethodOnFilter(
resultFilterKind,
nameof(IResultFilter.OnResultExecuted),

View File

@ -16,55 +16,82 @@ namespace Microsoft.AspNetCore.Mvc
internal static class MvcCoreDiagnosticSourceExtensions
{
public static void BeforeAction(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionDescriptor actionDescriptor,
HttpContext httpContext,
RouteData routeData)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionDescriptor != null);
Debug.Assert(httpContext != null);
Debug.Assert(routeData != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeAction"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeActionImpl(diagnosticListener, actionDescriptor, httpContext, routeData);
}
}
private static void BeforeActionImpl(DiagnosticListener diagnosticListener, ActionDescriptor actionDescriptor, HttpContext httpContext, RouteData routeData)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeAction"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeAction",
new { actionDescriptor, httpContext = httpContext, routeData = routeData });
}
}
public static void AfterAction(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionDescriptor actionDescriptor,
HttpContext httpContext,
RouteData routeData)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionDescriptor != null);
Debug.Assert(httpContext != null);
Debug.Assert(routeData != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterAction"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterActionImpl(diagnosticListener, actionDescriptor, httpContext, routeData);
}
}
private static void AfterActionImpl(DiagnosticListener diagnosticListener, ActionDescriptor actionDescriptor, HttpContext httpContext, RouteData routeData)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterAction"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterAction",
new { actionDescriptor, httpContext = httpContext, routeData = routeData });
}
}
public static void BeforeOnAuthorizationAsync(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
AuthorizationFilterContext authorizationContext,
IAsyncAuthorizationFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(authorizationContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnAuthorization"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnAuthorizationAsyncImpl(diagnosticListener, authorizationContext, filter);
}
}
private static void BeforeOnAuthorizationAsyncImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAsyncAuthorizationFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnAuthorization"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnAuthorization",
new
{
@ -76,17 +103,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterOnAuthorizationAsync(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
AuthorizationFilterContext authorizationContext,
IAsyncAuthorizationFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(authorizationContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnAuthorization"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnAuthorizationAsyncImpl(diagnosticListener, authorizationContext, filter);
}
}
private static void AfterOnAuthorizationAsyncImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAsyncAuthorizationFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnAuthorization"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnAuthorization",
new
{
@ -98,17 +134,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeOnAuthorization(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
AuthorizationFilterContext authorizationContext,
IAuthorizationFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(authorizationContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnAuthorization"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnAuthorizationImpl(diagnosticListener, authorizationContext, filter);
}
}
private static void BeforeOnAuthorizationImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAuthorizationFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnAuthorization"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnAuthorization",
new
{
@ -120,17 +165,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterOnAuthorization(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
AuthorizationFilterContext authorizationContext,
IAuthorizationFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(authorizationContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnAuthorization"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnAuthorizationImpl(diagnosticListener, authorizationContext, filter);
}
}
private static void AfterOnAuthorizationImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAuthorizationFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnAuthorization"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnAuthorization",
new
{
@ -142,17 +196,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeOnResourceExecution(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ResourceExecutingContext resourceExecutingContext,
IAsyncResourceFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(resourceExecutingContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecution"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnResourceExecutionImpl(diagnosticListener, resourceExecutingContext, filter);
}
}
private static void BeforeOnResourceExecutionImpl(DiagnosticListener diagnosticListener, ResourceExecutingContext resourceExecutingContext, IAsyncResourceFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecution"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnResourceExecution",
new
{
@ -164,17 +227,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterOnResourceExecution(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ResourceExecutedContext resourceExecutedContext,
IAsyncResourceFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(resourceExecutedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecution"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnResourceExecutionImpl(diagnosticListener, resourceExecutedContext, filter);
}
}
private static void AfterOnResourceExecutionImpl(DiagnosticListener diagnosticListener, ResourceExecutedContext resourceExecutedContext, IAsyncResourceFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecution"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnResourceExecution",
new
{
@ -186,17 +258,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeOnResourceExecuting(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ResourceExecutingContext resourceExecutingContext,
IResourceFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(resourceExecutingContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuting"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnResourceExecutingImpl(diagnosticListener, resourceExecutingContext, filter);
}
}
private static void BeforeOnResourceExecutingImpl(DiagnosticListener diagnosticListener, ResourceExecutingContext resourceExecutingContext, IResourceFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuting"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuting",
new
{
@ -208,17 +289,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterOnResourceExecuting(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ResourceExecutingContext resourceExecutingContext,
IResourceFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(resourceExecutingContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecuting"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnResourceExecutingImpl(diagnosticListener, resourceExecutingContext, filter);
}
}
private static void AfterOnResourceExecutingImpl(DiagnosticListener diagnosticListener, ResourceExecutingContext resourceExecutingContext, IResourceFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecuting"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnResourceExecuting",
new
{
@ -230,17 +320,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeOnResourceExecuted(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ResourceExecutedContext resourceExecutedContext,
IResourceFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(resourceExecutedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuted"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnResourceExecutedImpl(diagnosticListener, resourceExecutedContext, filter);
}
}
private static void BeforeOnResourceExecutedImpl(DiagnosticListener diagnosticListener, ResourceExecutedContext resourceExecutedContext, IResourceFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuted"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuted",
new
{
@ -252,17 +351,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterOnResourceExecuted(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ResourceExecutedContext resourceExecutedContext,
IResourceFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(resourceExecutedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecuted"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnResourceExecutedImpl(diagnosticListener, resourceExecutedContext, filter);
}
}
private static void AfterOnResourceExecutedImpl(DiagnosticListener diagnosticListener, ResourceExecutedContext resourceExecutedContext, IResourceFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecuted"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnResourceExecuted",
new
{
@ -274,17 +382,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeOnExceptionAsync(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ExceptionContext exceptionContext,
IAsyncExceptionFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(exceptionContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnException"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnExceptionAsyncImpl(diagnosticListener, exceptionContext, filter);
}
}
private static void BeforeOnExceptionAsyncImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IAsyncExceptionFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnException"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnException",
new
{
@ -296,17 +413,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterOnExceptionAsync(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ExceptionContext exceptionContext,
IAsyncExceptionFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(exceptionContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnException"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnExceptionAsyncImpl(diagnosticListener, exceptionContext, filter);
}
}
private static void AfterOnExceptionAsyncImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IAsyncExceptionFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnException"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnException",
new
{
@ -318,17 +444,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeOnException(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ExceptionContext exceptionContext,
IExceptionFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(exceptionContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnException"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnExceptionImpl(diagnosticListener, exceptionContext, filter);
}
}
private static void BeforeOnExceptionImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IExceptionFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnException"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnException",
new
{
@ -340,17 +475,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterOnException(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ExceptionContext exceptionContext,
IExceptionFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(exceptionContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnException"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnExceptionImpl(diagnosticListener, exceptionContext, filter);
}
}
private static void AfterOnExceptionImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IExceptionFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnException"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnException",
new
{
@ -362,17 +506,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeOnActionExecution(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionExecutingContext actionExecutingContext,
IAsyncActionFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionExecutingContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecution"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnActionExecutionImpl(diagnosticListener, actionExecutingContext, filter);
}
}
private static void BeforeOnActionExecutionImpl(DiagnosticListener diagnosticListener, ActionExecutingContext actionExecutingContext, IAsyncActionFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecution"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnActionExecution",
new
{
@ -384,17 +537,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterOnActionExecution(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionExecutedContext actionExecutedContext,
IAsyncActionFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionExecutedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecution"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnActionExecutionImpl(diagnosticListener, actionExecutedContext, filter);
}
}
private static void AfterOnActionExecutionImpl(DiagnosticListener diagnosticListener, ActionExecutedContext actionExecutedContext, IAsyncActionFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecution"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnActionExecution",
new
{
@ -406,17 +568,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeOnActionExecuting(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionExecutingContext actionExecutingContext,
IActionFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionExecutingContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecuting"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnActionExecutingImpl(diagnosticListener, actionExecutingContext, filter);
}
}
private static void BeforeOnActionExecutingImpl(DiagnosticListener diagnosticListener, ActionExecutingContext actionExecutingContext, IActionFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecuting"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnActionExecuting",
new
{
@ -428,17 +599,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterOnActionExecuting(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionExecutingContext actionExecutingContext,
IActionFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionExecutingContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecuting"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnActionExecutingImpl(diagnosticListener, actionExecutingContext, filter);
}
}
private static void AfterOnActionExecutingImpl(DiagnosticListener diagnosticListener, ActionExecutingContext actionExecutingContext, IActionFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecuting"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnActionExecuting",
new
{
@ -450,17 +630,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeOnActionExecuted(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionExecutedContext actionExecutedContext,
IActionFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionExecutedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecuted"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnActionExecutedImpl(diagnosticListener, actionExecutedContext, filter);
}
}
private static void BeforeOnActionExecutedImpl(DiagnosticListener diagnosticListener, ActionExecutedContext actionExecutedContext, IActionFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecuted"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnActionExecuted",
new
{
@ -472,17 +661,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterOnActionExecuted(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionExecutedContext actionExecutedContext,
IActionFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionExecutedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecuted"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnActionExecutedImpl(diagnosticListener, actionExecutedContext, filter);
}
}
private static void AfterOnActionExecutedImpl(DiagnosticListener diagnosticListener, ActionExecutedContext actionExecutedContext, IActionFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecuted"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnActionExecuted",
new
{
@ -494,19 +692,28 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeActionMethod(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionContext actionContext,
IDictionary<string, object> actionArguments,
object controller)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionContext != null);
Debug.Assert(actionArguments != null);
Debug.Assert(controller != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeActionMethod"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeActionMethodImpl(diagnosticListener, actionContext, actionArguments, controller);
}
}
private static void BeforeActionMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IDictionary<string, object> actionArguments, object controller)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeActionMethod"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeActionMethod",
new
{
@ -518,20 +725,29 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterActionMethod(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionContext actionContext,
IDictionary<string, object> actionArguments,
object controller,
IActionResult result)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionContext != null);
Debug.Assert(actionArguments != null);
Debug.Assert(controller != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterActionMethod"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterActionMethodImpl(diagnosticListener, actionContext, actionArguments, controller, result);
}
}
private static void AfterActionMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IDictionary<string, object> actionArguments, object controller, IActionResult result)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterActionMethod"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterActionMethod",
new
{
@ -544,17 +760,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeOnResultExecution(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ResultExecutingContext resultExecutingContext,
IAsyncResultFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(resultExecutingContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecution"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnResultExecutionImpl(diagnosticListener, resultExecutingContext, filter);
}
}
private static void BeforeOnResultExecutionImpl(DiagnosticListener diagnosticListener, ResultExecutingContext resultExecutingContext, IAsyncResultFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecution"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnResultExecution",
new
{
@ -566,17 +791,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterOnResultExecution(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ResultExecutedContext resultExecutedContext,
IAsyncResultFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(resultExecutedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecution"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnResultExecutionImpl(diagnosticListener, resultExecutedContext, filter);
}
}
private static void AfterOnResultExecutionImpl(DiagnosticListener diagnosticListener, ResultExecutedContext resultExecutedContext, IAsyncResultFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecution"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnResultExecution",
new
{
@ -588,17 +822,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeOnResultExecuting(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ResultExecutingContext resultExecutingContext,
IResultFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(resultExecutingContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecuting"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnResultExecutingImpl(diagnosticListener, resultExecutingContext, filter);
}
}
private static void BeforeOnResultExecutingImpl(DiagnosticListener diagnosticListener, ResultExecutingContext resultExecutingContext, IResultFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecuting"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnResultExecuting",
new
{
@ -610,17 +853,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterOnResultExecuting(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ResultExecutingContext resultExecutingContext,
IResultFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(resultExecutingContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecuting"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnResultExecutingImpl(diagnosticListener, resultExecutingContext, filter);
}
}
private static void AfterOnResultExecutingImpl(DiagnosticListener diagnosticListener, ResultExecutingContext resultExecutingContext, IResultFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecuting"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnResultExecuting",
new
{
@ -632,17 +884,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeOnResultExecuted(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ResultExecutedContext resultExecutedContext,
IResultFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(resultExecutedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecuted"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnResultExecutedImpl(diagnosticListener, resultExecutedContext, filter);
}
}
private static void BeforeOnResultExecutedImpl(DiagnosticListener diagnosticListener, ResultExecutedContext resultExecutedContext, IResultFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecuted"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnResultExecuted",
new
{
@ -654,17 +915,26 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void AfterOnResultExecuted(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ResultExecutedContext resultExecutedContext,
IResultFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(resultExecutedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecuted"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnResultExecutedImpl(diagnosticListener, resultExecutedContext, filter);
}
}
private static void AfterOnResultExecutedImpl(DiagnosticListener diagnosticListener, ResultExecutedContext resultExecutedContext, IResultFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecuted"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnResultExecuted",
new
{
@ -676,34 +946,52 @@ namespace Microsoft.AspNetCore.Mvc
}
public static void BeforeActionResult(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionContext actionContext,
IActionResult result)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionContext != null);
Debug.Assert(result != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeActionResult"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeActionResultImpl(diagnosticListener, actionContext, result);
}
}
private static void BeforeActionResultImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IActionResult result)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeActionResult"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeActionResult",
new { actionContext = actionContext, result = result });
}
}
public static void AfterActionResult(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionContext actionContext,
IActionResult result)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionContext != null);
Debug.Assert(result != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterActionResult"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterActionResultImpl(diagnosticListener, actionContext, result);
}
}
private static void AfterActionResultImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IActionResult result)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterActionResult"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterActionResult",
new { actionContext = actionContext, result = result });
}

View File

@ -18,21 +18,21 @@ namespace Microsoft.AspNetCore.Mvc.Routing
private readonly IActionInvokerFactory _actionInvokerFactory;
private readonly IActionSelector _actionSelector;
private readonly ILogger _logger;
private DiagnosticSource _diagnosticSource;
private DiagnosticListener _diagnosticListener;
public MvcAttributeRouteHandler(
IActionInvokerFactory actionInvokerFactory,
IActionSelector actionSelector,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
ILoggerFactory loggerFactory)
: this(actionInvokerFactory, actionSelector, diagnosticSource, loggerFactory, actionContextAccessor: null)
: this(actionInvokerFactory, actionSelector, diagnosticListener, loggerFactory, actionContextAccessor: null)
{
}
public MvcAttributeRouteHandler(
IActionInvokerFactory actionInvokerFactory,
IActionSelector actionSelector,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
ILoggerFactory loggerFactory,
IActionContextAccessor actionContextAccessor)
{
@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Mvc.Routing
_actionInvokerFactory = actionInvokerFactory;
_actionSelector = actionSelector;
_diagnosticSource = diagnosticSource;
_diagnosticListener = diagnosticListener;
_logger = loggerFactory.CreateLogger<MvcAttributeRouteHandler>();
}

View File

@ -17,21 +17,21 @@ namespace Microsoft.AspNetCore.Mvc.Routing
private readonly IActionInvokerFactory _actionInvokerFactory;
private readonly IActionSelector _actionSelector;
private readonly ILogger _logger;
private readonly DiagnosticSource _diagnosticSource;
private readonly DiagnosticListener _diagnosticListener;
public MvcRouteHandler(
IActionInvokerFactory actionInvokerFactory,
IActionSelector actionSelector,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
ILoggerFactory loggerFactory)
: this(actionInvokerFactory, actionSelector, diagnosticSource, loggerFactory, actionContextAccessor: null)
: this(actionInvokerFactory, actionSelector, diagnosticListener, loggerFactory, actionContextAccessor: null)
{
}
public MvcRouteHandler(
IActionInvokerFactory actionInvokerFactory,
IActionSelector actionSelector,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
ILoggerFactory loggerFactory,
IActionContextAccessor actionContextAccessor)
{
@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Mvc.Routing
_actionInvokerFactory = actionInvokerFactory;
_actionSelector = actionSelector;
_diagnosticSource = diagnosticSource;
_diagnosticListener = diagnosticListener;
_logger = loggerFactory.CreateLogger<MvcRouteHandler>();
}

View File

@ -174,9 +174,9 @@ namespace Microsoft.Extensions.DependencyInjection
var optionsAccessor = s.GetRequiredService<IOptions<RazorViewEngineOptions>>();
var razorFileSystem = s.GetRequiredService<RazorProjectFileSystem>();
var loggerFactory = s.GetRequiredService<ILoggerFactory>();
var diagnosticSource = s.GetRequiredService<DiagnosticSource>();
var diagnosticListener = s.GetRequiredService<DiagnosticListener>();
var viewEngine = new RazorViewEngine(pageFactory, pageActivator, htmlEncoder, optionsAccessor, razorFileSystem, loggerFactory, diagnosticSource);
var viewEngine = new RazorViewEngine(pageFactory, pageActivator, htmlEncoder, optionsAccessor, razorFileSystem, loggerFactory, diagnosticListener);
return viewEngine;
});
services.TryAddSingleton<IViewCompilerProvider, RazorViewCompilerProvider>();

View File

@ -9,13 +9,25 @@ namespace Microsoft.AspNetCore.Mvc.Razor
internal static class MvcRazorDiagnosticSourceExtensions
{
public static void BeforeViewPage(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
IRazorPage page,
ViewContext viewContext)
{
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.Razor.BeforeViewPage"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeViewPageImpl(diagnosticListener, page, viewContext);
}
}
private static void BeforeViewPageImpl(
this DiagnosticListener diagnosticListener,
IRazorPage page,
ViewContext viewContext)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.Razor.BeforeViewPage"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.Razor.BeforeViewPage",
new
{
@ -28,13 +40,25 @@ namespace Microsoft.AspNetCore.Mvc.Razor
}
public static void AfterViewPage(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
IRazorPage page,
ViewContext viewContext)
{
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.Razor.AfterViewPage"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterViewPageImpl(diagnosticListener, page, viewContext);
}
}
private static void AfterViewPageImpl(
this DiagnosticListener diagnosticListener,
IRazorPage page,
ViewContext viewContext)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.Razor.AfterViewPage"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.Razor.AfterViewPage",
new
{

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
private readonly IRazorViewEngine _viewEngine;
private readonly IRazorPageActivator _pageActivator;
private readonly HtmlEncoder _htmlEncoder;
private readonly DiagnosticSource _diagnosticSource;
private readonly DiagnosticListener _diagnosticListener;
private IViewBufferScope _bufferScope;
/// <summary>
@ -35,14 +35,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor
/// </param>
/// <param name="razorPage">The <see cref="IRazorPage"/> instance to execute.</param>
/// <param name="htmlEncoder">The HTML encoder.</param>
/// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
/// <param name="diagnosticListener">The <see cref="DiagnosticListener"/>.</param>
public RazorView(
IRazorViewEngine viewEngine,
IRazorPageActivator pageActivator,
IReadOnlyList<IRazorPage> viewStartPages,
IRazorPage razorPage,
HtmlEncoder htmlEncoder,
DiagnosticSource diagnosticSource)
DiagnosticListener diagnosticListener)
{
if (viewEngine == null)
{
@ -69,9 +69,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor
throw new ArgumentNullException(nameof(htmlEncoder));
}
if (diagnosticSource == null)
if (diagnosticListener == null)
{
throw new ArgumentNullException(nameof(diagnosticSource));
throw new ArgumentNullException(nameof(diagnosticListener));
}
_viewEngine = viewEngine;
@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
ViewStartPages = viewStartPages;
RazorPage = razorPage;
_htmlEncoder = htmlEncoder;
_diagnosticSource = diagnosticSource;
_diagnosticListener = diagnosticListener;
}
/// <inheritdoc />
@ -170,7 +170,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
OnAfterPageActivated?.Invoke(page, context);
_diagnosticSource.BeforeViewPage(page, context);
_diagnosticListener.BeforeViewPage(page, context);
try
{
@ -178,7 +178,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
}
finally
{
_diagnosticSource.AfterViewPage(page, context);
_diagnosticListener.AfterViewPage(page, context);
}
}

View File

@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
private readonly ILogger _logger;
private readonly RazorViewEngineOptions _options;
private readonly RazorProject _razorFileSystem;
private readonly DiagnosticSource _diagnosticSource;
private readonly DiagnosticListener _diagnosticListener;
/// <summary>
/// Initializes a new instance of the <see cref="RazorViewEngine" />.
@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
IOptions<RazorViewEngineOptions> optionsAccessor,
RazorProject razorProject,
ILoggerFactory loggerFactory,
DiagnosticSource diagnosticSource)
DiagnosticListener diagnosticListener)
{
_options = optionsAccessor.Value;
@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
_htmlEncoder = htmlEncoder;
_logger = loggerFactory.CreateLogger<RazorViewEngine>();
_razorFileSystem = razorProject;
_diagnosticSource = diagnosticSource;
_diagnosticListener = diagnosticListener;
ViewLookupCache = new MemoryCache(new MemoryCacheOptions());
}
@ -93,9 +93,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor
IOptions<RazorViewEngineOptions> optionsAccessor,
RazorProjectFileSystem razorFileSystem,
ILoggerFactory loggerFactory,
DiagnosticSource diagnosticSource)
DiagnosticListener diagnosticListener)
#pragma warning disable CS0618 // Type or member is obsolete
: this (pageFactory, pageActivator, htmlEncoder, optionsAccessor, (RazorProject)razorFileSystem, loggerFactory, diagnosticSource)
: this (pageFactory, pageActivator, htmlEncoder, optionsAccessor, (RazorProject)razorFileSystem, loggerFactory, diagnosticListener)
#pragma warning restore CS0618 // Type or member is obsolete
{
}
@ -498,7 +498,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
viewStarts[i] = viewStartItem.PageFactory();
}
var view = new RazorView(this, _pageActivator, viewStarts, page, _htmlEncoder, _diagnosticSource);
var view = new RazorView(this, _pageActivator, viewStarts, page, _htmlEncoder, _diagnosticListener);
return ViewEngineResult.Found(viewName, view);
}

View File

@ -0,0 +1,17 @@
[
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine : Microsoft.AspNetCore.Mvc.Razor.IRazorViewEngine",
"MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.Razor.IRazorPageFactoryProvider pageFactory, Microsoft.AspNetCore.Mvc.Razor.IRazorPageActivator pageActivator, System.Text.Encodings.Web.HtmlEncoder htmlEncoder, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions> optionsAccessor, Microsoft.AspNetCore.Razor.Language.RazorProject razorProject, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Diagnostics.DiagnosticSource diagnosticSource)",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine : Microsoft.AspNetCore.Mvc.Razor.IRazorViewEngine",
"MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.Razor.IRazorPageFactoryProvider pageFactory, Microsoft.AspNetCore.Mvc.Razor.IRazorPageActivator pageActivator, System.Text.Encodings.Web.HtmlEncoder htmlEncoder, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions> optionsAccessor, Microsoft.AspNetCore.Razor.Language.RazorProjectFileSystem razorFileSystem, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Diagnostics.DiagnosticSource diagnosticSource)",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.Razor.RazorView : Microsoft.AspNetCore.Mvc.ViewEngines.IView",
"MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.Razor.IRazorViewEngine viewEngine, Microsoft.AspNetCore.Mvc.Razor.IRazorPageActivator pageActivator, System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Mvc.Razor.IRazorPage> viewStartPages, Microsoft.AspNetCore.Mvc.Razor.IRazorPage razorPage, System.Text.Encodings.Web.HtmlEncoder htmlEncoder, System.Diagnostics.DiagnosticSource diagnosticSource)",
"Kind": "Removal"
}
]

View File

@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
IModelMetadataProvider metadataProvider,
IUrlHelperFactory urlHelperFactory,
IJsonHelper jsonHelper,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
HtmlEncoder htmlEncoder,
IModelExpressionProvider modelExpressionProvider)
{
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
{
UrlHelperAccessor = context => urlHelperFactory.GetUrlHelper(context),
JsonHelperAccessor = context => jsonHelper,
DiagnosticSourceAccessor = context => diagnosticSource,
DiagnosticSourceAccessor = context => diagnosticListener,
HtmlEncoderAccessor = context => htmlEncoder,
ModelExpressionProviderAccessor = context => modelExpressionProvider,
};

View File

@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
public PageActionInvoker(
IPageHandlerMethodSelector handlerMethodSelector,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
ILogger logger,
IActionResultTypeMapper mapper,
PageContext pageContext,
@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
ITempDataDictionaryFactory tempDataFactory,
HtmlHelperOptions htmlHelperOptions)
: base(
diagnosticSource,
diagnosticListener,
logger,
mapper,
pageContext,
@ -255,7 +255,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
Debug.Assert(executor != null, "We should always find a executor for a handler");
_diagnosticSource.BeforeHandlerMethod(_pageContext, handler, _arguments, _instance);
_diagnosticListener.BeforeHandlerMethod(_pageContext, handler, _arguments, _instance);
_logger.ExecutingHandlerMethod(_pageContext, handler, arguments);
try
@ -265,7 +265,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
}
finally
{
_diagnosticSource.AfterHandlerMethod(_pageContext, handler, _arguments, _instance, _result);
_diagnosticListener.AfterHandlerMethod(_pageContext, handler, _arguments, _instance, _result);
}
}
@ -347,7 +347,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
var filter = (IAsyncPageFilter)state;
var handlerSelectedContext = _handlerSelectedContext;
_diagnosticSource.BeforeOnPageHandlerSelection(handlerSelectedContext, filter);
_diagnosticListener.BeforeOnPageHandlerSelection(handlerSelectedContext, filter);
_logger.BeforeExecutingMethodOnFilter(
PageLoggerExtensions.PageFilter,
nameof(IAsyncPageFilter.OnPageHandlerSelectionAsync),
@ -370,7 +370,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
var filter = (IAsyncPageFilter)state;
_diagnosticSource.AfterOnPageHandlerSelection(_handlerSelectedContext, filter);
_diagnosticListener.AfterOnPageHandlerSelection(_handlerSelectedContext, filter);
_logger.AfterExecutingMethodOnFilter(
PageLoggerExtensions.PageFilter,
nameof(IAsyncPageFilter.OnPageHandlerSelectionAsync),
@ -387,7 +387,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
var filter = (IPageFilter)state;
var handlerSelectedContext = _handlerSelectedContext;
_diagnosticSource.BeforeOnPageHandlerSelected(handlerSelectedContext, filter);
_diagnosticListener.BeforeOnPageHandlerSelected(handlerSelectedContext, filter);
_logger.BeforeExecutingMethodOnFilter(
PageLoggerExtensions.PageFilter,
nameof(IPageFilter.OnPageHandlerSelected),
@ -395,7 +395,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
filter.OnPageHandlerSelected(handlerSelectedContext);
_diagnosticSource.AfterOnPageHandlerSelected(handlerSelectedContext, filter);
_diagnosticListener.AfterOnPageHandlerSelected(handlerSelectedContext, filter);
goto case State.PageSelectHandlerNext;
}
@ -458,7 +458,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
var filter = (IAsyncPageFilter)state;
var handlerExecutingContext = _handlerExecutingContext;
_diagnosticSource.BeforeOnPageHandlerExecution(handlerExecutingContext, filter);
_diagnosticListener.BeforeOnPageHandlerExecution(handlerExecutingContext, filter);
_logger.BeforeExecutingMethodOnFilter(
PageLoggerExtensions.PageFilter,
nameof(IAsyncPageFilter.OnPageHandlerExecutionAsync),
@ -497,7 +497,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
};
}
_diagnosticSource.AfterOnPageHandlerExecution(_handlerExecutedContext, filter);
_diagnosticListener.AfterOnPageHandlerExecution(_handlerExecutedContext, filter);
_logger.AfterExecutingMethodOnFilter(
PageLoggerExtensions.PageFilter,
nameof(IAsyncPageFilter.OnPageHandlerExecutionAsync),
@ -514,7 +514,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
var filter = (IPageFilter)state;
var handlerExecutingContext = _handlerExecutingContext;
_diagnosticSource.BeforeOnPageHandlerExecuting(handlerExecutingContext, filter);
_diagnosticListener.BeforeOnPageHandlerExecuting(handlerExecutingContext, filter);
_logger.BeforeExecutingMethodOnFilter(
PageLoggerExtensions.PageFilter,
nameof(IPageFilter.OnPageHandlerExecuting),
@ -522,7 +522,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
filter.OnPageHandlerExecuting(handlerExecutingContext);
_diagnosticSource.AfterOnPageHandlerExecuting(handlerExecutingContext, filter);
_diagnosticListener.AfterOnPageHandlerExecuting(handlerExecutingContext, filter);
_logger.AfterExecutingMethodOnFilter(
PageLoggerExtensions.PageFilter,
nameof(IPageFilter.OnPageHandlerExecuting),
@ -565,7 +565,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
var filter = (IPageFilter)state;
var handlerExecutedContext = _handlerExecutedContext;
_diagnosticSource.BeforeOnPageHandlerExecuted(handlerExecutedContext, filter);
_diagnosticListener.BeforeOnPageHandlerExecuted(handlerExecutedContext, filter);
_logger.BeforeExecutingMethodOnFilter(
PageLoggerExtensions.PageFilter,
nameof(IPageFilter.OnPageHandlerExecuted),
@ -573,7 +573,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
filter.OnPageHandlerExecuted(handlerExecutedContext);
_diagnosticSource.AfterOnPageHandlerExecuted(handlerExecutedContext, filter);
_diagnosticListener.AfterOnPageHandlerExecuted(handlerExecutedContext, filter);
_logger.AfterExecutingMethodOnFilter(
PageLoggerExtensions.PageFilter,
nameof(IPageFilter.OnPageHandlerExecuted),

View File

@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
private readonly HtmlHelperOptions _htmlHelperOptions;
private readonly IPageHandlerMethodSelector _selector;
private readonly RazorProjectFileSystem _razorFileSystem;
private readonly DiagnosticSource _diagnosticSource;
private readonly DiagnosticListener _diagnosticListener;
private readonly ILogger<PageActionInvoker> _logger;
private readonly IActionResultTypeMapper _mapper;
private volatile InnerCache _currentCache;
@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
IOptions<HtmlHelperOptions> htmlHelperOptions,
IPageHandlerMethodSelector selector,
RazorProjectFileSystem razorFileSystem,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
ILoggerFactory loggerFactory,
IActionResultTypeMapper mapper)
{
@ -76,7 +76,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
_htmlHelperOptions = htmlHelperOptions.Value;
_selector = selector;
_razorFileSystem = razorFileSystem;
_diagnosticSource = diagnosticSource;
_diagnosticListener = diagnosticListener;
_logger = loggerFactory.CreateLogger<PageActionInvoker>();
_mapper = mapper;
}
@ -156,7 +156,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
return new PageActionInvoker(
_selector,
_diagnosticSource,
_diagnosticListener,
_logger,
_mapper,
pageContext,

View File

@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
{
private readonly IRazorViewEngine _razorViewEngine;
private readonly IRazorPageActivator _razorPageActivator;
private readonly DiagnosticSource _diagnosticSource;
private readonly DiagnosticListener _diagnosticListener;
private readonly HtmlEncoder _htmlEncoder;
/// <summary>
@ -30,21 +30,21 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
/// <param name="compositeViewEngine">The <see cref="ICompositeViewEngine"/>.</param>
/// <param name="razorViewEngine">The <see cref="IRazorViewEngine"/>.</param>
/// <param name="razorPageActivator">The <see cref="IRazorPageActivator"/>.</param>
/// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
/// <param name="diagnosticListener">The <see cref="DiagnosticListener"/>.</param>
/// <param name="htmlEncoder">The <see cref="HtmlEncoder"/>.</param>
public PageResultExecutor(
IHttpResponseStreamWriterFactory writerFactory,
ICompositeViewEngine compositeViewEngine,
IRazorViewEngine razorViewEngine,
IRazorPageActivator razorPageActivator,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
HtmlEncoder htmlEncoder)
: base(writerFactory, compositeViewEngine, diagnosticSource)
: base(writerFactory, compositeViewEngine, diagnosticListener)
{
_razorViewEngine = razorViewEngine;
_htmlEncoder = htmlEncoder;
_razorPageActivator = razorPageActivator;
_diagnosticSource = diagnosticSource;
_diagnosticListener = diagnosticListener;
}
/// <summary>
@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
viewStarts,
pageAdapter,
_htmlEncoder,
_diagnosticSource)
_diagnosticListener)
{
OnAfterPageActivated = (page, currentViewContext) =>
{

View File

@ -11,21 +11,30 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
internal static class MvcRazorPagesDiagnosticSourceExtensions
{
public static void BeforeHandlerMethod(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionContext actionContext,
HandlerMethodDescriptor handlerMethodDescriptor,
IDictionary<string, object> arguments,
object instance)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionContext != null);
Debug.Assert(handlerMethodDescriptor != null);
Debug.Assert(arguments != null);
Debug.Assert(instance != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeHandlerMethod"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeHandlerMethodImpl(diagnosticListener, actionContext, handlerMethodDescriptor, arguments, instance);
}
}
private static void BeforeHandlerMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, IDictionary<string, object> arguments, object instance)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeHandlerMethod"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeHandlerMethod",
new
{
@ -38,22 +47,31 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
}
public static void AfterHandlerMethod(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionContext actionContext,
HandlerMethodDescriptor handlerMethodDescriptor,
IDictionary<string, object> arguments,
object instance,
IActionResult result)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(actionContext != null);
Debug.Assert(handlerMethodDescriptor != null);
Debug.Assert(arguments != null);
Debug.Assert(instance != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterHandlerMethod"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterHandlerMethodImpl(diagnosticListener, actionContext, handlerMethodDescriptor, arguments, instance, result);
}
}
private static void AfterHandlerMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, IDictionary<string, object> arguments, object instance, IActionResult result)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterHandlerMethod"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterHandlerMethod",
new
{
@ -65,19 +83,28 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
});
}
}
public static void BeforeOnPageHandlerExecution(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
PageHandlerExecutingContext handlerExecutionContext,
IAsyncPageFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(handlerExecutionContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecution"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnPageHandlerExecutionImpl(diagnosticListener, handlerExecutionContext, filter);
}
}
private static void BeforeOnPageHandlerExecutionImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutionContext, IAsyncPageFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecution"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecution",
new
{
@ -89,17 +116,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
}
public static void AfterOnPageHandlerExecution(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
PageHandlerExecutedContext handlerExecutedContext,
IAsyncPageFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(handlerExecutedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecution"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnPageHandlerExecutionImpl(diagnosticListener, handlerExecutedContext, filter);
}
}
private static void AfterOnPageHandlerExecutionImpl(DiagnosticListener diagnosticListener, PageHandlerExecutedContext handlerExecutedContext, IAsyncPageFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecution"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecution",
new
{
@ -111,17 +147,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
}
public static void BeforeOnPageHandlerExecuting(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
PageHandlerExecutingContext handlerExecutingContext,
IPageFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(handlerExecutingContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuting"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnPageHandlerExecutingImpl(diagnosticListener, handlerExecutingContext, filter);
}
}
private static void BeforeOnPageHandlerExecutingImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutingContext, IPageFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuting"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuting",
new
{
@ -133,17 +178,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
}
public static void AfterOnPageHandlerExecuting(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
PageHandlerExecutingContext handlerExecutingContext,
IPageFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(handlerExecutingContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuting"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnPageHandlerExecutingImpl(diagnosticListener, handlerExecutingContext, filter);
}
}
private static void AfterOnPageHandlerExecutingImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutingContext, IPageFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuting"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuting",
new
{
@ -155,17 +209,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
}
public static void BeforeOnPageHandlerExecuted(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
PageHandlerExecutedContext handlerExecutedContext,
IPageFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(handlerExecutedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuted"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnPageHandlerExecutedImpl(diagnosticListener, handlerExecutedContext, filter);
}
}
private static void BeforeOnPageHandlerExecutedImpl(DiagnosticListener diagnosticListener, PageHandlerExecutedContext handlerExecutedContext, IPageFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuted"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuted",
new
{
@ -177,17 +240,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
}
public static void AfterOnPageHandlerExecuted(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
PageHandlerExecutedContext handlerExecutedContext,
IPageFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(handlerExecutedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuted"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnPageHandlerExecutedImpl(diagnosticListener, handlerExecutedContext, filter);
}
}
private static void AfterOnPageHandlerExecutedImpl(DiagnosticListener diagnosticListener, PageHandlerExecutedContext handlerExecutedContext, IPageFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuted"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuted",
new
{
@ -199,17 +271,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
}
public static void BeforeOnPageHandlerSelection(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
PageHandlerSelectedContext handlerSelectedContext,
IAsyncPageFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(handlerSelectedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelection"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnPageHandlerSelectionImpl(diagnosticListener, handlerSelectedContext, filter);
}
}
private static void BeforeOnPageHandlerSelectionImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IAsyncPageFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelection"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelection",
new
{
@ -221,17 +302,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
}
public static void AfterOnPageHandlerSelection(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
PageHandlerSelectedContext handlerSelectedContext,
IAsyncPageFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(handlerSelectedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelection"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnPageHandlerSelectionImpl(diagnosticListener, handlerSelectedContext, filter);
}
}
private static void AfterOnPageHandlerSelectionImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IAsyncPageFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelection"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelection",
new
{
@ -243,17 +333,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
}
public static void BeforeOnPageHandlerSelected(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
PageHandlerSelectedContext handlerSelectedContext,
IPageFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(handlerSelectedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelected"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeOnPageHandlerSelectedImpl(diagnosticListener, handlerSelectedContext, filter);
}
}
private static void BeforeOnPageHandlerSelectedImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IPageFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelected"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelected",
new
{
@ -265,17 +364,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
}
public static void AfterOnPageHandlerSelected(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
PageHandlerSelectedContext handlerSelectedContext,
IPageFilter filter)
{
Debug.Assert(diagnosticSource != null);
Debug.Assert(diagnosticListener != null);
Debug.Assert(handlerSelectedContext != null);
Debug.Assert(filter != null);
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterOnPageHandlerSelectedImpl(diagnosticListener, handlerSelectedContext, filter);
}
}
private static void AfterOnPageHandlerSelectedImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IPageFilter filter)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected",
new
{

View File

@ -0,0 +1,12 @@
[
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageResultExecutor : Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor",
"MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine compositeViewEngine, Microsoft.AspNetCore.Mvc.Razor.IRazorViewEngine razorViewEngine, Microsoft.AspNetCore.Mvc.Razor.IRazorPageActivator razorPageActivator, System.Diagnostics.DiagnosticSource diagnosticSource, System.Text.Encodings.Web.HtmlEncoder htmlEncoder)",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DefaultPageFactoryProvider : Microsoft.AspNetCore.Mvc.RazorPages.IPageFactoryProvider",
"MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.RazorPages.IPageActivatorProvider pageActivator, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider metadataProvider, Microsoft.AspNetCore.Mvc.Routing.IUrlHelperFactory urlHelperFactory, Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper jsonHelper, System.Diagnostics.DiagnosticSource diagnosticSource, System.Text.Encodings.Web.HtmlEncoder htmlEncoder, Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider modelExpressionProvider)",
"Kind": "Removal"
}
]

View File

@ -12,13 +12,22 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
internal static class MvcViewFeaturesDiagnosticSourceExtensions
{
public static void BeforeViewComponent(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ViewComponentContext context,
object viewComponent)
{
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeViewComponent"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeViewComponentImpl(diagnosticListener, context, viewComponent);
}
}
private static void BeforeViewComponentImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, object viewComponent)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeViewComponent"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeViewComponent",
new
{
@ -30,14 +39,23 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
}
public static void AfterViewComponent(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ViewComponentContext context,
IViewComponentResult result,
object viewComponent)
{
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterViewComponent"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterViewComponentImpl(diagnosticListener, context, result, viewComponent);
}
}
private static void AfterViewComponentImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, IViewComponentResult result, object viewComponent)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterViewComponent"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterViewComponent",
new
{
@ -50,13 +68,22 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
}
public static void ViewComponentBeforeViewExecute(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ViewComponentContext context,
IView view)
{
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewComponentBeforeViewExecute"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
ViewComponentBeforeViewExecuteImpl(diagnosticListener, context, view);
}
}
private static void ViewComponentBeforeViewExecuteImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, IView view)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.ViewComponentBeforeViewExecute"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.ViewComponentBeforeViewExecute",
new
{
@ -68,13 +95,22 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
}
public static void ViewComponentAfterViewExecute(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ViewComponentContext context,
IView view)
{
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewComponentAfterViewExecute"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
ViewComponentAfterViewExecuteImpl(diagnosticListener, context, view);
}
}
private static void ViewComponentAfterViewExecuteImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, IView view)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.ViewComponentAfterViewExecute"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.ViewComponentAfterViewExecute",
new
{
@ -86,42 +122,69 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
}
public static void BeforeView(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
IView view,
ViewContext viewContext)
{
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeView"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
BeforeViewImpl(diagnosticListener, view, viewContext);
}
}
private static void BeforeViewImpl(DiagnosticListener diagnosticListener, IView view, ViewContext viewContext)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeView"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeView",
new { view = view, viewContext = viewContext, });
}
}
public static void AfterView(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
IView view,
ViewContext viewContext)
{
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterView"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
AfterViewImpl(diagnosticListener, view, viewContext);
}
}
private static void AfterViewImpl(DiagnosticListener diagnosticListener, IView view, ViewContext viewContext)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterView"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterView",
new { view = view, viewContext = viewContext, });
}
}
public static void ViewFound(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionContext actionContext,
bool isMainPage,
PartialViewResult viewResult,
string viewName,
IView view)
{
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewFound"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
ViewFoundImpl(diagnosticListener, actionContext, isMainPage, viewResult, viewName, view);
}
}
private static void ViewFoundImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, bool isMainPage, PartialViewResult viewResult, string viewName, IView view)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.ViewFound"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.ViewFound",
new
{
@ -135,16 +198,25 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
}
public static void ViewNotFound(
this DiagnosticSource diagnosticSource,
this DiagnosticListener diagnosticListener,
ActionContext actionContext,
bool isMainPage,
PartialViewResult viewResult,
string viewName,
IEnumerable<string> searchedLocations)
{
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewNotFound"))
// Inlinable fast-path check if Diagnositcs is enabled
if (diagnosticListener.IsEnabled())
{
diagnosticSource.Write(
ViewNotFoundImpl(diagnosticListener, actionContext, isMainPage, viewResult, viewName, searchedLocations);
}
}
private static void ViewNotFoundImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, bool isMainPage, PartialViewResult viewResult, string viewName, IEnumerable<string> searchedLocations)
{
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.ViewNotFound"))
{
diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.ViewNotFound",
new
{

View File

@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
/// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
/// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
/// <param name="tempDataFactory">The <see cref="ITempDataDictionaryFactory"/>.</param>
/// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
/// <param name="diagnosticListener">The <see cref="DiagnosticListener"/>.</param>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
/// <param name="modelMetadataProvider">The <see cref="IModelMetadataProvider"/>.</param>
public PartialViewResultExecutor(
@ -38,10 +38,10 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
IHttpResponseStreamWriterFactory writerFactory,
ICompositeViewEngine viewEngine,
ITempDataDictionaryFactory tempDataFactory,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
ILoggerFactory loggerFactory,
IModelMetadataProvider modelMetadataProvider)
: base(viewOptions, writerFactory, viewEngine, tempDataFactory, diagnosticSource, modelMetadataProvider)
: base(viewOptions, writerFactory, viewEngine, tempDataFactory, diagnosticListener, modelMetadataProvider)
{
if (loggerFactory == null)
{

View File

@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
{
private readonly IViewComponentFactory _viewComponentFactory;
private readonly ViewComponentInvokerCache _viewComponentInvokerCache;
private readonly DiagnosticSource _diagnosticSource;
private readonly DiagnosticListener _diagnosticListener;
private readonly ILogger _logger;
/// <summary>
@ -27,12 +27,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
/// </summary>
/// <param name="viewComponentFactory">The <see cref="IViewComponentFactory"/>.</param>
/// <param name="viewComponentInvokerCache">The <see cref="ViewComponentInvokerCache"/>.</param>
/// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
/// <param name="diagnosticListener">The <see cref="DiagnosticListener"/>.</param>
/// <param name="logger">The <see cref="ILogger"/>.</param>
public DefaultViewComponentInvoker(
IViewComponentFactory viewComponentFactory,
ViewComponentInvokerCache viewComponentInvokerCache,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
ILogger logger)
{
if (viewComponentFactory == null)
@ -45,9 +45,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
throw new ArgumentNullException(nameof(viewComponentInvokerCache));
}
if (diagnosticSource == null)
if (diagnosticListener == null)
{
throw new ArgumentNullException(nameof(diagnosticSource));
throw new ArgumentNullException(nameof(diagnosticListener));
}
if (logger == null)
@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
_viewComponentFactory = viewComponentFactory;
_viewComponentInvokerCache = viewComponentInvokerCache;
_diagnosticSource = diagnosticSource;
_diagnosticListener = diagnosticListener;
_logger = logger;
}
@ -101,7 +101,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
{
var arguments = PrepareArguments(context.Arguments, executor);
_diagnosticSource.BeforeViewComponent(context, component);
_diagnosticListener.BeforeViewComponent(context, component);
_logger.ViewComponentExecuting(context, arguments);
var stopwatch = ValueStopwatch.StartNew();
@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
var viewComponentResult = CoerceToViewComponentResult(resultAsObject);
_logger.ViewComponentExecuted(context, stopwatch.GetElapsedTime(), viewComponentResult);
_diagnosticSource.AfterViewComponent(context, viewComponentResult, component);
_diagnosticListener.AfterViewComponent(context, viewComponentResult, component);
_viewComponentFactory.ReleaseViewComponent(context, component);
@ -144,7 +144,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
{
var arguments = PrepareArguments(context.Arguments, executor);
_diagnosticSource.BeforeViewComponent(context, component);
_diagnosticListener.BeforeViewComponent(context, component);
_logger.ViewComponentExecuting(context, arguments);
var stopwatch = ValueStopwatch.StartNew();
@ -161,7 +161,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
var viewComponentResult = CoerceToViewComponentResult(result);
_logger.ViewComponentExecuted(context, stopwatch.GetElapsedTime(), viewComponentResult);
_diagnosticSource.AfterViewComponent(context, viewComponentResult, component);
_diagnosticListener.AfterViewComponent(context, viewComponentResult, component);
_viewComponentFactory.ReleaseViewComponent(context, component);

View File

@ -12,12 +12,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
private readonly IViewComponentFactory _viewComponentFactory;
private readonly ViewComponentInvokerCache _viewComponentInvokerCache;
private readonly ILogger _logger;
private readonly DiagnosticSource _diagnosticSource;
private readonly DiagnosticListener _diagnosticListener;
public DefaultViewComponentInvokerFactory(
IViewComponentFactory viewComponentFactory,
ViewComponentInvokerCache viewComponentInvokerCache,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
ILoggerFactory loggerFactory)
{
if (viewComponentFactory == null)
@ -30,9 +30,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
throw new ArgumentNullException(nameof(viewComponentInvokerCache));
}
if (diagnosticSource == null)
if (diagnosticListener == null)
{
throw new ArgumentNullException(nameof(diagnosticSource));
throw new ArgumentNullException(nameof(diagnosticListener));
}
if (loggerFactory == null)
@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
}
_viewComponentFactory = viewComponentFactory;
_diagnosticSource = diagnosticSource;
_diagnosticListener = diagnosticListener;
_viewComponentInvokerCache = viewComponentInvokerCache;
_logger = loggerFactory.CreateLogger<DefaultViewComponentInvoker>();
@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
return new DefaultViewComponentInvoker(
_viewComponentFactory,
_viewComponentInvokerCache,
_diagnosticSource,
_diagnosticListener,
_logger);
}
}

View File

@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
private const string ViewPathFormat = "Components/{0}/{1}";
private const string DefaultViewName = "Default";
private DiagnosticSource _diagnosticSource;
private DiagnosticListener _diagnosticListener;
/// <summary>
/// Gets or sets the view name.
@ -115,12 +115,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
var view = result.EnsureSuccessful(originalLocations).View;
using (view as IDisposable)
{
if (_diagnosticSource == null)
if (_diagnosticListener == null)
{
_diagnosticSource = viewContext.HttpContext.RequestServices.GetRequiredService<DiagnosticSource>();
_diagnosticListener = viewContext.HttpContext.RequestServices.GetRequiredService<DiagnosticListener>();
}
_diagnosticSource.ViewComponentBeforeViewExecute(context, view);
_diagnosticListener.ViewComponentBeforeViewExecute(context, view);
var childViewContext = new ViewContext(
viewContext,
@ -129,7 +129,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
context.Writer);
await view.RenderAsync(childViewContext);
_diagnosticSource.ViewComponentAfterViewExecute(context, view);
_diagnosticListener.ViewComponentAfterViewExecute(context, view);
}
}

View File

@ -32,16 +32,16 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
/// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
/// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
/// <param name="tempDataFactory">The <see cref="ITempDataDictionaryFactory"/>.</param>
/// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
/// <param name="diagnosticListener">The <see cref="DiagnosticSource"/>.</param>
/// <param name="modelMetadataProvider">The <see cref="IModelMetadataProvider" />.</param>
public ViewExecutor(
IOptions<MvcViewOptions> viewOptions,
IHttpResponseStreamWriterFactory writerFactory,
ICompositeViewEngine viewEngine,
ITempDataDictionaryFactory tempDataFactory,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
IModelMetadataProvider modelMetadataProvider)
: this(writerFactory, viewEngine, diagnosticSource)
: this(writerFactory, viewEngine, diagnosticListener)
{
if (viewOptions == null)
{
@ -53,9 +53,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
throw new ArgumentNullException(nameof(tempDataFactory));
}
if (diagnosticSource == null)
if (diagnosticListener == null)
{
throw new ArgumentNullException(nameof(diagnosticSource));
throw new ArgumentNullException(nameof(diagnosticListener));
}
ViewOptions = viewOptions.Value;
@ -68,11 +68,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
/// </summary>
/// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
/// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
/// <param name="diagnosticSource">The <see cref="System.Diagnostics.DiagnosticSource"/>.</param>
/// <param name="diagnosticListener">The <see cref="System.Diagnostics.DiagnosticListener"/>.</param>
protected ViewExecutor(
IHttpResponseStreamWriterFactory writerFactory,
ICompositeViewEngine viewEngine,
DiagnosticSource diagnosticSource)
DiagnosticListener diagnosticListener)
{
if (writerFactory == null)
{
@ -84,20 +84,20 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
throw new ArgumentNullException(nameof(viewEngine));
}
if (diagnosticSource == null)
if (diagnosticListener == null)
{
throw new ArgumentNullException(nameof(diagnosticSource));
throw new ArgumentNullException(nameof(diagnosticListener));
}
WriterFactory = writerFactory;
ViewEngine = viewEngine;
DiagnosticSource = diagnosticSource;
DiagnosticSource = diagnosticListener;
}
/// <summary>
/// Gets the <see cref="DiagnosticSource"/>.
/// </summary>
protected DiagnosticSource DiagnosticSource { get; }
protected DiagnosticListener DiagnosticSource { get; }
/// <summary>
/// Gets the <see cref="ITempDataDictionaryFactory"/>.

View File

@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
/// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
/// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
/// <param name="tempDataFactory">The <see cref="ITempDataDictionaryFactory"/>.</param>
/// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
/// <param name="diagnosticListener">The <see cref="DiagnosticListener"/>.</param>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
/// <param name="modelMetadataProvider">The <see cref="IModelMetadataProvider"/>.</param>
public ViewResultExecutor(
@ -38,10 +38,10 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
IHttpResponseStreamWriterFactory writerFactory,
ICompositeViewEngine viewEngine,
ITempDataDictionaryFactory tempDataFactory,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
ILoggerFactory loggerFactory,
IModelMetadataProvider modelMetadataProvider)
: base(viewOptions, writerFactory, viewEngine, tempDataFactory, diagnosticSource, modelMetadataProvider)
: base(viewOptions, writerFactory, viewEngine, tempDataFactory, diagnosticListener, modelMetadataProvider)
{
if (loggerFactory == null)
{
@ -107,6 +107,25 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
}
}
if (DiagnosticSource.IsEnabled())
{
OutputDiagnostics(actionContext, viewResult, viewName, stopwatch, result);
}
if (result.Success)
{
Logger.ViewFound(result.View, stopwatch.GetElapsedTime());
}
else
{
Logger.ViewNotFound(viewName, result.SearchedLocations);
}
return result;
}
private void OutputDiagnostics(ActionContext actionContext, ViewResult viewResult, string viewName, ValueStopwatch stopwatch, ViewEngineResult result)
{
if (result.Success)
{
if (DiagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewFound"))
@ -122,8 +141,6 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
view = result.View,
});
}
Logger.ViewFound(result.View, stopwatch.GetElapsedTime());
}
else
{
@ -140,10 +157,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
searchedLocations = result.SearchedLocations
});
}
Logger.ViewNotFound(viewName, result.SearchedLocations);
}
return result;
}
/// <inheritdoc />

View File

@ -1,16 +1,30 @@
[
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.RemoteAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute, Microsoft.AspNetCore.Mvc.ModelBinding.Validation.IClientModelValidator",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionaryControllerPropertyActivator : Microsoft.AspNetCore.Mvc.Internal.IControllerPropertyActivator",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentActivator : Microsoft.AspNetCore.Mvc.ViewComponents.IViewComponentActivator",
"MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.Internal.ITypeActivatorCache typeActivatorCache)",
"TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor",
"MemberId": "protected .ctor(Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine viewEngine, System.Diagnostics.DiagnosticSource diagnosticSource)",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.DefaultValidationHtmlAttributeProvider : Microsoft.AspNetCore.Mvc.ViewFeatures.ValidationHtmlAttributeProvider",
"MemberId": "public .ctor(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.MvcViewOptions> optionsAccessor, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider metadataProvider, Microsoft.AspNetCore.Mvc.Internal.ClientValidatorCache clientValidatorCache)",
"TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor",
"MemberId": "protected System.Diagnostics.DiagnosticSource get_DiagnosticSource()",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor",
"MemberId": "public .ctor(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.MvcViewOptions> viewOptions, Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine viewEngine, Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory tempDataFactory, System.Diagnostics.DiagnosticSource diagnosticSource, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider modelMetadataProvider)",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentActivator : Microsoft.AspNetCore.Mvc.ViewComponents.IViewComponentActivator",
"MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.Internal.ITypeActivatorCache typeActivatorCache)",
"Kind": "Removal"
},
{
@ -44,7 +58,18 @@
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.RemoteAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute, Microsoft.AspNetCore.Mvc.ModelBinding.Validation.IClientModelValidator",
"Kind": "Removal"
"TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.DefaultValidationHtmlAttributeProvider : Microsoft.AspNetCore.Mvc.ViewFeatures.ValidationHtmlAttributeProvider",
"MemberId": "public .ctor(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.MvcViewOptions> optionsAccessor, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider metadataProvider, Microsoft.AspNetCore.Mvc.Internal.ClientValidatorCache clientValidatorCache)",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.PartialViewResultExecutor : Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor, Microsoft.AspNetCore.Mvc.Infrastructure.IActionResultExecutor<Microsoft.AspNetCore.Mvc.PartialViewResult>",
"MemberId": "public .ctor(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.MvcViewOptions> viewOptions, Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine viewEngine, Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory tempDataFactory, System.Diagnostics.DiagnosticSource diagnosticSource, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider modelMetadataProvider)",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor : Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor, Microsoft.AspNetCore.Mvc.Infrastructure.IActionResultExecutor<Microsoft.AspNetCore.Mvc.ViewResult>",
"MemberId": "public .ctor(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.MvcViewOptions> viewOptions, Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine viewEngine, Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory tempDataFactory, System.Diagnostics.DiagnosticSource diagnosticSource, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider modelMetadataProvider)",
"Kind": "Removal"
}
]
]

View File

@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Builder
{
// Arrange
var services = new ServiceCollection();
services.AddSingleton<DiagnosticSource>(new DiagnosticListener("Microsoft.AspNetCore"));
services.AddSingleton<DiagnosticListener>(new DiagnosticListener("Microsoft.AspNetCore"));
services.AddLogging();
services.AddMvcCore(o => o.EnableEndpointRouting = false);
var serviceProvider = services.BuildServiceProvider();
@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Builder
{
// Arrange
var services = new ServiceCollection();
services.AddSingleton<DiagnosticSource>(new DiagnosticListener("Microsoft.AspNetCore"));
services.AddSingleton<DiagnosticListener>(new DiagnosticListener("Microsoft.AspNetCore"));
services.AddLogging();
services.AddMvcCore(o => o.EnableEndpointRouting = true);
var serviceProvider = services.BuildServiceProvider();

View File

@ -276,14 +276,14 @@ namespace Microsoft.AspNetCore.Mvc.Filters
var actionContext = new ActionContext(httpContext, new RouteData(), actionDescriptor);
var diagnosticSource = new DiagnosticListener("Microsoft.AspNetCore");
diagnosticSource.SubscribeWithAdapter(new TestDiagnosticListener());
var diagnosticListener = new DiagnosticListener("Microsoft.AspNetCore");
diagnosticListener.SubscribeWithAdapter(new TestDiagnosticListener());
var invoker = new TestControllerActionInvoker(
filters,
new MockControllerFactory(controller ?? this),
new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(),
diagnosticSource,
diagnosticListener,
new ActionResultTypeMapper(),
actionContext,
new List<IValueProviderFactory>(),
@ -388,14 +388,14 @@ namespace Microsoft.AspNetCore.Mvc.Filters
IFilterMetadata[] filters,
MockControllerFactory controllerFactory,
ILogger logger,
DiagnosticSource diagnosticSource,
DiagnosticListener diagnosticListener,
IActionResultTypeMapper mapper,
ActionContext actionContext,
IReadOnlyList<IValueProviderFactory> valueProviderFactories,
int maxAllowedErrorsInModelState)
: base(
logger,
diagnosticSource,
diagnosticListener,
mapper,
CreateControllerContext(actionContext, valueProviderFactories, maxAllowedErrorsInModelState),
CreateCacheEntry((ControllerActionDescriptor)actionContext.ActionDescriptor, controllerFactory),

View File

@ -111,8 +111,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor
var activator = new Mock<IRazorPageActivator>();
var adapter = new TestDiagnosticListener();
var diagnosticSource = new DiagnosticListener("Microsoft.AspNetCore.Mvc.Razor");
diagnosticSource.SubscribeWithAdapter(adapter);
var diagnosticListener = new DiagnosticListener("Microsoft.AspNetCore.Mvc.Razor");
diagnosticListener.SubscribeWithAdapter(adapter);
var view = new RazorView(
Mock.Of<IRazorViewEngine>(),
@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
new IRazorPage[0],
page,
new HtmlTestEncoder(),
diagnosticSource);
diagnosticListener);
var viewContext = CreateViewContext(view);
var expectedWriter = viewContext.Writer;

View File

@ -294,7 +294,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
IModelMetadataProvider provider = null,
IUrlHelperFactory urlHelperFactory = null,
IJsonHelper jsonHelper = null,
DiagnosticSource diagnosticSource = null,
DiagnosticListener diagnosticListener = null,
HtmlEncoder htmlEncoder = null,
IModelExpressionProvider modelExpressionProvider = null)
{
@ -303,7 +303,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
provider ?? Mock.Of<IModelMetadataProvider>(),
urlHelperFactory ?? Mock.Of<IUrlHelperFactory>(),
jsonHelper ?? Mock.Of<IJsonHelper>(),
diagnosticSource ?? new DiagnosticListener("Microsoft.AspNetCore.Mvc.RazorPages"),
diagnosticListener ?? new DiagnosticListener("Microsoft.AspNetCore.Mvc.RazorPages"),
htmlEncoder ?? HtmlEncoder.Default,
modelExpressionProvider ?? Mock.Of<IModelExpressionProvider>());
}

View File

@ -264,7 +264,9 @@ namespace Microsoft.AspNetCore.Mvc
{
var serviceCollection = new ServiceCollection();
serviceCollection.AddSingleton(new ApplicationPartManager());
serviceCollection.AddSingleton<DiagnosticSource>(new DiagnosticListener("Microsoft.AspNetCore.Mvc"));
var diagnosticListener = new DiagnosticListener("Microsoft.AspNetCore.Mvc");
serviceCollection.AddSingleton<DiagnosticSource>(diagnosticListener);
serviceCollection.AddSingleton<DiagnosticListener>(diagnosticListener);
serviceCollection.AddMvc();
serviceCollection
.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>()

View File

@ -261,7 +261,10 @@ namespace Microsoft.AspNetCore.Mvc
services.AddSingleton<IHostingEnvironment>(GetHostingEnvironment());
services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
services.AddSingleton<DiagnosticSource>(new DiagnosticListener("Microsoft.AspNet"));
var diagnosticListener = new DiagnosticListener("Microsoft.AspNet");
services.AddSingleton<DiagnosticSource>(diagnosticListener);
services.AddSingleton<DiagnosticListener>(diagnosticListener);
services.AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
services.AddLogging();
services.AddOptions();

View File

@ -210,12 +210,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
public void FindView_WritesDiagnostic_ViewFound()
{
// Arrange
var diagnosticSource = new DiagnosticListener("Test");
var diagnosticListener = new DiagnosticListener("Test");
var listener = new TestDiagnosticListener();
diagnosticSource.SubscribeWithAdapter(listener);
diagnosticListener.SubscribeWithAdapter(listener);
var context = GetActionContext();
var executor = GetViewExecutor(diagnosticSource);
var executor = GetViewExecutor(diagnosticListener);
var viewName = "myview";
var viewResult = new PartialViewResult
@ -243,12 +243,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
public void FindView_WritesDiagnostic_ViewNotFound()
{
// Arrange
var diagnosticSource = new DiagnosticListener("Test");
var diagnosticListener = new DiagnosticListener("Test");
var listener = new TestDiagnosticListener();
diagnosticSource.SubscribeWithAdapter(listener);
diagnosticListener.SubscribeWithAdapter(listener);
var context = GetActionContext();
var executor = GetViewExecutor(diagnosticSource);
var executor = GetViewExecutor(diagnosticListener);
var viewName = "myview";
var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
@ -342,11 +342,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
return new ActionContext(new DefaultHttpContext(), routeData, new ControllerActionDescriptor() { ActionName = actionName });
}
private PartialViewResultExecutor GetViewExecutor(DiagnosticSource diagnosticSource = null)
private PartialViewResultExecutor GetViewExecutor(DiagnosticListener diagnosticListener = null)
{
if (diagnosticSource == null)
if (diagnosticListener == null)
{
diagnosticSource = new DiagnosticListener("Test");
diagnosticListener = new DiagnosticListener("Test");
}
var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
@ -367,7 +367,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
new TestHttpResponseStreamWriterFactory(),
new CompositeViewEngine(options),
new TempDataDictionaryFactory(new SessionStateTempDataProvider()),
diagnosticSource,
diagnosticListener,
NullLoggerFactory.Instance,
new EmptyModelMetadataProvider());

View File

@ -560,7 +560,7 @@ namespace Microsoft.AspNetCore.Mvc
}
var services = new ServiceCollection();
services.AddSingleton<DiagnosticSource>(diagnosticSource);
services.AddSingleton<DiagnosticListener>(diagnosticSource);
services.AddSingleton<ViewComponentInvokerCache>();
services.AddSingleton<ExpressionTextCache>();
services.AddSingleton(Options.Create(new MvcViewOptions()));

View File

@ -355,7 +355,7 @@ namespace Microsoft.AspNetCore.Mvc
var serviceProvider = new Mock<IServiceProvider>();
serviceProvider.Setup(p => p.GetService(typeof(ICompositeViewEngine)))
.Returns(viewEngine.Object);
serviceProvider.Setup(p => p.GetService(typeof(DiagnosticSource)))
serviceProvider.Setup(p => p.GetService(typeof(DiagnosticListener)))
.Returns(new DiagnosticListener("Test"));
var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
@ -519,7 +519,7 @@ namespace Microsoft.AspNetCore.Mvc
diagnosticSource.SubscribeWithAdapter(diagnosticListener);
var serviceProvider = new Mock<IServiceProvider>();
serviceProvider.Setup(s => s.GetService(typeof(DiagnosticSource))).Returns(diagnosticSource);
serviceProvider.Setup(s => s.GetService(typeof(DiagnosticListener))).Returns(diagnosticSource);
var httpContext = new DefaultHttpContext();
httpContext.RequestServices = serviceProvider.Object;

View File

@ -235,10 +235,10 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
var adapter = new TestDiagnosticListener();
var diagnosticSource = new DiagnosticListener("Test");
diagnosticSource.SubscribeWithAdapter(adapter);
var diagnosticListener = new DiagnosticListener("Test");
diagnosticListener.SubscribeWithAdapter(adapter);
var viewExecutor = CreateViewExecutor(diagnosticSource);
var viewExecutor = CreateViewExecutor(diagnosticListener);
// Act
await viewExecutor.ExecuteAsync(
@ -351,11 +351,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
return view.Object;
}
private ViewExecutor CreateViewExecutor(DiagnosticListener diagnosticSource = null)
private ViewExecutor CreateViewExecutor(DiagnosticListener diagnosticListener = null)
{
if (diagnosticSource == null)
if (diagnosticListener == null)
{
diagnosticSource = new DiagnosticListener("Test");
diagnosticListener = new DiagnosticListener("Test");
}
return new ViewExecutor(
@ -363,7 +363,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
new TestHttpResponseStreamWriterFactory(),
new Mock<ICompositeViewEngine>(MockBehavior.Strict).Object,
new TempDataDictionaryFactory(new SessionStateTempDataProvider()),
diagnosticSource,
diagnosticListener,
new EmptyModelMetadataProvider());
}
}

View File

@ -206,12 +206,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
public void FindView_WritesDiagnostic_ViewFound()
{
// Arrange
var diagnosticSource = new DiagnosticListener("Test");
var diagnosticListener = new DiagnosticListener("Test");
var listener = new TestDiagnosticListener();
diagnosticSource.SubscribeWithAdapter(listener);
diagnosticListener.SubscribeWithAdapter(listener);
var context = GetActionContext();
var executor = GetViewExecutor(diagnosticSource);
var executor = GetViewExecutor(diagnosticListener);
var viewName = "myview";
var viewResult = new ViewResult
@ -239,12 +239,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
public void FindView_WritesDiagnostic_ViewNotFound()
{
// Arrange
var diagnosticSource = new DiagnosticListener("Test");
var diagnosticListener = new DiagnosticListener("Test");
var listener = new TestDiagnosticListener();
diagnosticSource.SubscribeWithAdapter(listener);
diagnosticListener.SubscribeWithAdapter(listener);
var context = GetActionContext();
var executor = GetViewExecutor(diagnosticSource);
var executor = GetViewExecutor(diagnosticListener);
var viewName = "myview";
var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
@ -332,11 +332,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
return new ActionContext(new DefaultHttpContext(), routeData, new ControllerActionDescriptor() { ActionName = actionName });
}
private ViewResultExecutor GetViewExecutor(DiagnosticListener diagnosticSource = null)
private ViewResultExecutor GetViewExecutor(DiagnosticListener diagnosticListener = null)
{
if (diagnosticSource == null)
if (diagnosticListener == null)
{
diagnosticSource = new DiagnosticListener("Test");
diagnosticListener = new DiagnosticListener("Test");
}
var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
@ -357,7 +357,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
new TestHttpResponseStreamWriterFactory(),
new CompositeViewEngine(options),
new TempDataDictionaryFactory(new SessionStateTempDataProvider()),
diagnosticSource,
diagnosticListener,
NullLoggerFactory.Instance,
new EmptyModelMetadataProvider());