Update to use DiagnosticSource
This commit is contained in:
parent
054b39013c
commit
173f00fda7
|
|
@ -84,7 +84,7 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Locali
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Localization.Test", "test\Microsoft.AspNet.Mvc.Localization.Test\Microsoft.AspNet.Mvc.Localization.Test.xproj", "{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Localization.Test", "test\Microsoft.AspNet.Mvc.Localization.Test\Microsoft.AspNet.Mvc.Localization.Test.xproj", "{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestTelemetryListener.Sources", "test\Microsoft.AspNet.Mvc.TestTelemetryListener.Sources\Microsoft.AspNet.Mvc.TestTelemetryListener.Sources.xproj", "{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources", "test\Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources\Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources.xproj", "{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
|
||||||
2
Mvc.sln
2
Mvc.sln
|
|
@ -180,7 +180,7 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Locali
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Localization.Test", "test\Microsoft.AspNet.Mvc.Localization.Test\Microsoft.AspNet.Mvc.Localization.Test.xproj", "{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Localization.Test", "test\Microsoft.AspNet.Mvc.Localization.Test\Microsoft.AspNet.Mvc.Localization.Test.xproj", "{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestTelemetryListener.Sources", "test\Microsoft.AspNet.Mvc.TestTelemetryListener.Sources\Microsoft.AspNet.Mvc.TestTelemetryListener.Sources.xproj", "{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources", "test\Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources\Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources.xproj", "{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.Tracing;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.Core;
|
using Microsoft.AspNet.Mvc.Core;
|
||||||
|
|
@ -23,7 +22,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
private readonly ControllerActionDescriptor _descriptor;
|
private readonly ControllerActionDescriptor _descriptor;
|
||||||
private readonly IControllerFactory _controllerFactory;
|
private readonly IControllerFactory _controllerFactory;
|
||||||
private readonly IControllerActionArgumentBinder _argumentBinder;
|
private readonly IControllerActionArgumentBinder _argumentBinder;
|
||||||
#pragma warning disable 0618
|
|
||||||
public ControllerActionInvoker(
|
public ControllerActionInvoker(
|
||||||
ActionContext actionContext,
|
ActionContext actionContext,
|
||||||
IReadOnlyList<IFilterProvider> filterProviders,
|
IReadOnlyList<IFilterProvider> filterProviders,
|
||||||
|
|
@ -37,7 +36,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
IReadOnlyList<IValueProviderFactory> valueProviderFactories,
|
IReadOnlyList<IValueProviderFactory> valueProviderFactories,
|
||||||
IActionBindingContextAccessor actionBindingContextAccessor,
|
IActionBindingContextAccessor actionBindingContextAccessor,
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
TelemetrySource telemetry,
|
DiagnosticSource diagnosticSource,
|
||||||
int maxModelValidationErrors)
|
int maxModelValidationErrors)
|
||||||
: base(
|
: base(
|
||||||
actionContext,
|
actionContext,
|
||||||
|
|
@ -49,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
valueProviderFactories,
|
valueProviderFactories,
|
||||||
actionBindingContextAccessor,
|
actionBindingContextAccessor,
|
||||||
logger,
|
logger,
|
||||||
telemetry,
|
diagnosticSource,
|
||||||
maxModelValidationErrors)
|
maxModelValidationErrors)
|
||||||
{
|
{
|
||||||
if (actionContext == null)
|
if (actionContext == null)
|
||||||
|
|
@ -112,9 +111,9 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
throw new ArgumentNullException(nameof(logger));
|
throw new ArgumentNullException(nameof(logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (telemetry == null)
|
if (diagnosticSource == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(telemetry));
|
throw new ArgumentNullException(nameof(diagnosticSource));
|
||||||
}
|
}
|
||||||
|
|
||||||
_descriptor = descriptor;
|
_descriptor = descriptor;
|
||||||
|
|
@ -129,7 +128,6 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
"descriptor");
|
"descriptor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#pragma warning disable 0618
|
|
||||||
|
|
||||||
protected override object CreateInstance()
|
protected override object CreateInstance()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNet.Mvc.Abstractions;
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.Filters;
|
using Microsoft.AspNet.Mvc.Filters;
|
||||||
|
|
@ -18,7 +18,6 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
{
|
{
|
||||||
public class ControllerActionInvokerProvider : IActionInvokerProvider
|
public class ControllerActionInvokerProvider : IActionInvokerProvider
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
|
||||||
private readonly IControllerActionArgumentBinder _argumentBinder;
|
private readonly IControllerActionArgumentBinder _argumentBinder;
|
||||||
private readonly IControllerFactory _controllerFactory;
|
private readonly IControllerFactory _controllerFactory;
|
||||||
private readonly IFilterProvider[] _filterProviders;
|
private readonly IFilterProvider[] _filterProviders;
|
||||||
|
|
@ -30,7 +29,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
private readonly IActionBindingContextAccessor _actionBindingContextAccessor;
|
private readonly IActionBindingContextAccessor _actionBindingContextAccessor;
|
||||||
private readonly int _maxModelValidationErrors;
|
private readonly int _maxModelValidationErrors;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly TelemetrySource _telemetry;
|
private readonly DiagnosticSource _diagnosticSource;
|
||||||
|
|
||||||
public ControllerActionInvokerProvider(
|
public ControllerActionInvokerProvider(
|
||||||
IControllerFactory controllerFactory,
|
IControllerFactory controllerFactory,
|
||||||
|
|
@ -39,7 +38,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
IOptions<MvcOptions> optionsAccessor,
|
IOptions<MvcOptions> optionsAccessor,
|
||||||
IActionBindingContextAccessor actionBindingContextAccessor,
|
IActionBindingContextAccessor actionBindingContextAccessor,
|
||||||
ILoggerFactory loggerFactory,
|
ILoggerFactory loggerFactory,
|
||||||
TelemetrySource telemetry)
|
DiagnosticSource diagnosticSource)
|
||||||
{
|
{
|
||||||
_controllerFactory = controllerFactory;
|
_controllerFactory = controllerFactory;
|
||||||
_filterProviders = filterProviders.OrderBy(item => item.Order).ToArray();
|
_filterProviders = filterProviders.OrderBy(item => item.Order).ToArray();
|
||||||
|
|
@ -52,9 +51,8 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
_actionBindingContextAccessor = actionBindingContextAccessor;
|
_actionBindingContextAccessor = actionBindingContextAccessor;
|
||||||
_maxModelValidationErrors = optionsAccessor.Value.MaxModelValidationErrors;
|
_maxModelValidationErrors = optionsAccessor.Value.MaxModelValidationErrors;
|
||||||
_logger = loggerFactory.CreateLogger<ControllerActionInvoker>();
|
_logger = loggerFactory.CreateLogger<ControllerActionInvoker>();
|
||||||
_telemetry = telemetry;
|
_diagnosticSource = diagnosticSource;
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
public int Order
|
public int Order
|
||||||
{
|
{
|
||||||
|
|
@ -86,7 +84,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
_valueProviderFactories,
|
_valueProviderFactories,
|
||||||
_actionBindingContextAccessor,
|
_actionBindingContextAccessor,
|
||||||
_logger,
|
_logger,
|
||||||
_telemetry,
|
_diagnosticSource,
|
||||||
_maxModelValidationErrors);
|
_maxModelValidationErrors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.Tracing;
|
|
||||||
using System.Runtime.ExceptionServices;
|
using System.Runtime.ExceptionServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.Abstractions;
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
|
|
@ -31,9 +30,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
private readonly IReadOnlyList<IValueProviderFactory> _valueProviderFactories;
|
private readonly IReadOnlyList<IValueProviderFactory> _valueProviderFactories;
|
||||||
private readonly IActionBindingContextAccessor _actionBindingContextAccessor;
|
private readonly IActionBindingContextAccessor _actionBindingContextAccessor;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
#pragma warning disable 0618
|
private readonly DiagnosticSource _diagnosticSource;
|
||||||
private readonly TelemetrySource _telemetry;
|
|
||||||
#pragma warning restore 0618
|
|
||||||
private readonly int _maxModelValidationErrors;
|
private readonly int _maxModelValidationErrors;
|
||||||
|
|
||||||
private IFilterMetadata[] _filters;
|
private IFilterMetadata[] _filters;
|
||||||
|
|
@ -62,8 +59,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
"Request was short circuited at exception filter '{ExceptionFilter}'.";
|
"Request was short circuited at exception filter '{ExceptionFilter}'.";
|
||||||
private const string ResultFilterShortCircuitLogMessage =
|
private const string ResultFilterShortCircuitLogMessage =
|
||||||
"Request was short circuited at result filter '{ResultFilter}'.";
|
"Request was short circuited at result filter '{ResultFilter}'.";
|
||||||
|
|
||||||
#pragma warning disable 0618
|
|
||||||
public FilterActionInvoker(
|
public FilterActionInvoker(
|
||||||
ActionContext actionContext,
|
ActionContext actionContext,
|
||||||
IReadOnlyList<IFilterProvider> filterProviders,
|
IReadOnlyList<IFilterProvider> filterProviders,
|
||||||
|
|
@ -74,7 +70,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
IReadOnlyList<IValueProviderFactory> valueProviderFactories,
|
IReadOnlyList<IValueProviderFactory> valueProviderFactories,
|
||||||
IActionBindingContextAccessor actionBindingContextAccessor,
|
IActionBindingContextAccessor actionBindingContextAccessor,
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
TelemetrySource telemetry,
|
DiagnosticSource diagnosticSource,
|
||||||
int maxModelValidationErrors)
|
int maxModelValidationErrors)
|
||||||
{
|
{
|
||||||
if (actionContext == null)
|
if (actionContext == null)
|
||||||
|
|
@ -122,9 +118,9 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
throw new ArgumentNullException(nameof(logger));
|
throw new ArgumentNullException(nameof(logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (telemetry == null)
|
if (diagnosticSource == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(telemetry));
|
throw new ArgumentNullException(nameof(diagnosticSource));
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionContext = actionContext;
|
ActionContext = actionContext;
|
||||||
|
|
@ -137,10 +133,9 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
_valueProviderFactories = valueProviderFactories;
|
_valueProviderFactories = valueProviderFactories;
|
||||||
_actionBindingContextAccessor = actionBindingContextAccessor;
|
_actionBindingContextAccessor = actionBindingContextAccessor;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_telemetry = telemetry;
|
_diagnosticSource = diagnosticSource;
|
||||||
_maxModelValidationErrors = maxModelValidationErrors;
|
_maxModelValidationErrors = maxModelValidationErrors;
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
protected ActionContext ActionContext { get; private set; }
|
protected ActionContext ActionContext { get; private set; }
|
||||||
|
|
||||||
|
|
@ -656,10 +651,9 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
if (_diagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionMethod"))
|
||||||
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionMethod"))
|
|
||||||
{
|
{
|
||||||
_telemetry.WriteTelemetry(
|
_diagnosticSource.Write(
|
||||||
"Microsoft.AspNet.Mvc.BeforeActionMethod",
|
"Microsoft.AspNet.Mvc.BeforeActionMethod",
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
|
|
@ -668,16 +662,14 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
controller = _actionExecutingContext.Controller
|
controller = _actionExecutingContext.Controller
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
result = await InvokeActionAsync(_actionExecutingContext);
|
result = await InvokeActionAsync(_actionExecutingContext);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
if (_diagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.AfterActionMethod"))
|
||||||
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionMethod"))
|
|
||||||
{
|
{
|
||||||
_telemetry.WriteTelemetry(
|
_diagnosticSource.Write(
|
||||||
"Microsoft.AspNet.Mvc.AfterActionMethod",
|
"Microsoft.AspNet.Mvc.AfterActionMethod",
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
|
|
@ -687,7 +679,6 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
result = result
|
result = result
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_actionExecutedContext = new ActionExecutedContext(
|
_actionExecutedContext = new ActionExecutedContext(
|
||||||
|
|
@ -835,14 +826,12 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
|
|
||||||
private async Task InvokeResultAsync(IActionResult result)
|
private async Task InvokeResultAsync(IActionResult result)
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
if (_diagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionResult"))
|
||||||
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionResult"))
|
|
||||||
{
|
{
|
||||||
_telemetry.WriteTelemetry(
|
_diagnosticSource.Write(
|
||||||
"Microsoft.AspNet.Mvc.BeforeActionResult",
|
"Microsoft.AspNet.Mvc.BeforeActionResult",
|
||||||
new { actionContext = ActionContext, result = result });
|
new { actionContext = ActionContext, result = result });
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -850,14 +839,12 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
if (_diagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.AfterActionResult"))
|
||||||
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionResult"))
|
|
||||||
{
|
{
|
||||||
_telemetry.WriteTelemetry(
|
_diagnosticSource.Write(
|
||||||
"Microsoft.AspNet.Mvc.AfterActionResult",
|
"Microsoft.AspNet.Mvc.AfterActionResult",
|
||||||
new { actionContext = ActionContext, result = result });
|
new { actionContext = ActionContext, result = result });
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.AspNet.Mvc.Abstractions;
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
|
|
@ -21,9 +21,7 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
private IActionInvokerFactory _actionInvokerFactory;
|
private IActionInvokerFactory _actionInvokerFactory;
|
||||||
private IActionSelector _actionSelector;
|
private IActionSelector _actionSelector;
|
||||||
private ILogger _logger;
|
private ILogger _logger;
|
||||||
#pragma warning disable 0618
|
private DiagnosticSource _diagnosticSource;
|
||||||
private TelemetrySource _telemetry;
|
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
public VirtualPathData GetVirtualPath(VirtualPathContext context)
|
public VirtualPathData GetVirtualPath(VirtualPathContext context)
|
||||||
{
|
{
|
||||||
|
|
@ -86,14 +84,12 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
{
|
{
|
||||||
context.RouteData = newRouteData;
|
context.RouteData = newRouteData;
|
||||||
|
|
||||||
#pragma warning disable 0618
|
if (_diagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.BeforeAction"))
|
||||||
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeAction"))
|
|
||||||
{
|
{
|
||||||
_telemetry.WriteTelemetry(
|
_diagnosticSource.Write(
|
||||||
"Microsoft.AspNet.Mvc.BeforeAction",
|
"Microsoft.AspNet.Mvc.BeforeAction",
|
||||||
new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData });
|
new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData });
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
using (_logger.BeginScope("ActionId: {ActionId}", actionDescriptor.Id))
|
using (_logger.BeginScope("ActionId: {ActionId}", actionDescriptor.Id))
|
||||||
{
|
{
|
||||||
|
|
@ -105,14 +101,12 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
if (_diagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.AfterAction"))
|
||||||
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterAction"))
|
|
||||||
{
|
{
|
||||||
_telemetry.WriteTelemetry(
|
_diagnosticSource.Write(
|
||||||
"Microsoft.AspNet.Mvc.AfterAction",
|
"Microsoft.AspNet.Mvc.AfterAction",
|
||||||
new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData });
|
new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData });
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
if (!context.IsHandled)
|
if (!context.IsHandled)
|
||||||
{
|
{
|
||||||
|
|
@ -159,13 +153,11 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
var factory = context.RequestServices.GetRequiredService<ILoggerFactory>();
|
var factory = context.RequestServices.GetRequiredService<ILoggerFactory>();
|
||||||
_logger = factory.CreateLogger<MvcRouteHandler>();
|
_logger = factory.CreateLogger<MvcRouteHandler>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable 0618
|
if (_diagnosticSource == null)
|
||||||
if (_telemetry == null)
|
|
||||||
{
|
{
|
||||||
_telemetry = context.RequestServices.GetRequiredService<TelemetrySource>();
|
_diagnosticSource = context.RequestServices.GetRequiredService<DiagnosticSource>();
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
"version": "1.0.0-*",
|
"version": "1.0.0-*",
|
||||||
"type": "build"
|
"type": "build"
|
||||||
},
|
},
|
||||||
"System.Diagnostics.Tracing.Telemetry": "4.0.0-beta-*"
|
"System.Diagnostics.DiagnosticSource": "4.0.0-beta-*"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"dnx451": {
|
"dnx451": {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
|
|
@ -16,22 +16,21 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PartialViewResultExecutor : ViewExecutor
|
public class PartialViewResultExecutor : ViewExecutor
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="PartialViewResultExecutor"/>.
|
/// Creates a new <see cref="PartialViewResultExecutor"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="viewOptions">The <see cref="IOptions{MvcViewOptions}"/>.</param>
|
/// <param name="viewOptions">The <see cref="IOptions{MvcViewOptions}"/>.</param>
|
||||||
/// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
|
/// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
|
||||||
/// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
|
/// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
|
||||||
/// <param name="telemetry">The <see cref="TelemetrySource"/>.</param>
|
/// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
|
||||||
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
|
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
|
||||||
public PartialViewResultExecutor(
|
public PartialViewResultExecutor(
|
||||||
IOptions<MvcViewOptions> viewOptions,
|
IOptions<MvcViewOptions> viewOptions,
|
||||||
IHttpResponseStreamWriterFactory writerFactory,
|
IHttpResponseStreamWriterFactory writerFactory,
|
||||||
ICompositeViewEngine viewEngine,
|
ICompositeViewEngine viewEngine,
|
||||||
TelemetrySource telemetry,
|
DiagnosticSource diagnosticSource,
|
||||||
ILoggerFactory loggerFactory)
|
ILoggerFactory loggerFactory)
|
||||||
: base(viewOptions, writerFactory, viewEngine, telemetry)
|
: base(viewOptions, writerFactory, viewEngine, diagnosticSource)
|
||||||
{
|
{
|
||||||
if (loggerFactory == null)
|
if (loggerFactory == null)
|
||||||
{
|
{
|
||||||
|
|
@ -40,7 +39,6 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
Logger = loggerFactory.CreateLogger<PartialViewResultExecutor>();
|
Logger = loggerFactory.CreateLogger<PartialViewResultExecutor>();
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="ILogger"/>.
|
/// Gets the <see cref="ILogger"/>.
|
||||||
|
|
@ -71,10 +69,9 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
var result = viewEngine.FindPartialView(actionContext, viewName);
|
var result = viewEngine.FindPartialView(actionContext, viewName);
|
||||||
if (result.Success)
|
if (result.Success)
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
if (DiagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.ViewFound"))
|
||||||
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewFound"))
|
|
||||||
{
|
{
|
||||||
Telemetry.WriteTelemetry(
|
DiagnosticSource.Write(
|
||||||
"Microsoft.AspNet.Mvc.ViewFound",
|
"Microsoft.AspNet.Mvc.ViewFound",
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
|
|
@ -85,15 +82,14 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
view = result.View,
|
view = result.View,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
Logger.LogVerbose("The partial view '{PartialViewName}' was found.", viewName);
|
Logger.LogVerbose("The partial view '{PartialViewName}' was found.", viewName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
if (DiagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.ViewNotFound"))
|
||||||
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewNotFound"))
|
|
||||||
{
|
{
|
||||||
Telemetry.WriteTelemetry(
|
DiagnosticSource.Write(
|
||||||
"Microsoft.AspNet.Mvc.ViewNotFound",
|
"Microsoft.AspNet.Mvc.ViewNotFound",
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
|
|
@ -104,7 +100,6 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
searchedLocations = result.SearchedLocations
|
searchedLocations = result.SearchedLocations
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
Logger.LogError(
|
Logger.LogError(
|
||||||
"The partial view '{PartialViewName}' was not found. Searched locations: {SearchedViewLocations}",
|
"The partial view '{PartialViewName}' was not found. Searched locations: {SearchedViewLocations}",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||||
|
|
@ -26,19 +26,18 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
Encoding = Encoding.UTF8
|
Encoding = Encoding.UTF8
|
||||||
}.CopyAsReadOnly();
|
}.CopyAsReadOnly();
|
||||||
|
|
||||||
#pragma warning disable 0618
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="ViewExecutor"/>.
|
/// Creates a new <see cref="ViewExecutor"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="viewOptions">The <see cref="IOptions{MvcViewOptions}"/>.</param>
|
/// <param name="viewOptions">The <see cref="IOptions{MvcViewOptions}"/>.</param>
|
||||||
/// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
|
/// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
|
||||||
/// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
|
/// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
|
||||||
/// <param name="telemetry">The <see cref="TelemetrySource"/>.</param>
|
/// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
|
||||||
public ViewExecutor(
|
public ViewExecutor(
|
||||||
IOptions<MvcViewOptions> viewOptions,
|
IOptions<MvcViewOptions> viewOptions,
|
||||||
IHttpResponseStreamWriterFactory writerFactory,
|
IHttpResponseStreamWriterFactory writerFactory,
|
||||||
ICompositeViewEngine viewEngine,
|
ICompositeViewEngine viewEngine,
|
||||||
TelemetrySource telemetry)
|
DiagnosticSource diagnosticSource)
|
||||||
{
|
{
|
||||||
if (viewOptions == null)
|
if (viewOptions == null)
|
||||||
{
|
{
|
||||||
|
|
@ -55,22 +54,21 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
throw new ArgumentNullException(nameof(viewEngine));
|
throw new ArgumentNullException(nameof(viewEngine));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (telemetry == null)
|
if (diagnosticSource == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(telemetry));
|
throw new ArgumentNullException(nameof(diagnosticSource));
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewOptions = viewOptions.Value;
|
ViewOptions = viewOptions.Value;
|
||||||
WriterFactory = writerFactory;
|
WriterFactory = writerFactory;
|
||||||
ViewEngine = viewEngine;
|
ViewEngine = viewEngine;
|
||||||
Telemetry = telemetry;
|
DiagnosticSource = diagnosticSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="TelemetrySource"/>.
|
/// Gets the <see cref="DiagnosticSource"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected TelemetrySource Telemetry { get; }
|
protected DiagnosticSource DiagnosticSource { get; }
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the default <see cref="IViewEngine"/>.
|
/// Gets the default <see cref="IViewEngine"/>.
|
||||||
|
|
@ -159,26 +157,22 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
tempData,
|
tempData,
|
||||||
writer,
|
writer,
|
||||||
ViewOptions.HtmlHelperOptions);
|
ViewOptions.HtmlHelperOptions);
|
||||||
|
|
||||||
#pragma warning disable 0618
|
if (DiagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.BeforeView"))
|
||||||
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeView"))
|
|
||||||
{
|
{
|
||||||
Telemetry.WriteTelemetry(
|
DiagnosticSource.Write(
|
||||||
"Microsoft.AspNet.Mvc.BeforeView",
|
"Microsoft.AspNet.Mvc.BeforeView",
|
||||||
new { view = view, viewContext = viewContext, });
|
new { view = view, viewContext = viewContext, });
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
await view.RenderAsync(viewContext);
|
await view.RenderAsync(viewContext);
|
||||||
|
|
||||||
#pragma warning disable 0618
|
if (DiagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.AfterView"))
|
||||||
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterView"))
|
|
||||||
{
|
{
|
||||||
Telemetry.WriteTelemetry(
|
DiagnosticSource.Write(
|
||||||
"Microsoft.AspNet.Mvc.AfterView",
|
"Microsoft.AspNet.Mvc.AfterView",
|
||||||
new { view = view, viewContext = viewContext, });
|
new { view = view, viewContext = viewContext, });
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
// Perf: Invoke FlushAsync to ensure any buffered content is asynchronously written to the underlying
|
// Perf: Invoke FlushAsync to ensure any buffered content is asynchronously written to the underlying
|
||||||
// response asynchronously. In the absence of this line, the buffer gets synchronously written to the
|
// response asynchronously. In the absence of this line, the buffer gets synchronously written to the
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
|
|
@ -16,22 +16,21 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ViewResultExecutor : ViewExecutor
|
public class ViewResultExecutor : ViewExecutor
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="ViewResultExecutor"/>.
|
/// Creates a new <see cref="ViewResultExecutor"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="viewOptions">The <see cref="IOptions{MvcViewOptions}"/>.</param>
|
/// <param name="viewOptions">The <see cref="IOptions{MvcViewOptions}"/>.</param>
|
||||||
/// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
|
/// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
|
||||||
/// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
|
/// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
|
||||||
/// <param name="telemetry">The <see cref="TelemetrySource"/>.</param>
|
/// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
|
||||||
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
|
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
|
||||||
public ViewResultExecutor(
|
public ViewResultExecutor(
|
||||||
IOptions<MvcViewOptions> viewOptions,
|
IOptions<MvcViewOptions> viewOptions,
|
||||||
IHttpResponseStreamWriterFactory writerFactory,
|
IHttpResponseStreamWriterFactory writerFactory,
|
||||||
ICompositeViewEngine viewEngine,
|
ICompositeViewEngine viewEngine,
|
||||||
TelemetrySource telemetry,
|
DiagnosticSource diagnosticSource,
|
||||||
ILoggerFactory loggerFactory)
|
ILoggerFactory loggerFactory)
|
||||||
: base(viewOptions, writerFactory, viewEngine, telemetry)
|
: base(viewOptions, writerFactory, viewEngine, diagnosticSource)
|
||||||
{
|
{
|
||||||
if (loggerFactory == null)
|
if (loggerFactory == null)
|
||||||
{
|
{
|
||||||
|
|
@ -40,7 +39,6 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
Logger = loggerFactory.CreateLogger<ViewResultExecutor>();
|
Logger = loggerFactory.CreateLogger<ViewResultExecutor>();
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="ILogger"/>.
|
/// Gets the <see cref="ILogger"/>.
|
||||||
|
|
@ -71,10 +69,9 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
var result = viewEngine.FindView(actionContext, viewName);
|
var result = viewEngine.FindView(actionContext, viewName);
|
||||||
if (result.Success)
|
if (result.Success)
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
if (DiagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.ViewFound"))
|
||||||
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewFound"))
|
|
||||||
{
|
{
|
||||||
Telemetry.WriteTelemetry(
|
DiagnosticSource.Write(
|
||||||
"Microsoft.AspNet.Mvc.ViewFound",
|
"Microsoft.AspNet.Mvc.ViewFound",
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
|
|
@ -85,16 +82,14 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
view = result.View,
|
view = result.View,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
Logger.LogVerbose("The view '{ViewName}' was found.", viewName);
|
Logger.LogVerbose("The view '{ViewName}' was found.", viewName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
if (DiagnosticSource.IsEnabled("Microsoft.AspNet.Mvc.ViewNotFound"))
|
||||||
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewNotFound"))
|
|
||||||
{
|
{
|
||||||
Telemetry.WriteTelemetry(
|
DiagnosticSource.Write(
|
||||||
"Microsoft.AspNet.Mvc.ViewNotFound",
|
"Microsoft.AspNet.Mvc.ViewNotFound",
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
|
|
@ -105,7 +100,6 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
searchedLocations = result.SearchedLocations
|
searchedLocations = result.SearchedLocations
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
Logger.LogError(
|
Logger.LogError(
|
||||||
"The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}",
|
"The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}",
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
@ -2041,7 +2041,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
filterProvider
|
filterProvider
|
||||||
.SetupGet(fp => fp.Order)
|
.SetupGet(fp => fp.Order)
|
||||||
.Returns(-1000);
|
.Returns(-1000);
|
||||||
#pragma warning disable 0618
|
|
||||||
var invoker = new TestControllerActionInvoker(
|
var invoker = new TestControllerActionInvoker(
|
||||||
actionContext,
|
actionContext,
|
||||||
new[] { filterProvider.Object },
|
new[] { filterProvider.Object },
|
||||||
|
|
@ -2055,9 +2055,8 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
new IValueProviderFactory[0],
|
new IValueProviderFactory[0],
|
||||||
new ActionBindingContextAccessor(),
|
new ActionBindingContextAccessor(),
|
||||||
new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(),
|
new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(),
|
||||||
new TelemetryListener("Microsoft.AspNet"),
|
new DiagnosticListener("Microsoft.AspNet"),
|
||||||
maxAllowedErrorsInModelState);
|
maxAllowedErrorsInModelState);
|
||||||
#pragma warning restore 0618
|
|
||||||
return invoker;
|
return invoker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2101,7 +2100,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
.Returns(new TestController());
|
.Returns(new TestController());
|
||||||
|
|
||||||
var metadataProvider = new EmptyModelMetadataProvider();
|
var metadataProvider = new EmptyModelMetadataProvider();
|
||||||
#pragma warning disable 0618
|
|
||||||
var invoker = new ControllerActionInvoker(
|
var invoker = new ControllerActionInvoker(
|
||||||
actionContext,
|
actionContext,
|
||||||
new List<IFilterProvider>(),
|
new List<IFilterProvider>(),
|
||||||
|
|
@ -2117,9 +2116,8 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
new IValueProviderFactory[0],
|
new IValueProviderFactory[0],
|
||||||
new ActionBindingContextAccessor(),
|
new ActionBindingContextAccessor(),
|
||||||
new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(),
|
new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(),
|
||||||
new TelemetryListener("Microsoft.AspNet"),
|
new DiagnosticListener("Microsoft.AspNet"),
|
||||||
200);
|
200);
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await invoker.InvokeAsync();
|
await invoker.InvokeAsync();
|
||||||
|
|
@ -2206,7 +2204,6 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
|
|
||||||
private class TestControllerActionInvoker : ControllerActionInvoker
|
private class TestControllerActionInvoker : ControllerActionInvoker
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
|
||||||
public TestControllerActionInvoker(
|
public TestControllerActionInvoker(
|
||||||
ActionContext actionContext,
|
ActionContext actionContext,
|
||||||
IFilterProvider[] filterProvider,
|
IFilterProvider[] filterProvider,
|
||||||
|
|
@ -2220,7 +2217,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
IReadOnlyList<IValueProviderFactory> valueProviderFactories,
|
IReadOnlyList<IValueProviderFactory> valueProviderFactories,
|
||||||
IActionBindingContextAccessor actionBindingContext,
|
IActionBindingContextAccessor actionBindingContext,
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
TelemetrySource telemetry,
|
DiagnosticSource diagnosticSource,
|
||||||
int maxAllowedErrorsInModelState)
|
int maxAllowedErrorsInModelState)
|
||||||
: base(
|
: base(
|
||||||
actionContext,
|
actionContext,
|
||||||
|
|
@ -2235,12 +2232,11 @@ namespace Microsoft.AspNet.Mvc.Controllers
|
||||||
valueProviderFactories,
|
valueProviderFactories,
|
||||||
actionBindingContext,
|
actionBindingContext,
|
||||||
logger,
|
logger,
|
||||||
telemetry,
|
diagnosticSource,
|
||||||
maxAllowedErrorsInModelState)
|
maxAllowedErrorsInModelState)
|
||||||
{
|
{
|
||||||
ControllerFactory = controllerFactory;
|
ControllerFactory = controllerFactory;
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
public MockControllerFactory ControllerFactory { get; }
|
public MockControllerFactory ControllerFactory { get; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.AspNet.Mvc.Abstractions;
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
|
|
@ -193,12 +193,12 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task RouteAsync_Notifies_ActionSelected()
|
public async Task RouteAsync_WritesDiagnostic_ActionSelected()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var listener = new TestTelemetryListener();
|
var listener = new TestDiagnosticListener();
|
||||||
|
|
||||||
var context = CreateRouteContext(telemetryListener: listener);
|
var context = CreateRouteContext(diagnosticListener: listener);
|
||||||
context.RouteData.Values.Add("tag", "value");
|
context.RouteData.Values.Add("tag", "value");
|
||||||
|
|
||||||
var handler = new MvcRouteHandler();
|
var handler = new MvcRouteHandler();
|
||||||
|
|
@ -218,12 +218,12 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task RouteAsync_Notifies_ActionInvoked()
|
public async Task RouteAsync_WritesDiagnostic_ActionInvoked()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var listener = new TestTelemetryListener();
|
var listener = new TestDiagnosticListener();
|
||||||
|
|
||||||
var context = CreateRouteContext(telemetryListener: listener);
|
var context = CreateRouteContext(diagnosticListener: listener);
|
||||||
|
|
||||||
var handler = new MvcRouteHandler();
|
var handler = new MvcRouteHandler();
|
||||||
|
|
||||||
|
|
@ -241,7 +241,7 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
IActionInvokerFactory invokerFactory = null,
|
IActionInvokerFactory invokerFactory = null,
|
||||||
ILoggerFactory loggerFactory = null,
|
ILoggerFactory loggerFactory = null,
|
||||||
IOptions<MvcOptions> optionsAccessor = null,
|
IOptions<MvcOptions> optionsAccessor = null,
|
||||||
object telemetryListener = null)
|
object diagnosticListener = null)
|
||||||
{
|
{
|
||||||
if (actionDescriptor == null)
|
if (actionDescriptor == null)
|
||||||
{
|
{
|
||||||
|
|
@ -280,13 +280,13 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
{
|
{
|
||||||
optionsAccessor = new TestOptionsManager<MvcOptions>();
|
optionsAccessor = new TestOptionsManager<MvcOptions>();
|
||||||
}
|
}
|
||||||
#pragma warning disable 0618
|
|
||||||
var telemetry = new TelemetryListener("Microsoft.AspNet");
|
var diagnosticSource = new DiagnosticListener("Microsoft.AspNet");
|
||||||
if (telemetryListener != null)
|
if (diagnosticListener != null)
|
||||||
{
|
{
|
||||||
telemetry.SubscribeWithAdapter(telemetryListener);
|
diagnosticSource.SubscribeWithAdapter(diagnosticListener);
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
var httpContext = new Mock<HttpContext>();
|
var httpContext = new Mock<HttpContext>();
|
||||||
httpContext.Setup(h => h.RequestServices.GetService(typeof(IActionContextAccessor)))
|
httpContext.Setup(h => h.RequestServices.GetService(typeof(IActionContextAccessor)))
|
||||||
.Returns(new ActionContextAccessor());
|
.Returns(new ActionContextAccessor());
|
||||||
|
|
@ -300,10 +300,8 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
.Returns(new MvcMarkerService());
|
.Returns(new MvcMarkerService());
|
||||||
httpContext.Setup(h => h.RequestServices.GetService(typeof(IOptions<MvcOptions>)))
|
httpContext.Setup(h => h.RequestServices.GetService(typeof(IOptions<MvcOptions>)))
|
||||||
.Returns(optionsAccessor);
|
.Returns(optionsAccessor);
|
||||||
#pragma warning disable 0618
|
httpContext.Setup(h => h.RequestServices.GetService(typeof(DiagnosticSource)))
|
||||||
httpContext.Setup(h => h.RequestServices.GetService(typeof(TelemetrySource)))
|
.Returns(diagnosticSource);
|
||||||
.Returns(telemetry);
|
|
||||||
#pragma warning restore 0618
|
|
||||||
return new RouteContext(httpContext.Object);
|
return new RouteContext(httpContext.Object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@
|
||||||
"type": "build"
|
"type": "build"
|
||||||
},
|
},
|
||||||
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
|
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
|
||||||
"Microsoft.AspNet.Mvc.TestTelemetryListener.Sources": {
|
"Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources": {
|
||||||
"version": "6.0.0-*",
|
"version": "6.0.0-*",
|
||||||
"type": "build"
|
"type": "build"
|
||||||
},
|
},
|
||||||
"Microsoft.AspNet.Testing": "1.0.0-*",
|
"Microsoft.AspNet.Testing": "1.0.0-*",
|
||||||
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
|
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
|
||||||
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
|
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
|
||||||
"Microsoft.Extensions.TelemetryAdapter": "1.0.0-*",
|
"Microsoft.Extensions.DiagnosticAdapter": "1.0.0-*",
|
||||||
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
|
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
|
||||||
"Moq": "4.2.1312.1622",
|
"Moq": "4.2.1312.1622",
|
||||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>9879b5d5-2325-4a81-b4df-f279fe8feeb4</ProjectGuid>
|
<ProjectGuid>9879b5d5-2325-4a81-b4df-f279fe8feeb4</ProjectGuid>
|
||||||
<RootNamespace>Microsoft.AspNet.Mvc.TestTelemetryListener.Sources</RootNamespace>
|
<RootNamespace>Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources</RootNamespace>
|
||||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.Extensions.TelemetryAdapter;
|
using Microsoft.Extensions.DiagnosticAdapter;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public class TestTelemetryListener
|
public class TestDiagnosticListener
|
||||||
{
|
{
|
||||||
public class OnBeforeActionEventData
|
public class OnBeforeActionEventData
|
||||||
{
|
{
|
||||||
|
|
@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public OnBeforeActionEventData BeforeAction { get; set; }
|
public OnBeforeActionEventData BeforeAction { get; set; }
|
||||||
|
|
||||||
[TelemetryName("Microsoft.AspNet.Mvc.BeforeAction")]
|
[DiagnosticName("Microsoft.AspNet.Mvc.BeforeAction")]
|
||||||
public virtual void OnBeforeAction(
|
public virtual void OnBeforeAction(
|
||||||
IProxyHttpContext httpContext,
|
IProxyHttpContext httpContext,
|
||||||
IProxyRouteData routeData,
|
IProxyRouteData routeData,
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public OnAfterActionEventData AfterAction { get; set; }
|
public OnAfterActionEventData AfterAction { get; set; }
|
||||||
|
|
||||||
[TelemetryName("Microsoft.AspNet.Mvc.AfterAction")]
|
[DiagnosticName("Microsoft.AspNet.Mvc.AfterAction")]
|
||||||
public virtual void OnAfterAction(
|
public virtual void OnAfterAction(
|
||||||
IProxyHttpContext httpContext,
|
IProxyHttpContext httpContext,
|
||||||
IProxyActionDescriptor actionDescriptor)
|
IProxyActionDescriptor actionDescriptor)
|
||||||
|
|
@ -59,7 +59,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public OnBeforeActionMethodEventData BeforeActionMethod { get; set; }
|
public OnBeforeActionMethodEventData BeforeActionMethod { get; set; }
|
||||||
|
|
||||||
[TelemetryName("Microsoft.AspNet.Mvc.BeforeActionMethod")]
|
[DiagnosticName("Microsoft.AspNet.Mvc.BeforeActionMethod")]
|
||||||
public virtual void OnBeforeActionMethod(
|
public virtual void OnBeforeActionMethod(
|
||||||
IProxyActionContext actionContext,
|
IProxyActionContext actionContext,
|
||||||
IReadOnlyDictionary<string, object> arguments)
|
IReadOnlyDictionary<string, object> arguments)
|
||||||
|
|
@ -79,7 +79,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public OnAfterActionMethodEventData AfterActionMethod { get; set; }
|
public OnAfterActionMethodEventData AfterActionMethod { get; set; }
|
||||||
|
|
||||||
[TelemetryName("Microsoft.AspNet.Mvc.AfterActionMethod")]
|
[DiagnosticName("Microsoft.AspNet.Mvc.AfterActionMethod")]
|
||||||
public virtual void OnAfterActionMethod(
|
public virtual void OnAfterActionMethod(
|
||||||
IProxyActionContext actionContext,
|
IProxyActionContext actionContext,
|
||||||
IProxyActionResult result)
|
IProxyActionResult result)
|
||||||
|
|
@ -99,7 +99,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public OnBeforeActionResultEventData BeforeActionResult { get; set; }
|
public OnBeforeActionResultEventData BeforeActionResult { get; set; }
|
||||||
|
|
||||||
[TelemetryName("Microsoft.AspNet.Mvc.BeforeActionResult")]
|
[DiagnosticName("Microsoft.AspNet.Mvc.BeforeActionResult")]
|
||||||
public virtual void OnBeforeActionResult(IProxyActionContext actionContext, IProxyActionResult result)
|
public virtual void OnBeforeActionResult(IProxyActionContext actionContext, IProxyActionResult result)
|
||||||
{
|
{
|
||||||
BeforeActionResult = new OnBeforeActionResultEventData()
|
BeforeActionResult = new OnBeforeActionResultEventData()
|
||||||
|
|
@ -117,7 +117,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public OnAfterActionResultEventData AfterActionResult { get; set; }
|
public OnAfterActionResultEventData AfterActionResult { get; set; }
|
||||||
|
|
||||||
[TelemetryName("Microsoft.AspNet.Mvc.AfterActionResult")]
|
[DiagnosticName("Microsoft.AspNet.Mvc.AfterActionResult")]
|
||||||
public virtual void OnAfterActionResult(IProxyActionContext actionContext, IProxyActionResult result)
|
public virtual void OnAfterActionResult(IProxyActionContext actionContext, IProxyActionResult result)
|
||||||
{
|
{
|
||||||
AfterActionResult = new OnAfterActionResultEventData()
|
AfterActionResult = new OnAfterActionResultEventData()
|
||||||
|
|
@ -138,7 +138,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public OnViewFoundEventData ViewFound { get; set; }
|
public OnViewFoundEventData ViewFound { get; set; }
|
||||||
|
|
||||||
[TelemetryName("Microsoft.AspNet.Mvc.ViewFound")]
|
[DiagnosticName("Microsoft.AspNet.Mvc.ViewFound")]
|
||||||
public virtual void OnViewFound(
|
public virtual void OnViewFound(
|
||||||
IProxyActionContext actionContext,
|
IProxyActionContext actionContext,
|
||||||
bool isPartial,
|
bool isPartial,
|
||||||
|
|
@ -167,7 +167,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public OnViewNotFoundEventData ViewNotFound { get; set; }
|
public OnViewNotFoundEventData ViewNotFound { get; set; }
|
||||||
|
|
||||||
[TelemetryName("Microsoft.AspNet.Mvc.ViewNotFound")]
|
[DiagnosticName("Microsoft.AspNet.Mvc.ViewNotFound")]
|
||||||
public virtual void OnViewNotFound(
|
public virtual void OnViewNotFound(
|
||||||
IProxyActionContext actionContext,
|
IProxyActionContext actionContext,
|
||||||
bool isPartial,
|
bool isPartial,
|
||||||
|
|
@ -193,7 +193,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public OnBeforeViewEventData BeforeView { get; set; }
|
public OnBeforeViewEventData BeforeView { get; set; }
|
||||||
|
|
||||||
[TelemetryName("Microsoft.AspNet.Mvc.BeforeView")]
|
[DiagnosticName("Microsoft.AspNet.Mvc.BeforeView")]
|
||||||
public virtual void OnBeforeView(IProxyView view, IProxyViewContext viewContext)
|
public virtual void OnBeforeView(IProxyView view, IProxyViewContext viewContext)
|
||||||
{
|
{
|
||||||
BeforeView = new OnBeforeViewEventData()
|
BeforeView = new OnBeforeViewEventData()
|
||||||
|
|
@ -211,7 +211,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public OnAfterViewEventData AfterView { get; set; }
|
public OnAfterViewEventData AfterView { get; set; }
|
||||||
|
|
||||||
[TelemetryName("Microsoft.AspNet.Mvc.AfterView")]
|
[DiagnosticName("Microsoft.AspNet.Mvc.AfterView")]
|
||||||
public virtual void OnAfterView(IProxyView view, IProxyViewContext viewContext)
|
public virtual void OnAfterView(IProxyView view, IProxyViewContext viewContext)
|
||||||
{
|
{
|
||||||
AfterView = new OnAfterViewEventData()
|
AfterView = new OnAfterViewEventData()
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#if MOCK_SUPPORT
|
#if MOCK_SUPPORT
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.AspNet.Http.Internal;
|
using Microsoft.AspNet.Http.Internal;
|
||||||
|
|
@ -105,14 +105,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
private HttpContext GetHttpContext()
|
private HttpContext GetHttpContext()
|
||||||
{
|
{
|
||||||
var options = new TestOptionsManager<MvcViewOptions>();
|
var options = new TestOptionsManager<MvcViewOptions>();
|
||||||
#pragma warning disable 0618
|
|
||||||
var viewExecutor = new PartialViewResultExecutor(
|
var viewExecutor = new PartialViewResultExecutor(
|
||||||
options,
|
options,
|
||||||
new TestHttpResponseStreamWriterFactory(),
|
new TestHttpResponseStreamWriterFactory(),
|
||||||
new CompositeViewEngine(options),
|
new CompositeViewEngine(options),
|
||||||
new TelemetryListener("Microsoft.AspNet"),
|
new DiagnosticListener("Microsoft.AspNet"),
|
||||||
NullLoggerFactory.Instance);
|
NullLoggerFactory.Instance);
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
services.AddInstance(viewExecutor);
|
services.AddInstance(viewExecutor);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
#if MOCK_SUPPORT
|
#if MOCK_SUPPORT
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Http.Internal;
|
using Microsoft.AspNet.Http.Internal;
|
||||||
using Microsoft.AspNet.Mvc.Abstractions;
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
|
|
@ -70,18 +70,17 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(viewName, viewEngineResult.ViewName);
|
Assert.Equal(viewName, viewEngineResult.ViewName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable 0618
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void FindView_Notifies_ViewFound()
|
public void FindView_WritesDiagnostic_ViewFound()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var telemetry = new TelemetryListener("Test");
|
var diagnosticSource = new DiagnosticListener("Test");
|
||||||
var listener = new TestTelemetryListener();
|
var listener = new TestDiagnosticListener();
|
||||||
telemetry.SubscribeWithAdapter(listener);
|
diagnosticSource.SubscribeWithAdapter(listener);
|
||||||
|
|
||||||
var context = GetActionContext();
|
var context = GetActionContext();
|
||||||
var executor = GetViewExecutor(telemetry);
|
var executor = GetViewExecutor(diagnosticSource);
|
||||||
|
|
||||||
var viewName = "myview";
|
var viewName = "myview";
|
||||||
var viewResult = new PartialViewResult
|
var viewResult = new PartialViewResult
|
||||||
|
|
@ -106,15 +105,15 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void FindView_Notifies_ViewNotFound()
|
public void FindView_WritesDiagnostic_ViewNotFound()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var telemetry = new TelemetryListener("Test");
|
var diagnosticSource = new DiagnosticListener("Test");
|
||||||
var listener = new TestTelemetryListener();
|
var listener = new TestDiagnosticListener();
|
||||||
telemetry.SubscribeWithAdapter(listener);
|
diagnosticSource.SubscribeWithAdapter(listener);
|
||||||
|
|
||||||
var context = GetActionContext();
|
var context = GetActionContext();
|
||||||
var executor = GetViewExecutor(telemetry);
|
var executor = GetViewExecutor(diagnosticSource);
|
||||||
|
|
||||||
var viewName = "myview";
|
var viewName = "myview";
|
||||||
var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
|
var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
|
||||||
|
|
@ -142,7 +141,6 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
Assert.Equal(new string[] { "location/myview" }, listener.ViewNotFound.SearchedLocations);
|
Assert.Equal(new string[] { "location/myview" }, listener.ViewNotFound.SearchedLocations);
|
||||||
Assert.Equal("myview", listener.ViewNotFound.ViewName);
|
Assert.Equal("myview", listener.ViewNotFound.ViewName);
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ExecuteAsync_UsesContentType_FromPartialViewResult()
|
public async Task ExecuteAsync_UsesContentType_FromPartialViewResult()
|
||||||
|
|
@ -201,13 +199,12 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
return new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());
|
return new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable 0618
|
private PartialViewResultExecutor GetViewExecutor(DiagnosticSource diagnosticSource = null)
|
||||||
private PartialViewResultExecutor GetViewExecutor(TelemetrySource telemetry = null)
|
|
||||||
{
|
{
|
||||||
if (telemetry == null)
|
if (diagnosticSource == null)
|
||||||
{
|
{
|
||||||
telemetry = new TelemetryListener("Test");
|
diagnosticSource = new DiagnosticListener("Test");
|
||||||
}
|
}
|
||||||
|
|
||||||
var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
|
var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
|
||||||
|
|
@ -222,12 +219,11 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
options,
|
options,
|
||||||
new TestHttpResponseStreamWriterFactory(),
|
new TestHttpResponseStreamWriterFactory(),
|
||||||
new CompositeViewEngine(options),
|
new CompositeViewEngine(options),
|
||||||
telemetry,
|
diagnosticSource,
|
||||||
NullLoggerFactory.Instance);
|
NullLoggerFactory.Instance);
|
||||||
|
|
||||||
return viewExecutor;
|
return viewExecutor;
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#if MOCK_SUPPORT
|
#if MOCK_SUPPORT
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
@ -146,9 +146,9 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
Assert.Equal(500, context.Response.StatusCode);
|
Assert.Equal(500, context.Response.StatusCode);
|
||||||
Assert.Equal("abcd", Encoding.UTF8.GetString(memoryStream.ToArray()));
|
Assert.Equal("abcd", Encoding.UTF8.GetString(memoryStream.ToArray()));
|
||||||
}
|
}
|
||||||
#pragma warning disable 0618
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ExecuteAsync_WritesTelemetry()
|
public async Task ExecuteAsync_WritesDiagnostic()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var view = CreateView(async (v) =>
|
var view = CreateView(async (v) =>
|
||||||
|
|
@ -166,12 +166,12 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
new ActionDescriptor());
|
new ActionDescriptor());
|
||||||
var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
|
var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
|
||||||
|
|
||||||
var adapter = new TestTelemetryListener();
|
var adapter = new TestDiagnosticListener();
|
||||||
|
|
||||||
var telemetryListener = new TelemetryListener("Test");
|
var diagnosticSource = new DiagnosticListener("Test");
|
||||||
telemetryListener.SubscribeWithAdapter(adapter);
|
diagnosticSource.SubscribeWithAdapter(adapter);
|
||||||
|
|
||||||
var viewExecutor = CreateViewExecutor(telemetryListener);
|
var viewExecutor = CreateViewExecutor(diagnosticSource);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await viewExecutor.ExecuteAsync(
|
await viewExecutor.ExecuteAsync(
|
||||||
|
|
@ -190,7 +190,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
Assert.NotNull(adapter.AfterView?.View);
|
Assert.NotNull(adapter.AfterView?.View);
|
||||||
Assert.NotNull(adapter.AfterView?.ViewContext);
|
Assert.NotNull(adapter.AfterView?.ViewContext);
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ExecuteAsync_DoesNotWriteToResponse_OnceExceptionIsThrown()
|
public async Task ExecuteAsync_DoesNotWriteToResponse_OnceExceptionIsThrown()
|
||||||
{
|
{
|
||||||
|
|
@ -277,21 +277,20 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
return view.Object;
|
return view.Object;
|
||||||
}
|
}
|
||||||
#pragma warning disable 0618
|
|
||||||
private ViewExecutor CreateViewExecutor(TelemetryListener listener = null)
|
private ViewExecutor CreateViewExecutor(DiagnosticListener diagnosticSource = null)
|
||||||
{
|
{
|
||||||
if (listener == null)
|
if (diagnosticSource == null)
|
||||||
{
|
{
|
||||||
listener = new TelemetryListener("Test");
|
diagnosticSource = new DiagnosticListener("Test");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ViewExecutor(
|
return new ViewExecutor(
|
||||||
new TestOptionsManager<MvcViewOptions>(),
|
new TestOptionsManager<MvcViewOptions>(),
|
||||||
new TestHttpResponseStreamWriterFactory(),
|
new TestHttpResponseStreamWriterFactory(),
|
||||||
new Mock<ICompositeViewEngine>(MockBehavior.Strict).Object,
|
new Mock<ICompositeViewEngine>(MockBehavior.Strict).Object,
|
||||||
listener);
|
diagnosticSource);
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
#if MOCK_SUPPORT
|
#if MOCK_SUPPORT
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Http.Internal;
|
using Microsoft.AspNet.Http.Internal;
|
||||||
using Microsoft.AspNet.Mvc.Abstractions;
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
|
|
@ -71,17 +71,16 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
Assert.Equal(viewName, viewEngineResult.ViewName);
|
Assert.Equal(viewName, viewEngineResult.ViewName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable 0618
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void FindView_Notifies_ViewFound()
|
public void FindView_WritesDiagnostic_ViewFound()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var telemetry = new TelemetryListener("Test");
|
var diagnosticSource = new DiagnosticListener("Test");
|
||||||
var listener = new TestTelemetryListener();
|
var listener = new TestDiagnosticListener();
|
||||||
telemetry.SubscribeWithAdapter(listener);
|
diagnosticSource.SubscribeWithAdapter(listener);
|
||||||
|
|
||||||
var context = GetActionContext();
|
var context = GetActionContext();
|
||||||
var executor = GetViewExecutor(telemetry);
|
var executor = GetViewExecutor(diagnosticSource);
|
||||||
|
|
||||||
var viewName = "myview";
|
var viewName = "myview";
|
||||||
var viewResult = new ViewResult
|
var viewResult = new ViewResult
|
||||||
|
|
@ -106,15 +105,15 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void FindView_Notifies_ViewNotFound()
|
public void FindView_WritesDiagnostic_ViewNotFound()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var telemetry = new TelemetryListener("Test");
|
var diagnosticSource = new DiagnosticListener("Test");
|
||||||
var listener = new TestTelemetryListener();
|
var listener = new TestDiagnosticListener();
|
||||||
telemetry.SubscribeWithAdapter(listener);
|
diagnosticSource.SubscribeWithAdapter(listener);
|
||||||
|
|
||||||
var context = GetActionContext();
|
var context = GetActionContext();
|
||||||
var executor = GetViewExecutor(telemetry);
|
var executor = GetViewExecutor(diagnosticSource);
|
||||||
|
|
||||||
var viewName = "myview";
|
var viewName = "myview";
|
||||||
var viewEngine = new Mock<IViewEngine>();
|
var viewEngine = new Mock<IViewEngine>();
|
||||||
|
|
@ -142,7 +141,6 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
Assert.Equal(new string[] { "location/myview" }, listener.ViewNotFound.SearchedLocations);
|
Assert.Equal(new string[] { "location/myview" }, listener.ViewNotFound.SearchedLocations);
|
||||||
Assert.Equal("myview", listener.ViewNotFound.ViewName);
|
Assert.Equal("myview", listener.ViewNotFound.ViewName);
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ExecuteAsync_UsesContentType_FromViewResult()
|
public async Task ExecuteAsync_UsesContentType_FromViewResult()
|
||||||
|
|
@ -201,13 +199,12 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
return new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());
|
return new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable 0618
|
private ViewResultExecutor GetViewExecutor(DiagnosticListener diagnosticSource = null)
|
||||||
private ViewResultExecutor GetViewExecutor(TelemetrySource telemetry = null)
|
|
||||||
{
|
{
|
||||||
if (telemetry == null)
|
if (diagnosticSource == null)
|
||||||
{
|
{
|
||||||
telemetry = new TelemetryListener("Test");
|
diagnosticSource = new DiagnosticListener("Test");
|
||||||
}
|
}
|
||||||
|
|
||||||
var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
|
var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
|
||||||
|
|
@ -222,12 +219,11 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
options,
|
options,
|
||||||
new TestHttpResponseStreamWriterFactory(),
|
new TestHttpResponseStreamWriterFactory(),
|
||||||
new CompositeViewEngine(options),
|
new CompositeViewEngine(options),
|
||||||
telemetry,
|
diagnosticSource,
|
||||||
NullLoggerFactory.Instance);
|
NullLoggerFactory.Instance);
|
||||||
|
|
||||||
return viewExecutor;
|
return viewExecutor;
|
||||||
}
|
}
|
||||||
#pragma warning restore 0618
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#if MOCK_SUPPORT
|
#if MOCK_SUPPORT
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.AspNet.Http.Internal;
|
using Microsoft.AspNet.Http.Internal;
|
||||||
|
|
@ -105,14 +105,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
private HttpContext GetHttpContext()
|
private HttpContext GetHttpContext()
|
||||||
{
|
{
|
||||||
var options = new TestOptionsManager<MvcViewOptions>();
|
var options = new TestOptionsManager<MvcViewOptions>();
|
||||||
#pragma warning disable 0618
|
|
||||||
var viewExecutor = new ViewResultExecutor(
|
var viewExecutor = new ViewResultExecutor(
|
||||||
options,
|
options,
|
||||||
new TestHttpResponseStreamWriterFactory(),
|
new TestHttpResponseStreamWriterFactory(),
|
||||||
new CompositeViewEngine(options),
|
new CompositeViewEngine(options),
|
||||||
new TelemetryListener("Microsoft.AspNet"),
|
new DiagnosticListener("Microsoft.AspNet"),
|
||||||
NullLoggerFactory.Instance);
|
NullLoggerFactory.Instance);
|
||||||
#pragma warning restore 0618
|
|
||||||
|
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
services.AddInstance(viewExecutor);
|
services.AddInstance(viewExecutor);
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@
|
||||||
"version": "6.0.0-*",
|
"version": "6.0.0-*",
|
||||||
"type": "build"
|
"type": "build"
|
||||||
},
|
},
|
||||||
"Microsoft.AspNet.Mvc.TestTelemetryListener.Sources": {
|
"Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources": {
|
||||||
"version": "6.0.0-*",
|
"version": "6.0.0-*",
|
||||||
"type": "build"
|
"type": "build"
|
||||||
},
|
},
|
||||||
"Microsoft.AspNet.Testing": "1.0.0-*",
|
"Microsoft.AspNet.Testing": "1.0.0-*",
|
||||||
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
|
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
|
||||||
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
|
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
|
||||||
"Microsoft.Extensions.TelemetryAdapter": "1.0.0-*",
|
"Microsoft.Extensions.DiagnosticAdapter": "1.0.0-*",
|
||||||
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
|
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
|
||||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue